Commit 1f69b258 authored by Matthias Messner's avatar Matthias Messner
parents 57ea27fd d788edc1
......@@ -150,7 +150,8 @@ void ValidateFMMAlgo(OctreeClass* const tree){
octreeIterator.gotoBottomLeft();
do{
if(octreeIterator.getCurrentCell()->getDataUp() != octreeIterator.getCurrentListSrc()->getSize() ){
std::cout << "Problem P2M : " << (octreeIterator.getCurrentCell()->getDataUp() - octreeIterator.getCurrentListSrc()->getSize()) << "\n";
std::cout << "Problem P2M : " << octreeIterator.getCurrentCell()->getDataUp() <<
" (should be " << octreeIterator.getCurrentListSrc()->getSize() << ")\n";
}
NbPart += octreeIterator.getCurrentListSrc()->getSize();
} while(octreeIterator.moveRight());
......@@ -194,7 +195,7 @@ void ValidateFMMAlgo(OctreeClass* const tree){
// there is a problem
if( (!isUsingTsm && iter.data().getDataDown() != NbPart - 1) ||
(isUsingTsm && iter.data().getDataDown() != NbPart) ){
std::cout << "Problem L2P + P2P : " << iter.data().getDataDown() << "\n";
std::cout << "Problem L2P + P2P : " << iter.data().getDataDown() << "(" << octreeIterator.getCurrentGlobalIndex() << ")\n";
}
iter.gotoNext();
}
......
......@@ -43,8 +43,8 @@ struct StarHandle : public FNoCopyable, public FNoAssignement {
/** Release the handle */
~StarHandle(){
if( handle != ((void *)0) ){
//starpu_data_unregister(handle);
if( handle != starpu_data_handle_t(0) ){
starpu_data_unregister(handle);
}
}
......@@ -69,7 +69,7 @@ struct StarHandle : public FNoCopyable, public FNoAssignement {
/** Release data */
void unregisterData(){
if( handle != ((void *)0) ){
//starpu_data_unregister(handle);
starpu_data_unregister(handle);
memset(&handle, 0, sizeof(starpu_data_handle_t));
}
}
......@@ -259,6 +259,7 @@ class FFmmAlgorithmStarpu : protected FAssertable{
KernelClass* const kernels; //< The kernels
const int OctreeHeight;
const bool putNameInTask;
//////////////////////////////////////////////////////////////////
// Codelets
......@@ -280,7 +281,7 @@ class FFmmAlgorithmStarpu : protected FAssertable{
starpu_perfmodel l2p_model;
// Init the codelet
void initCodelets(const bool putNameInTask){
void initCodelets(){
memset(&p2p_model, 0, sizeof(p2p_model));
p2p_model.type = STARPU_HISTORY_BASED;
p2p_model.symbol = "P2P";
......@@ -341,6 +342,8 @@ class FFmmAlgorithmStarpu : protected FAssertable{
l2p_cl.where = STARPU_CPU;
l2p_cl.cpu_funcs[0] = l2p_cpu;
l2p_cl.nbuffers = 2;
l2p_cl.modes[0] = STARPU_R;
l2p_cl.modes[1] = STARPU_RW;
if(putNameInTask) l2p_cl.model = &l2p_model;
// M2M & L2L
......@@ -400,6 +403,29 @@ class FFmmAlgorithmStarpu : protected FAssertable{
}
void releaseHandles(){
typename OctreeClass::Iterator octreeIterator(tree);
octreeIterator.gotoBottomLeft();
typename OctreeClass::Iterator avoidGotoLeftIterator(octreeIterator);
// init leaf handle
do{
octreeIterator.getCurrentLeaf()->getSrc()->handle.unregisterData();
if(octreeIterator.getCurrentLeaf()->getSrc() != octreeIterator.getCurrentLeaf()->getTargets()){
octreeIterator.getCurrentLeaf()->getTargets()->handle.unregisterData();
}
} while(octreeIterator.moveRight());
octreeIterator = avoidGotoLeftIterator;
// init cells handle
for(int idxLevel = OctreeHeight - 1 ; idxLevel > 1 ; --idxLevel ){
do{
octreeIterator.getCurrentCell()->handleUp.unregisterData();
octreeIterator.getCurrentCell()->handleDown.unregisterData();
} while(octreeIterator.moveRight());
avoidGotoLeftIterator.moveUp();
octreeIterator = avoidGotoLeftIterator;
}
}
//////////////////////////////////////////////////////////////////
......@@ -433,20 +459,33 @@ public:
* @param inKernels the kernels to call
* An assert is launched if one of the arguments is null
*/
FFmmAlgorithmStarpu(OctreeClass* const inTree, KernelClass* const inKernels, const bool putNameInTask = false)
: tree(inTree) , kernels(inKernels), OctreeHeight(tree->getHeight()) {
FFmmAlgorithmStarpu(OctreeClass* const inTree, KernelClass* const inKernels, const bool inPutNameInTask = false)
: tree(inTree) , kernels(inKernels), OctreeHeight(tree->getHeight()), putNameInTask(inPutNameInTask) {
FDEBUG(FDebug::Controller << "FFmmAlgorithmStarpu\n");
}
/** Default destructor */
virtual ~FFmmAlgorithmStarpu(){
}
/** Run starpu */
void initStarpu(const int nbThreads = -1){
starpu_conf setup;
starpu_conf_init(&setup);
setup.ncpus = nbThreads;
// Run starpu
starpu_init(NULL);
starpu_init(&setup);
FDEBUG(FDebug::Controller << "Init starpu, there are " << starpu_worker_get_count() << " workers\n");
// Init
initCodelets(putNameInTask);
initCodelets();
initHandles();
initKernels();
}
/** Default destructor */
virtual ~FFmmAlgorithmStarpu(){
/** Release starpu */
void releaseStarpu(){
// Release stuff
releaseCodelets();
releaseHandles();
......
This diff is collapsed.
......@@ -87,20 +87,31 @@ int main(int argc, char ** argv){
// -----------------------------------------------------
std::cout << "Working on particles ..." << std::endl;
std::cout << "Create kernel ..." << std::endl;
counter.tic();
KernelClass kernels(DevP, NbLevels,loader.getBoxWidth(), loader.getCenterOfBox());
KernelClass kernels(DevP, NbLevels, loader.getBoxWidth(), loader.getCenterOfBox());
counter.tac();
std::cout << "Done " << " in " << counter.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
std::cout << "Working on particles ..." << std::endl;
if( FParameters::findParameter(argc,argv,"-sequential") != FParameters::NotFound){
FmmClass algo(&tree,&kernels);
counter.tic();
algo.execute();
}
else if( FParameters::findParameter(argc,argv,"-task") != FParameters::NotFound){
FmmClassTask algo(&tree,&kernels);
counter.tic();
algo.execute();
}
else {
FmmClassThread algo(&tree,&kernels);
counter.tic();
algo.execute();
}
......
......@@ -92,21 +92,31 @@ int main(int argc, char ** argv){
// -----------------------------------------------------
std::cout << "Working on particles ..." << std::endl;
std::cout << "Create kernel ..." << std::endl;
counter.tic();
KernelClass kernels(DevP, NbLevels, loader.getBoxWidth(), loader.getCenterOfBox());
counter.tac();
std::cout << "Done " << " in " << counter.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
std::cout << "Working on particles ..." << std::endl;
if( FParameters::findParameter(argc,argv,"-sequential") != FParameters::NotFound){
FmmClass algo(&tree,&kernels);
counter.tic();
algo.execute();
}
else if( FParameters::findParameter(argc,argv,"-task") != FParameters::NotFound){
FmmClassTask algo(&tree,&kernels);
counter.tic();
algo.execute();
}
else {
FmmClassThread algo(&tree,&kernels);
counter.tic();
algo.execute();
}
......
......@@ -93,21 +93,31 @@ int main(int argc, char ** argv){
// -----------------------------------------------------
std::cout << "Working on particles ..." << std::endl;
std::cout << "Create kernel ..." << std::endl;
counter.tic();
KernelClass kernels(DevP, NbLevels, loader.getBoxWidth(), loader.getCenterOfBox());
counter.tac();
std::cout << "Done " << " in " << counter.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
std::cout << "Working on particles ..." << std::endl;
if( FParameters::findParameter(argc,argv,"-sequential") != FParameters::NotFound){
FmmClass algo(&tree,&kernels);
counter.tic();
algo.execute();
}
else if( FParameters::findParameter(argc,argv,"-task") != FParameters::NotFound){
FmmClassTask algo(&tree,&kernels);
counter.tic();
algo.execute();
}
else {
FmmClassThread algo(&tree,&kernels);
counter.tic();
algo.execute();
}
......
......@@ -130,14 +130,24 @@ int main(int argc, char ** argv){
// -----------------------------------------------------
std::cout << "Working on particles ..." << std::endl;
std::cout << "Create kernel ..." << std::endl;
counter.tic();
KernelClass kernels(DevP, NbLevels,loader.getBoxWidth(),loader.getCenterOfBox(), BoundaryDeep);
counter.tac();
std::cout << "Done " << " in " << counter.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
std::cout << "Working on particles ..." << std::endl;
FmmClass algo(&tree,&kernels,BoundaryDeep);
algo.execute();
counter.tic();
algo.execute();
counter.tac();
std::cout << "Done " << "(@Algorithm = " << counter.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
......
......@@ -254,16 +254,23 @@ int main(int argc, char ** argv){
counter.tac();
std::cout << "Done " << "(@Creating and Inserting Particles = " << counter.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
std::cout << "Create kernel..." << std::endl;
KernelClass kernels(DevP, NbLevels,loader.getBoxWidth(), loader.getCenterOfBox());
std::cout << "Done " << " in " << counter.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
std::cout << "Working on particles ..." << std::endl;
counter.tic();
KernelClass kernels(DevP, NbLevels,loader.getBoxWidth(), loader.getCenterOfBox());
FmmClass algo(app.global(),&tree,&kernels);
algo.execute();
counter.tic();
algo.execute();
counter.tac();
std::cout << "Done " << "(@Algorithm = " << counter.elapsed() << "s)." << std::endl;
{ // get sum forces&potential
......@@ -311,8 +318,8 @@ int main(int argc, char ** argv){
}
std::cout << "Working on particles ..." << std::endl;
counter.tic();
FmmClassNoProc algoValide(&treeValide,&kernels);
counter.tic();
algoValide.execute();
counter.tac();
std::cout << "Done " << "(@Algorithm = " << counter.elapsed() << "s)." << std::endl;
......
......@@ -87,21 +87,31 @@ int main(int argc, char ** argv){
// -----------------------------------------------------
std::cout << "Working on particles ..." << std::endl;
std::cout << "Create kernel ..." << std::endl;
counter.tic();
KernelClass kernels(DevP, NbLevels, loader.getBoxWidth(), loader.getCenterOfBox());
counter.tac();
std::cout << "Done " << " in " << counter.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
std::cout << "Working on particles ..." << std::endl;
if( FParameters::findParameter(argc,argv,"-sequential") != FParameters::NotFound){
FmmClass algo(&tree,&kernels);
counter.tic();
algo.execute();
}
else if( FParameters::findParameter(argc,argv,"-task") != FParameters::NotFound){
FmmClassTask algo(&tree,&kernels);
counter.tic();
algo.execute();
}
else {
FmmClassThread algo(&tree,&kernels);
counter.tic();
algo.execute();
}
......
......@@ -82,15 +82,24 @@ int main(int argc, char ** argv){
// -----------------------------------------------------
std::cout << "Working on particles ..." << std::endl;
std::cout << "Create kernel ..." << std::endl;
counter.tic();
KernelClass kernels(DevP, NbLevels, loader.getBoxWidth(), loader.getCenterOfBox());
counter.tac();
std::cout << "Done " << " in " << counter.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
std::cout << "Working on particles ..." << std::endl;
FmmClass algo(&tree,&kernels);
algo.execute();
counter.tic();
algo.execute();
counter.tac();
std::cout << "Done " << "(@Algorithm = " << counter.elapsed() << "s)." << std::endl;
{ // get sum forces&potential
......
......@@ -116,16 +116,18 @@ int main(int argc, char ** argv){
std::cout << "Done " << "(@Creating and Inserting Particles = " << counter.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
std::cout << "Working on particles ..." << std::endl;
counter.tic();
std::cout << "Create kernels ..." << std::endl;
KernelClass kernels(DevP, NbLevels, BoxWidth, CenterOfBox);
KernelClassTyped kernelsTyped(DevP, NbLevels, BoxWidth, CenterOfBox);
std::cout << "Working on particles ..." << std::endl;
FmmClass algo(&tree,&kernels);
FmmClassTyped algoTyped(&treeTyped,&kernelsTyped);
counter.tic();
algo.execute();
algoTyped.execute();
......
......@@ -110,12 +110,15 @@ int main(int argc, char ** argv){
KernelClass kernel;
AlgorithmClass algo( &tree, &kernel);
std::cout << "There are " << starpu_worker_get_count() << " workers" << std::endl;
algo.execute();
algo.initStarpu();
counter.tic();
algo.execute();
counter.tac();
std::cout << "Done " << "(@Algorithm = " << counter.elapsed() << "s)." << std::endl;
algo.releaseStarpu();
// Check result
ValidateFMMAlgo<OctreeClass, ParticleClass, CellClass, ContainerClass, LeafClass>(&tree);
......
// ===================================================================================
// Logiciel initial: ScalFmm Version 0.5
// Co-auteurs : Olivier Coulaud, Bérenger Bramas.
// Propriétaires : INRIA.
// Copyright © 2011-2012, diffusé sous les termes et conditions d’une licence propriétaire.
// Initial software: ScalFmm Version 0.5
// Co-authors: Olivier Coulaud, Bérenger Bramas.
// Owners: INRIA.
// Copyright © 2011-2012, spread under the terms and conditions of a proprietary license.
// ===================================================================================
// ==== CMAKE =====
// @FUSE_STARPU
// ================
#include <starpu.h>
#include "../../Src/Utils/FTic.hpp"
#include "../../Src/Utils/FParameters.hpp"
#include "../../Src/Containers/FOctree.hpp"
#include "../../Src/Containers/FVector.hpp"
#include "../../Src/Components/FTestKernels.hpp"
#include "../../Src/Components/FTestParticle.hpp"
#include "../../Src/Components/FTestCell.hpp"
#include "../../Src/Core/FFmmAlgorithmStarpuGroup.hpp"
#include "../../Src/Core/FFmmAlgorithm.hpp"
#include "../../Src/Components/FSimpleLeaf.hpp"
#include "../../Src/Components/FFmaParticle.hpp"
#include "../../Src/Extensions/FExtendForces.hpp"
#include "../../Src/Extensions/FExtendPotential.hpp"
#include "../../Src/Components/FBasicCell.hpp"
#include "../../Src/Files/FFmaLoader.hpp"
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
////////////////////////////////////////////////////////////////
// Define classes
////////////////////////////////////////////////////////////////
class TestCell : public FTestCell {
public:
void intialCopy(const TestCell*const other){
setDataUp( other->getDataUp() );
setDataDown( other->getDataDown() );
}
void copyUp(const TestCell*const other){
setDataUp( other->getDataUp() );
}
void restoreCopy(const TestCell*const other){
setDataUp( other->getDataUp() );
setDataDown( other->getDataDown() );
}
};
// just to be able to load a fma file
class TestParticle : public FTestParticle, public FExtendPhysicalValue{
};
template <class ParticleClass>
class Container : public FVector<ParticleClass> {
public:
void reduce(const Container*const other){
for( int idx = 0 ; idx < FVector<ParticleClass>::getSize() ; ++idx){
FVector<ParticleClass>::data()[idx].setDataDown(FVector<ParticleClass>::data()[idx].getDataDown() +
other->FVector<ParticleClass>::data()[idx].getDataDown());
}
}
};
////////////////////////////////////////////////////////////////
// Typedefs
////////////////////////////////////////////////////////////////
typedef TestParticle ParticleClass;
typedef Container<ParticleClass> ContainerClass;
typedef TestCell CellClass;
typedef FSimpleLeaf<ParticleClass, ContainerClass > LeafClass;
typedef FOctree<ParticleClass, CellClass, ContainerClass , LeafClass > OctreeClass;
typedef FTestKernels<ParticleClass, CellClass, ContainerClass > KernelClass;
typedef FFmmAlgorithmStarpuGroup<OctreeClass, ParticleClass, CellClass, ContainerClass,KernelClass,LeafClass> AlgorithmClass;
typedef FFmmAlgorithm<OctreeClass, ParticleClass, CellClass, ContainerClass,KernelClass,LeafClass> TestAlgorithmClass;
////////////////////////////////////////////////////////////////
// Main
////////////////////////////////////////////////////////////////
// Simply create particles and try the kernels
int main(int argc, char ** argv){
///////////////////////What we do/////////////////////////////
std::cout << ">> This executable has to be used to test fmb algorithm.\n";
//////////////////////////////////////////////////////////////
const int NbLevels = FParameters::getValue(argc,argv,"-h", 5);
const int SizeSubLevels = FParameters::getValue(argc,argv,"-sh", 3);
const int BlockSize = FParameters::getValue(argc,argv,"-bs", 250);
FTic counter;
const char* const filename = FParameters::getStr(argc,argv,"-f", "../Data/test20k.fma");
std::cout << "Opening : " << filename << "\n";
FFmaLoader<ParticleClass> loader(filename);
if(!loader.isOpen()){
std::cout << "Loader Error, " << filename << " is missing\n";
return 1;
}
// -----------------------------------------------------
OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox());
// -----------------------------------------------------
std::cout << "Creating & Inserting " << loader.getNumberOfParticles() << " particles ..." << std::endl;
std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl;
counter.tic();
loader.fillTree(tree);
counter.tac();
std::cout << "Done " << "(@Creating and Inserting Particles = " << counter.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
KernelClass kernel;
TestAlgorithmClass testalgo( &tree, &kernel);
AlgorithmClass algo( &tree, &kernel, BlockSize);
// -----------------------------------------------------
std::cout << "Build gouped tree..." << std::endl;
counter.tic();
algo.buildGroups();
counter.tac();
std::cout << "Done in " << counter.elapsed() << "s." << std::endl;
// -----------------------------------------------------
std::cout << "Execute Fmm..." << std::endl;
counter.tic();
algo.execute();
//testalgo.execute();
counter.tac();
std::cout << "Done " << "(@Algorithm = " << counter.elapsed() << "s)." << std::endl;
// -----------------------------------------------------
std::cout << "Release gouped tree..." << std::endl;
counter.tic();
algo.releaseGroups();
counter.tac();
std::cout << "Done in " << counter.elapsed() << "s." << std::endl;
// -----------------------------------------------------
// Check result
ValidateFMMAlgo<OctreeClass, ParticleClass, CellClass, ContainerClass, LeafClass>(&tree);
return 0;
}
......@@ -129,8 +129,14 @@ int main(int argc, char* argv[])
time.tic();
KernelClass kernels(TreeHeight, loader.getCenterOfBox(), loader.getBoxWidth(), epsilon);
FmmClass algorithm(&tree,&kernels);
algorithm.initStarpu();
std::cout << "init fmm & kernel " << time.tacAndElapsed() << "sec." << std::endl;
time.tic();
algorithm.execute();
std::cout << "completed in " << time.tacAndElapsed() << "sec." << std::endl;
algorithm.releaseStarpu();
// -----------------------------------------------------
......
This diff is collapsed.
This diff is collapsed.
......@@ -98,12 +98,15 @@ int main(int argc, char ** argv){
KernelClass kernel(DevP, NbLevels,loader.getBoxWidth(), loader.getCenterOfBox());
AlgorithmClass algo( &tree, &kernel);
std::cout << "There are " << starpu_worker_get_count() << " workers" << std::endl;
algo.execute();
algo.initStarpu();
counter.tic();
algo.execute();
counter.tac();
std::cout << "Done " << "(@Algorithm = " << counter.elapsed() << "s)." << std::endl;
algo.releaseStarpu();
// -----------------------------------------------------
{ // get sum forces&potential
......
......@@ -86,16 +86,20 @@ int main(int argc, char ** argv){
loader.fillTree(tree);
// -----------------------------------------------------
counter.tic();
KernelClass kernels(DevP, NbLevels, loader.getBoxWidth(), loader.getCenterOfBox(), idxBlockSize);