Commit d2cf3103 authored by berenger-bramas's avatar berenger-bramas

Git conflict.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@396 2616d619-271b-44dc-8df4-d4a8f33a7222
parent 99387669
......@@ -65,7 +65,7 @@ public:
/** Reset and allocate nbBytes memory filled with 0 */
void reserve(const int nbBytes){
buffer.clear();
reset();
buffer.set( 0, nbBytes);
}
......@@ -79,7 +79,7 @@ public:
template <class ClassType>
ClassType getValue(){
ClassType value = (*reinterpret_cast<ClassType*>(&buffer[index]));
index += sizeof(ClassType);
index += int(sizeof(ClassType));
return value;
}
......@@ -87,14 +87,14 @@ public:
template <class ClassType>
void fillValue(ClassType* const inValue){
(*inValue) = (*reinterpret_cast<ClassType*>(&buffer[index]));
index += sizeof(ClassType);
index += int(sizeof(ClassType));
}
/** Fill one/many value(s) with memcpy */
template <class ClassType>
void fillArray(ClassType* const inArray, const int inSize){
memcpy( inArray, &buffer[index], sizeof(ClassType) * inSize);
index += sizeof(ClassType) * inSize;
index += int(sizeof(ClassType) * inSize);
}
/** Same as fillValue */
......
......@@ -1026,7 +1026,7 @@ private:
// Prepare receive
for(int idxProc = 0 ; idxProc < nbProcess ; ++idxProc){
if(globalReceiveMap[idxProc * nbProcess + idProcess]){
recvBuffer[idxProc] = new FBufferReader(sizeof(ParticleClass) * globalReceiveMap[idxProc * nbProcess + idProcess]);
recvBuffer[idxProc] = new FBufferReader(int(sizeof(ParticleClass)) * globalReceiveMap[idxProc * nbProcess + idProcess]);
FMpi::MpiAssert( MPI_Irecv(recvBuffer[idxProc]->data(), recvBuffer[idxProc]->getSize(), MPI_BYTE,
idxProc, FMpi::TagFmmP2P, MPI_COMM_WORLD, &requests[iterRequest++]) , __LINE__ );
}
......@@ -1035,7 +1035,7 @@ private:
// Prepare send
for(int idxProc = 0 ; idxProc < nbProcess ; ++idxProc){
if(indexToSend[idxProc] != 0){
sendBuffer[idxProc] = new FBufferWriter(sizeof(ParticleClass) * partsToSend[idxProc]);
sendBuffer[idxProc] = new FBufferWriter(int(sizeof(ParticleClass)) * partsToSend[idxProc]);
for(int idxLeaf = 0 ; idxLeaf < indexToSend[idxProc] ; ++idxLeaf){
typename ContainerClass::BasicIterator iterSource(*toSend[idxProc][idxLeaf].getCurrentListSrc());
......
......@@ -438,7 +438,7 @@ private:
for(int idxProc = 1 ; idxProc < nbProcess ; ++idxProc ){
if( getWorkingInterval(1, idxProc - 1).max < getWorkingInterval(1, idxProc).max ){
MPI_Irecv(&recvBuffer[idxProc * recvBufferOffset], recvBufferOffset, MPI_BYTE, idxProc,
MPI_Irecv(&recvBuffer.data()[idxProc * recvBufferOffset], recvBufferOffset, MPI_BYTE, idxProc,
FMpi::TagFmmM2M, MPI_COMM_WORLD, &requests[iterRequests++]);
}
}
......@@ -448,10 +448,10 @@ private:
// retreive data and merge my child and the child from others
for(int idxProc = 1 ; idxProc < nbProcess ; ++idxProc){
if( getWorkingInterval(1, idxProc - 1).max < getWorkingInterval(1, idxProc).max ){
int state = int(recvBuffer[idxProc * recvBufferOffset]);
recvBuffer.seek(idxProc * recvBufferOffset);
int state = int(recvBuffer.getValue<char>());
int position = 0;
int bufferIndex = 1;
while( state && position < 8){
while(!(state & 0x1)){
state >>= 1;
......@@ -459,8 +459,7 @@ private:
}
fassert(!currentChild[position], "Already has a cell here", __LINE__, __FILE__);
recvBufferCells[position].deserializeUp(&recvBuffer[idxProc * recvBufferOffset + bufferIndex]);
bufferIndex += CellClass::SerializedSizeUp;
recvBufferCells[position].deserializeUp(recvBuffer);
currentChild[position] = (CellClass*) &recvBufferCells[position];
......@@ -482,18 +481,18 @@ private:
CellClass** child = octreeIterator.getCurrentBox();
char state = 0;
int idxBuff = 1;
sendBuffer.write(state);
for(int idxChild = firstChild ; idxChild <= lastChild ; ++idxChild){
if( child[idxChild] ){
child[idxChild]->serializeUp(&sendBuffer[idxBuff]);
idxBuff += CellClass::SerializedSizeUp;
child[idxChild]->serializeUp(sendBuffer);
state = char( state | (0x1 << idxChild));
}
}
sendBuffer[0] = state;
sendBuffer.writeAt(0,state);
MPI_Send(sendBuffer, idxBuff, MPI_BYTE, 0, FMpi::TagFmmM2M, MPI_COMM_WORLD);
MPI_Send(sendBuffer.data(), sendBuffer.getSize(), MPI_BYTE, 0, FMpi::TagFmmM2M, MPI_COMM_WORLD);
}
}
......@@ -879,7 +878,16 @@ private:
FBufferReader recvBuffer(MaxSizePerCell);
// Periodic
FMpi::MpiAssert( MPI_Bcast( &root, sizeof(CellClass), MPI_BYTE, 0, MPI_COMM_WORLD ), __LINE__ );
if( idProcess == 0){
root.serializeDown(sendBuffer);
FMpi::MpiAssert( MPI_Bcast( sendBuffer.data(), sendBuffer.getSize(), MPI_BYTE, 0, MPI_COMM_WORLD ), __LINE__ );
sendBuffer.reset();
}
else{
FMpi::MpiAssert( MPI_Bcast( recvBuffer.data(), recvBuffer.getSize(), MPI_BYTE, 0, MPI_COMM_WORLD ), __LINE__ );
root.deserializeDown(recvBuffer);
recvBuffer.reset();
}
kernels[0]->L2L(&root, octreeIterator.getCurrentBox(), 0);
// for each levels exepted leaf level
......@@ -917,7 +925,8 @@ private:
&& (getWorkingInterval((idxLevel + 1) , idProcess).min >> 3 ) <= (getWorkingInterval((idxLevel+1) , idProcess - 1).max >> 3 ) ){
needToRecv = true;
MPI_Irecv( recvBuffer, CellClass::SerializedSizeDown, MPI_BYTE, MPI_ANY_SOURCE, FMpi::TagFmmL2L, MPI_COMM_WORLD, &requests[iterRequests++]);
MPI_Irecv( recvBuffer.data(), recvBuffer.getSize(), MPI_BYTE, MPI_ANY_SOURCE,
FMpi::TagFmmL2L, MPI_COMM_WORLD, &requests[iterRequests++]);
}
......@@ -937,18 +946,18 @@ private:
if(firstProcThatRecv != endProcThatRecv){
iterArray[numberOfCells - 1].getCurrentCell()->serializeDown(sendBuffer);
for(int idxProc = firstProcThatRecv ; idxProc < endProcThatRecv ; ++idxProc ){
MPI_Isend(sendBuffer, CellClass::SerializedSizeDown, MPI_BYTE, idxProc, FMpi::TagFmmL2L, MPI_COMM_WORLD, &requests[iterRequests++]);
MPI_Isend(sendBuffer.data(), sendBuffer.getSize(), MPI_BYTE, idxProc,
FMpi::TagFmmL2L, MPI_COMM_WORLD, &requests[iterRequests++]);
}
}
}
FDEBUG(prepareCounter.tac());
FDEBUG(computationCounter.tic());
#pragma omp parallel
#pragma omp parallel
{
KernelClass& myThreadkernels = (*kernels[omp_get_thread_num()]);
#pragma omp for
#pragma omp for
for(int idxCell = firstCellWork + 1 ; idxCell < numberOfCells ; ++idxCell){
myThreadkernels.L2L( iterArray[idxCell].getCurrentCell() , iterArray[idxCell].getCurrentChild(), idxLevel);
}
......@@ -970,6 +979,9 @@ private:
FDEBUG(computationCounter.tac());
}
}
sendBuffer.reset();
recvBuffer.reset();
}
FDEBUG( FDebug::Controller << "\tFinished (@Downward Pass (L2L) = " << counterTime.tacAndElapsed() << "s)\n" );
......@@ -1004,10 +1016,10 @@ private:
int iterRequest = 0;
int nbMessagesToRecv = 0;
ParticleClass* sendBuffer[nbProcess];
FBufferWriter* sendBuffer[nbProcess];
memset(sendBuffer, 0, sizeof(ParticleClass*) * nbProcess);
ParticleClass* recvBuffer[nbProcess];
FBufferReader* recvBuffer[nbProcess];
memset(recvBuffer, 0, sizeof(ParticleClass*) * nbProcess);
int globalReceiveMap[nbProcess * nbProcess];
......@@ -1100,9 +1112,8 @@ private:
// Prepare receive
for(int idxProc = 0 ; idxProc < nbProcess ; ++idxProc){
if(globalReceiveMap[idxProc * nbProcess + idProcess]){
recvBuffer[idxProc] = reinterpret_cast<ParticleClass*>(new char[sizeof(ParticleClass) * globalReceiveMap[idxProc * nbProcess + idProcess]]);
FMpi::MpiAssert( MPI_Irecv(recvBuffer[idxProc], globalReceiveMap[idxProc * nbProcess + idProcess]*int(sizeof(ParticleClass)), MPI_BYTE,
recvBuffer[idxProc] = new FBufferReader(int(sizeof(ParticleClass)) * globalReceiveMap[idxProc * nbProcess + idProcess]);
FMpi::MpiAssert( MPI_Irecv(recvBuffer[idxProc]->data(), recvBuffer[idxProc]->getSize(), MPI_BYTE,
idxProc, FMpi::TagFmmP2P, MPI_COMM_WORLD, &requests[iterRequest++]) , __LINE__ );
}
}
......@@ -1110,16 +1121,16 @@ private:
// Prepare send
for(int idxProc = 0 ; idxProc < nbProcess ; ++idxProc){
if(indexToSend[idxProc] != 0){
sendBuffer[idxProc] = reinterpret_cast<ParticleClass*>(new char[sizeof(ParticleClass) * partsToSend[idxProc]]);
sendBuffer[idxProc] = new FBufferWriter(int(sizeof(ParticleClass)) * partsToSend[idxProc]);
int currentIndex = 0;
for(int idxLeaf = 0 ; idxLeaf < indexToSend[idxProc] ; ++idxLeaf){
memcpy(&sendBuffer[idxProc][currentIndex], toSend[idxProc][idxLeaf].getCurrentListSrc()->data(),
sizeof(ParticleClass) * toSend[idxProc][idxLeaf].getCurrentListSrc()->getSize() );
currentIndex += toSend[idxProc][idxLeaf].getCurrentListSrc()->getSize();
typename ContainerClass::BasicIterator iterSource(*toSend[idxProc][idxLeaf].getCurrentListSrc());
while( iterSource.hasNotFinished() ){
iterSource.data().save(*sendBuffer[idxProc]);
}
}
FMpi::MpiAssert( MPI_Isend( sendBuffer[idxProc], int(sizeof(ParticleClass)) * partsToSend[idxProc] , MPI_BYTE ,
FMpi::MpiAssert( MPI_Isend( sendBuffer[idxProc]->data(), sendBuffer[idxProc]->getSize() , MPI_BYTE ,
idxProc, FMpi::TagFmmP2P, MPI_COMM_WORLD, &requests[iterRequest++]) , __LINE__ );
}
......@@ -1260,10 +1271,13 @@ private:
for(int idxRcv = 0 ; idxRcv < countMessages ; ++idxRcv){
if( indexMessage[idxRcv] < nbMessagesToRecv ){
const int idxProc = status[idxRcv].MPI_SOURCE;
ParticleClass tempoParticle;
for(int idxPart = 0 ; idxPart < globalReceiveMap[idxProc * nbProcess + idProcess] ; ++idxPart){
otherP2Ptree.insert(recvBuffer[idxProc][idxPart]);
tempoParticle.restore(*recvBuffer[idxProc]);
otherP2Ptree.insert(tempoParticle);
}
delete [] reinterpret_cast<char*>(recvBuffer[idxProc]);
delete recvBuffer[idxProc];
recvBuffer[idxProc] = 0;
}
}
}
......
......@@ -32,7 +32,7 @@
class FTreeIO{
public:
/** To save in memory */
template <class OctreeClass, class CellClass, class ParticleClass, class ClassProptotype >
template <class OctreeClass, class CellClass, class ParticleClass , class ContainerClass >
static bool Save(const char filename[], OctreeClass& tree){
std::ofstream file(filename, std::ofstream::binary | std::ofstream::out );
FBufferWriter buffer;
......@@ -101,7 +101,7 @@ public:
iter.gotoNext();
}
const int sizeOfLeaf= buffer.getSize();
const int sizeOfLeaf = buffer.getSize();
file.write((const char*) &sizeOfLeaf, sizeof(int));
file.write(buffer.data(), buffer.getSize());
......@@ -158,7 +158,7 @@ public:
/** To load from memory */
template <class OctreeClass, class CellClass, class ParticleClass, class ClassProptotype >
template <class OctreeClass, class CellClass, class ParticleClass , class ContainerClass >
static bool Load(const char filename[], OctreeClass& tree){
std::ifstream file(filename, std::ifstream::binary | std::ifstream::in );
FBufferReader buffer;
......
......@@ -186,12 +186,13 @@ public:
//FReal alpha_and_beta[2] = {1.0, 0.0};
//CblasTrans
FBlas::gemtv( static_cast<unsigned int>(FF_MATRIX_COLUMN_DIM),
static_cast<unsigned int>(FF_MATRIX_ROW_DIM),
FReal(1.0),
(FReal*)M2L_Outer_transfer,
(FReal*)temporaryMultiSource,
(FReal*)local_exp);
FBlas::gemtva(
static_cast<unsigned int>(FF_MATRIX_ROW_DIM),
static_cast<unsigned int>(FF_MATRIX_COLUMN_DIM),
FReal(1.0),
(FReal*)M2L_Outer_transfer,
(FReal*)temporaryMultiSource,
(FReal*)local_exp);
}
};
......
......@@ -68,7 +68,7 @@ int main(int argc, char ** argv){
}
// -----------------------------------------------------
CellClass::Init(DevP);
CellClass::Init(DevP, true);
OctreeClass tree(NbLevels, SizeSubLevels,loader.getBoxWidth(),loader.getCenterOfBox());
// -----------------------------------------------------
......
......@@ -70,7 +70,7 @@ int main(int argc, char ** argv){
const int NbLevels = FParameters::getValue(argc,argv,"-h", 5);
const int SizeSubLevels = FParameters::getValue(argc,argv,"-sh", 3);
FTic counter;
const long NbPart = 200000;//2000000
const int NbPart = 200000;//2000000
const double BoxWidth = 1.0;
const F3DPosition CenterOfBox(0.5,0.5,0.5);
const FReal FRandMax = FReal(RAND_MAX);
......
......@@ -59,7 +59,7 @@ int main(int argc, char ** argv){
const int NbLevels = FParameters::getValue(argc,argv,"-h", 7);
const int SizeSubLevels = FParameters::getValue(argc,argv,"-sh", 3);
const long NbPart = FParameters::getValue(argc,argv,"-nb", 2000000);
const int NbPart = FParameters::getValue(argc,argv,"-nb", 2000000);
FTic counter;
//////////////////////////////////////////////////////////////////////////////////
......
......@@ -67,7 +67,7 @@ int main(int argc, char ** argv){
const int NbLevels = FParameters::getValue(argc,argv,"-h", 5);
const int SizeSubLevels = FParameters::getValue(argc,argv,"-sh", 3);
const long NbPart = FParameters::getValue(argc,argv,"-nb", 2000000);
const int NbPart = FParameters::getValue(argc,argv,"-nb", 2000000);
FTic counter;
//////////////////////////////////////////////////////////////////////////////////
......
......@@ -135,7 +135,7 @@ int main(int argc, char ** argv){
const int NbLevels = FParameters::getValue(argc,argv,"-h", 5);
const int SizeSubLevels = FParameters::getValue(argc,argv,"-sh", 3);
const long NbPart = FParameters::getValue(argc,argv,"-pn", 20L);
const int NbPart = FParameters::getValue(argc,argv,"-pn", 20L);
FTic counter;
//////////////////////////////////////////////////////////////////////////////////
......
......@@ -62,7 +62,7 @@ int main(int argc, char ** argv){
const int NbLevels = FParameters::getValue(argc,argv,"-h", 5);
const int SizeSubLevels = FParameters::getValue(argc,argv,"-sh", 3);
const long NbPart = FParameters::getValue(argc,argv,"-nb", 2000000);
const int NbPart = FParameters::getValue(argc,argv,"-nb", 2000000);
const long DevP = FParameters::getValue(argc,argv,"-p", 5);
const FReal FRandMax = FReal(RAND_MAX);
const F3DPosition centerOfBox = F3DPosition(0.5,0.5,0.5);
......
......@@ -45,7 +45,7 @@ int main(int argc, char ** argv){
const int NbLevels = FParameters::getValue(argc,argv,"-h", 7);
const int SizeSubLevels = FParameters::getValue(argc,argv,"-sh", 3);
const long NbPart = FParameters::getValue(argc,argv,"-nb", 2000000);
const int NbPart = FParameters::getValue(argc,argv,"-nb", 2000000);
const FReal FRandMax = FReal(RAND_MAX);
FTic counter;
......
......@@ -33,9 +33,9 @@
// Simply create particles and try the kernels
int main(int argc, char ** argv){
typedef FSerializableSphericalParticle ParticleClass;
typedef FSerializableSphericalCell CellClass;
typedef FVector<ParticleClass> ContainerClass;
typedef FSphericalParticle ParticleClass;
typedef FSphericalCell CellClass;
typedef FVector<ParticleClass> ContainerClass;
typedef FSimpleLeaf<ParticleClass, ContainerClass > LeafClass;
typedef FOctree<ParticleClass, CellClass, ContainerClass , LeafClass > OctreeClass;
......@@ -57,7 +57,7 @@ int main(int argc, char ** argv){
}
// -----------------------------------------------------
CellClass::Init(5);
OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox());
// -----------------------------------------------------
......@@ -75,13 +75,13 @@ int main(int argc, char ** argv){
std::cout << "Save tree ..." << std::endl;
FTreeIO::Save<OctreeClass, CellClass, ParticleClass >("/tmp/tree.data", tree);
FTreeIO::Save<OctreeClass, CellClass, ParticleClass, ContainerClass >("/tmp/tree.data", tree);
// -----------------------------------------------------
std::cout << "Load tree ..." << std::endl;
FTreeIO::Load<OctreeClass, CellClass, ParticleClass >("/tmp/tree.data", tree);
FTreeIO::Load<OctreeClass, CellClass, ParticleClass, ContainerClass >("/tmp/tree.data", tree);
return 0;
}
......
......@@ -28,52 +28,9 @@
This test compare a previous FMM result with a simulation.
*/
/** The result of a previous simulation has been saved and will be oponed */
class ParticleSerial : public FSphericalParticle, public FTreeIO::FAbstractSerial {
public:
void write(std::ofstream*const stream) const{
save(stream, getPosition().getX());
save(stream, getPosition().getY());
save(stream, getPosition().getZ());
save(stream, getForces().getX());
save(stream, getForces().getY());
save(stream, getForces().getZ());
save(stream, getPotential());
save(stream, getPhysicalValue());
}
void read(std::ifstream*const stream) {
const FReal posX = restore<FReal>(stream);
const FReal posY = restore<FReal>(stream);
const FReal posZ = restore<FReal>(stream);
setPosition(posX, posY, posZ);
const FReal forceX = restore<FReal>(stream);
const FReal forceY = restore<FReal>(stream);
const FReal forceZ = restore<FReal>(stream);
setForces(forceX, forceY, forceZ);
setPotential(restore<FReal>(stream));
setPhysicalValue(restore<FReal>(stream));
}
};
/** The result of a previous simulation has been saved and will be oponed */
class ComputeCellSerial : public FSphericalCell, public FTreeIO::FAbstractSerial {
public:
void write(std::ofstream*const stream) const{
saveArray(stream, FSphericalCell::getMultipole(), FSphericalCell::GetPoleSize());
saveArray(stream, FSphericalCell::getLocal(), FSphericalCell::GetLocalSize());
}
void read(std::ifstream*const stream){
restoreArray(stream, FSphericalCell::getMultipole(), FSphericalCell::GetPoleSize());
restoreArray(stream, FSphericalCell::getLocal(), FSphericalCell::GetLocalSize());
}
};
typedef ParticleSerial ParticleClass;
typedef ComputeCellSerial CellClass;
typedef FSphericalParticle ParticleClass;
typedef FSphericalCell CellClass;
typedef FVector<ParticleClass> ContainerClass;
typedef FSphericalKernel<ParticleClass, CellClass, ContainerClass > KernelClass;
......@@ -113,11 +70,11 @@ class TestFmb : public FUTester<TestFmb> {
algo.execute();
// If needed save the result
// FTreeIO::Save<OctreeClass, CellClass, ParticleClass, FTreeIO::Serializer<CellClass, ParticleClass> >(DataFile, testTree);
// FTreeIO::Save<OctreeClass, CellClass, ParticleClass, ContainerClass >(DataFile, testTree);
// Load previous result
OctreeClass goodTree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox());
FTreeIO::Load<OctreeClass, CellClass, ParticleClass, FTreeIO::Serializer<CellClass, ParticleClass> >(DataFile, goodTree);
FTreeIO::Load<OctreeClass, CellClass, ParticleClass, ContainerClass >(DataFile, goodTree);
// Compare the two simulations
Print("Check the particles...");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment