Commit 6ee28dd9 authored by PIACIBELLO Cyrille's avatar PIACIBELLO Cyrille

Api updated : Error spotted by D Barbier fixed alongside another one, and add...

Api updated : Error spotted by D Barbier fixed alongside another one, and add a definition of scalfmm_call_delete()
parent f47afb0a
...@@ -428,7 +428,7 @@ public: ...@@ -428,7 +428,7 @@ public:
template<class ContainerClass,class LeafClass,class CellClass> template<class ContainerClass,class LeafClass,class CellClass>
void generic_set_positions(FOctree<FReal,CellClass,ContainerClass,LeafClass> * octree, void generic_set_positions(FOctree<FReal,CellClass,ContainerClass,LeafClass> * octree,
int NbPositions, FReal * X, FReal * Y, FReal * Z, PartType type){ int NbPositions, FReal * X, FReal * Y, FReal * Z, PartType type){
int checkCount = 0; int checkCount = 0;
if(type == SOURCE || type==BOTH){ if(type == SOURCE || type==BOTH){
octree->forEachLeaf([&](LeafClass* leaf){ octree->forEachLeaf([&](LeafClass* leaf){
...@@ -564,7 +564,7 @@ public: ...@@ -564,7 +564,7 @@ public:
template<class ContainerClass,class LeafClass,class CellClass> template<class ContainerClass,class LeafClass,class CellClass>
void generic_get_positions_xyz(FOctree<FReal,CellClass,ContainerClass,LeafClass> * octree, void generic_get_positions_xyz(FOctree<FReal,CellClass,ContainerClass,LeafClass> * octree,
int NbPositions, FReal * positionsToFill, PartType type){ int NbPositions, FReal * positionsToFill, PartType type){
int checkCount = 0; int checkCount = 0;
if(type == SOURCE || type==BOTH){ if(type == SOURCE || type==BOTH){
octree->forEachLeaf([&](LeafClass* leaf){ octree->forEachLeaf([&](LeafClass* leaf){
...@@ -599,7 +599,7 @@ public: ...@@ -599,7 +599,7 @@ public:
template<class ContainerClass,class LeafClass,class CellClass> template<class ContainerClass,class LeafClass,class CellClass>
void generic_get_positions_xyz_npart(FOctree<FReal,CellClass,ContainerClass,LeafClass> * octree, void generic_get_positions_xyz_npart(FOctree<FReal,CellClass,ContainerClass,LeafClass> * octree,
int NbPositions, int * idxOfParticles, FReal * positionsToFill, PartType type){ int NbPositions, int * idxOfParticles, FReal * positionsToFill, PartType type){
int checkCount = 0; int checkCount = 0;
if(type == SOURCE || type==BOTH){ if(type == SOURCE || type==BOTH){
octree->forEachLeaf([&](LeafClass* leaf){ octree->forEachLeaf([&](LeafClass* leaf){
...@@ -654,7 +654,7 @@ public: ...@@ -654,7 +654,7 @@ public:
template<class ContainerClass,class LeafClass,class CellClass> template<class ContainerClass,class LeafClass,class CellClass>
void generic_get_positions(FOctree<FReal,CellClass,ContainerClass,LeafClass> * octree, void generic_get_positions(FOctree<FReal,CellClass,ContainerClass,LeafClass> * octree,
int NbPositions, FReal * X, FReal * Y , FReal * Z, PartType type){ int NbPositions, FReal * X, FReal * Y , FReal * Z, PartType type){
int checkCount = 0; int checkCount = 0;
if(type == SOURCE || type==BOTH){ if(type == SOURCE || type==BOTH){
octree->forEachLeaf([&](LeafClass* leaf){ octree->forEachLeaf([&](LeafClass* leaf){
...@@ -689,7 +689,7 @@ public: ...@@ -689,7 +689,7 @@ public:
template<class ContainerClass,class LeafClass,class CellClass> template<class ContainerClass,class LeafClass,class CellClass>
void generic_get_positions_npart(FOctree<FReal,CellClass,ContainerClass,LeafClass> * octree, void generic_get_positions_npart(FOctree<FReal,CellClass,ContainerClass,LeafClass> * octree,
int NbPositions, int * idxOfParticles,FReal * X, FReal * Y , FReal * Z,PartType type){ int NbPositions, int * idxOfParticles,FReal * X, FReal * Y , FReal * Z,PartType type){
int checkCount = 0; int checkCount = 0;
if(type == SOURCE || type==BOTH){ if(type == SOURCE || type==BOTH){
octree->forEachLeaf([&](LeafClass* leaf){ octree->forEachLeaf([&](LeafClass* leaf){
...@@ -865,12 +865,12 @@ extern "C" void scalfmm_get_physical_values(scalfmm_handle Handle, int nbPhysica ...@@ -865,12 +865,12 @@ extern "C" void scalfmm_get_physical_values(scalfmm_handle Handle, int nbPhysica
extern "C" void scalfmm_set_physical_values_npart(scalfmm_handle Handle, int nbPhysicalValues, extern "C" void scalfmm_set_physical_values_npart(scalfmm_handle Handle, int nbPhysicalValues,
int* idxOfParticles, double * physicalValues, PartType type){ int* idxOfParticles, double * physicalValues, PartType type){
((ScalFmmCoreHandle<double> * ) Handle)->engine->set_physical_values_npart(nbPhysicalValues, ((ScalFmmCoreHandle<double> * ) Handle)->engine->set_physical_values_npart(nbPhysicalValues,
idxOfParticles, physicalValues, type); idxOfParticles, physicalValues, type);
} }
extern "C" void scalfmm_get_physical_values_npart(scalfmm_handle Handle, int nbPhysicalValues, extern "C" void scalfmm_get_physical_values_npart(scalfmm_handle Handle, int nbPhysicalValues,
int* idxOfParticles, double * physicalValues, PartType type){ int* idxOfParticles, double * physicalValues, PartType type){
((ScalFmmCoreHandle<double> * ) Handle)->engine->get_physical_values_npart(nbPhysicalValues, ((ScalFmmCoreHandle<double> * ) Handle)->engine->get_physical_values_npart(nbPhysicalValues,
idxOfParticles, physicalValues, type); idxOfParticles, physicalValues, type);
} }
//To get the result //To get the result
...@@ -1073,6 +1073,10 @@ extern "C" void scalfmm_generic_partition(scalfmm_handle handle, FSize nbThings, ...@@ -1073,6 +1073,10 @@ extern "C" void scalfmm_generic_partition(scalfmm_handle handle, FSize nbThings,
((ScalFmmCoreHandle<double> * ) handle)->engine->generic_partition(nbThings,sizeofthing,arrayOfThing,newArray); ((ScalFmmCoreHandle<double> * ) handle)->engine->generic_partition(nbThings,sizeofthing,arrayOfThing,newArray);
} }
extern "C" void scalfmm_call_delete(void * inPtr){
delete [] static_cast<double*>(inPtr);
}
#endif #endif
#endif #endif
...@@ -431,6 +431,8 @@ public: ...@@ -431,6 +431,8 @@ public:
~FUserKernelDistrEngine(){ ~FUserKernelDistrEngine(){
delete comm; delete comm;
comm = nullptr; comm = nullptr;
delete kernel;
delete octreeDist;
} }
//Qu'est-ce qu'il faut que je surcharge ? //Qu'est-ce qu'il faut que je surcharge ?
...@@ -486,15 +488,20 @@ public: ...@@ -486,15 +488,20 @@ public:
for(int id = 0 ; id<nbPoints ; ++id){ for(int id = 0 ; id<nbPoints ; ++id){
FTreeCoordinate host; FTreeCoordinate host;
arrayToBeSorted[id].position = FPoint<FReal>(particleXYZ[id+0],particleXYZ[id+1],particleXYZ[id+2]); arrayToBeSorted[id].position = FPoint<FReal>(particleXYZ[3*id+0],
particleXYZ[3*id+1],
particleXYZ[3*id+2]);
arrayToBeSorted[id].orIndex = id + Ind.getoriIntervals(myRank).first; arrayToBeSorted[id].orIndex = id + Ind.getoriIntervals(myRank).first;
arrayToBeSorted[id].orOwner = myRank; arrayToBeSorted[id].orOwner = myRank;
//Evaluate Morton Index //Evaluate Morton Index
host.setX(FCoordinateComputer::GetTreeCoordinate<FReal>(particleXYZ[id*3+0] - this->getBoxCorner().getX(),this->getBoxWidth(),this->getBoxWidthAtLeafLevel(), host.setX(FCoordinateComputer::GetTreeCoordinate<FReal>(particleXYZ[id*3+0] - this->getBoxCorner().getX(),
this->getBoxWidth(),this->getBoxWidthAtLeafLevel(),
this->getTreeHeight())); this->getTreeHeight()));
host.setX(FCoordinateComputer::GetTreeCoordinate<FReal>(particleXYZ[id*3+1] - this->getBoxCorner().getY(),this->getBoxWidth(),this->getBoxWidthAtLeafLevel(), host.setX(FCoordinateComputer::GetTreeCoordinate<FReal>(particleXYZ[id*3+1] - this->getBoxCorner().getY(),
this->getBoxWidth(),this->getBoxWidthAtLeafLevel(),
this->getTreeHeight())); this->getTreeHeight()));
host.setX(FCoordinateComputer::GetTreeCoordinate<FReal>(particleXYZ[id*3+2] - this->getBoxCorner().getZ(),this->getBoxWidth(),this->getBoxWidthAtLeafLevel(), host.setX(FCoordinateComputer::GetTreeCoordinate<FReal>(particleXYZ[id*3+2] - this->getBoxCorner().getZ(),
this->getBoxWidth(),this->getBoxWidthAtLeafLevel(),
this->getTreeHeight())); this->getTreeHeight()));
arrayToBeSorted[id].index = host.getMortonIndex(); arrayToBeSorted[id].index = host.getMortonIndex();
} }
...@@ -578,11 +585,11 @@ public: ...@@ -578,11 +585,11 @@ public:
return A*stride; return A*stride;
}); });
std::transform(Ind.getDisplSendVector().begin(),Ind.getDisplSendVector().end(),displSendByte.begin(), std::transform(Ind.getDisplSendVector().begin(),Ind.getDisplSendVector().end(),displSendByte.begin(),
[&](const FSize & A){ [&](const FSize & A){
return A*stride; return A*stride;
}); });
std::transform(Ind.getDisplRecvVector().begin(),Ind.getDisplRecvVector().end(),displRecvByte.begin(), std::transform(Ind.getDisplRecvVector().begin(),Ind.getDisplRecvVector().end(),displRecvByte.begin(),
[&](const FSize & A){ [&](const FSize & A){
return A*stride; return A*stride;
}); });
std::vector<char > recvBuffer; std::vector<char > recvBuffer;
...@@ -603,12 +610,13 @@ public: ...@@ -603,12 +610,13 @@ public:
//Then, i need to find the index where current index //Then, i need to find the index where current index
//is sorted inside currentArray; //is sorted inside currentArray;
FSize idSearch = 0; FSize idSearch = 0;
for(idSearch=0 ; idSearch < Ind.getCount(myRank) && (Ind.getCurrentArrayValue(idSearch) != currentIndex) ; ++idSearch); for(idSearch=0 ; idSearch < Ind.getCount(myRank) && (Ind.getCurrentArrayValue(idSearch) != currentIndex) ; ++idSearch){
memcpy(&output[idSearch*stride],&recvBuffer[idRead*stride],stride); memcpy(&output[idSearch*stride],&recvBuffer[idRead*stride],stride);
}
} }
//C Part //C Part
*newArray = malloc(output.size()); *newArray = new char[output.size()];
memcpy(*newArray,output.data(),output.size()); memcpy(*newArray,output.data(),output.size());
} }
...@@ -696,13 +704,13 @@ public: ...@@ -696,13 +704,13 @@ public:
//Only one config shall work , so let's use it //Only one config shall work , so let's use it
switch(FScalFMMEngine<FReal>::Algorithm){ switch(FScalFMMEngine<FReal>::Algorithm){
case 5: case 5:
{ {
typedef FFmmAlgorithmThreadProc<OctreeClass,CoreCellDist,ContainerClass,CoreKernelClass,LeafClass> AlgoProcClass; typedef FFmmAlgorithmThreadProc<OctreeClass,CoreCellDist,ContainerClass,CoreKernelClass,LeafClass> AlgoProcClass;
AlgoProcClass * algoProc = new AlgoProcClass(*comm,octreeDist,kernel); AlgoProcClass * algoProc = new AlgoProcClass(*comm,octreeDist,kernel);
FScalFMMEngine<FReal>::algoTimer = algoProc; FScalFMMEngine<FReal>::algoTimer = algoProc;
algoProc->execute(FFmmP2M | FFmmM2M | FFmmM2L | FFmmL2L | FFmmL2P | FFmmP2P); algoProc->execute(FFmmP2M | FFmmM2M | FFmmM2L | FFmmL2L | FFmmL2P | FFmmP2P);
break; break;
} }
default: default:
break; break;
} }
...@@ -714,13 +722,13 @@ public: ...@@ -714,13 +722,13 @@ public:
//Only one config shall work , so let's use it //Only one config shall work , so let's use it
switch(FScalFMMEngine<FReal>::Algorithm){ switch(FScalFMMEngine<FReal>::Algorithm){
case 5: case 5:
{ {
typedef FFmmAlgorithmThreadProc<OctreeClass,CoreCellDist,ContainerClass,CoreKernelClass,LeafClass> AlgoProcClass; typedef FFmmAlgorithmThreadProc<OctreeClass,CoreCellDist,ContainerClass,CoreKernelClass,LeafClass> AlgoProcClass;
AlgoProcClass * algoProc = new AlgoProcClass(*comm,octreeDist,kernel); AlgoProcClass * algoProc = new AlgoProcClass(*comm,octreeDist,kernel);
FScalFMMEngine<FReal>::algoTimer = algoProc; FScalFMMEngine<FReal>::algoTimer = algoProc;
algoProc->execute(FFmmP2M | FFmmM2M | FFmmM2L | FFmmL2L | FFmmL2P); algoProc->execute(FFmmP2M | FFmmM2M | FFmmM2L | FFmmL2L | FFmmL2P);
break; break;
} }
default: default:
break; break;
} }
......
...@@ -175,9 +175,9 @@ void on_leaf(int level, FSize nbParts, const FSize * idxParts, long long morton_ ...@@ -175,9 +175,9 @@ void on_leaf(int level, FSize nbParts, const FSize * idxParts, long long morton_
double pot = 0; double pot = 0;
for(int i=0 ; i<nbParts ; ++i){ for(int i=0 ; i<nbParts ; ++i){
pot += potentials[i]; ptrToUserData->totalEnergy += potentials[i]*(ptrToUserData->myPhyValues[idxParts[i]]);
} }
ptrToUserData->totalEnergy += pot*(ptrToUserData->myPhyValues[idxParts[i]]);
} }
/* printf("I'm leaf at %lld pos, of center [%e %e %e], containing %lld parts\n", */ /* printf("I'm leaf at %lld pos, of center [%e %e %e], containing %lld parts\n", */
/* morton_index,center[0],center[1],center[2],nbParts); */ /* morton_index,center[0],center[1],center[2],nbParts); */
...@@ -319,8 +319,6 @@ int main(int argc, char ** argv){ ...@@ -319,8 +319,6 @@ int main(int argc, char ** argv){
//Only read, so no split needed //Only read, so no split needed
userDatas.insertedPositions = outputArray; // Set the position userDatas.insertedPositions = outputArray; // Set the position
//Need to get the good ones...
double * newPhyValues = malloc(sizeof(double) * outputNbPoint);
//In this part, we store the physicalvalues //In this part, we store the physicalvalues
//Create as many array of forces as there are threads in order to //Create as many array of forces as there are threads in order to
...@@ -364,6 +362,7 @@ int main(int argc, char ** argv){ ...@@ -364,6 +362,7 @@ int main(int argc, char ** argv){
//Dealloc scalfmm handle //Dealloc scalfmm handle
scalfmm_dealloc_handle(Handle,cheb_free_cell); scalfmm_dealloc_handle(Handle,cheb_free_cell);
{//This part will write generated particles to a file at ScalFMM {//This part will write generated particles to a file at ScalFMM
//format in order to verify numercal results //format in order to verify numercal results
/* if(my_rank==0){ */ /* if(my_rank==0){ */
...@@ -395,8 +394,9 @@ int main(int argc, char ** argv){ ...@@ -395,8 +394,9 @@ int main(int argc, char ** argv){
/* } */ /* } */
} }
free(outputIndexes); scalfmm_call_delete(outputIndexes);
free(outputArray); scalfmm_call_delete(outputArray);
scalfmm_call_delete(*outputPhyValPtr);
MPI_Finalize(); MPI_Finalize();
......
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