Commit 756ee978 authored by COULAUD Olivier's avatar COULAUD Olivier

Add Blas spherical kernel

parent 0f1f7398
......@@ -319,7 +319,7 @@ int main(int argc, char* argv[])
}
time.tac();
std::cout << "( FFmaBlas@Inserting Particles = " << time.elapsed() << " s)." << std::endl;
std::cout << "( FFmaBlockBlas@Inserting Particles = " << time.elapsed() << " s)." << std::endl;
} // -----------------------------------------------------
// -----------------------------------------------------
......@@ -328,7 +328,7 @@ int main(int argc, char* argv[])
FmmClass algorithm(&tree, &kernels);
algorithm.execute();
time.tac();
std::cout << "(FFmaBlas @Algorithm = " << time.elapsed() << " s)." << std::endl;
std::cout << "(FFmaBlockBlas @Algorithm = " << time.elapsed() << " s)." << std::endl;
// -----------------------------------------------------
FReal energy = 0.0;
......@@ -357,12 +357,80 @@ int main(int argc, char* argv[])
}
// Print for information
std::cout << "FFmaBlas Energy " << FMath::Abs(energy-energyD) /energyD << std::endl;
std::cout << "FFmaBlas Potential " << potentialDiff << std::endl;
std::cout << "FFmaBlas Fx " << fx << std::endl;
std::cout << "FFmaBlas Fy " << fy << std::endl;
std::cout << "FFmaBlas Fz " << fz << std::endl;
std::cout << "FFmaBlockBlas Energy " << FMath::Abs(energy-energyD) /energyD << std::endl;
std::cout << "FFmaBlockBlas Potential " << potentialDiff << std::endl;
std::cout << "FFmaBlockBlas Fx " << fx << std::endl;
std::cout << "FFmaBlockBlas Fy " << fy << std::endl;
std::cout << "FFmaBlockBlas Fz " << fz << std::endl;
} // end FFmaBlas kernel
{ // begin FFmaBlas kernel
std::cout << "\nFFmaBlas FMM ... P: " <<DevP << std::endl;
// typedefs
typedef FSphericalCell CellClass;
typedef FP2PParticleContainerIndexed<> ContainerClass;
typedef FSimpleLeaf< ContainerClass > LeafClass;
typedef FOctree< CellClass, ContainerClass , LeafClass > OctreeClass;
typedef FSphericalBlasKernel< CellClass, ContainerClass > KernelClass;
typedef FFmmAlgorithmThread<OctreeClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass;
// init cell class and oct-tree
CellClass::Init(DevP, true); // only for blas
OctreeClass tree(TreeHeight, SubTreeHeight, loader.getBoxWidth(), loader.getCenterOfBox());
{ // -----------------------------------------------------
time.tic();
for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){
// put in tree
tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue());
}
time.tac();
std::cout << "( FFmaBlas@Inserting Particles = " << time.elapsed() << " s)." << std::endl;
} // -----------------------------------------------------
// -----------------------------------------------------
time.tic();
KernelClass kernels(DevP, TreeHeight, loader.getBoxWidth(), loader.getCenterOfBox());
FmmClass algorithm(&tree, &kernels);
algorithm.execute();
time.tac();
std::cout << "(FFmaBlas @Algorithm = " << time.elapsed() << " s)." << std::endl;
// -----------------------------------------------------
FReal energy = 0.0;
FMath::FAccurater potentialDiff;
FMath::FAccurater fx, fy, fz;
{ // Check that each particle has been summed with all other
tree.forEachLeaf([&](LeafClass* leaf){
const FReal*const physicalValues = leaf->getTargets()->getPhysicalValues();
const FReal*const potentials = leaf->getTargets()->getPotentials();
const FReal*const forcesX = leaf->getTargets()->getForcesX();
const FReal*const forcesY = leaf->getTargets()->getForcesY();
const FReal*const forcesZ = leaf->getTargets()->getForcesZ();
const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles();
const FVector<int>& indexes = leaf->getTargets()->getIndexes();
for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){
const int indexPartOrig = indexes[idxPart];
potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]);
fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]);
fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]);
fz.add(particles[indexPartOrig].getForces()[2],forcesZ[idxPart]);
energy += potentials[idxPart]*physicalValues[idxPart] ;
}
});
}
// Print for information
std::cout << "FFmaBlas Energy " << FMath::Abs(energy-energyD) /energyD << std::endl;
std::cout << "FFmaBlas Potential " << potentialDiff << std::endl;
std::cout << "FFmaBlas Fx " << fx << std::endl;
std::cout << "FFmaBlas Fy " << fy << std::endl;
std::cout << "FFmaBlas Fz " << fz << std::endl;
} // end FFmaBlas kernel
#endif
#ifdef ScalFMM_USE_FFT
......
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