Commit 1f69b258 authored by Matthias Messner's avatar Matthias Messner
parents 57ea27fd d788edc1
...@@ -150,7 +150,8 @@ void ValidateFMMAlgo(OctreeClass* const tree){ ...@@ -150,7 +150,8 @@ void ValidateFMMAlgo(OctreeClass* const tree){
octreeIterator.gotoBottomLeft(); octreeIterator.gotoBottomLeft();
do{ do{
if(octreeIterator.getCurrentCell()->getDataUp() != octreeIterator.getCurrentListSrc()->getSize() ){ 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(); NbPart += octreeIterator.getCurrentListSrc()->getSize();
} while(octreeIterator.moveRight()); } while(octreeIterator.moveRight());
...@@ -194,7 +195,7 @@ void ValidateFMMAlgo(OctreeClass* const tree){ ...@@ -194,7 +195,7 @@ void ValidateFMMAlgo(OctreeClass* const tree){
// there is a problem // there is a problem
if( (!isUsingTsm && iter.data().getDataDown() != NbPart - 1) || if( (!isUsingTsm && iter.data().getDataDown() != NbPart - 1) ||
(isUsingTsm && iter.data().getDataDown() != NbPart) ){ (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(); iter.gotoNext();
} }
......
...@@ -43,8 +43,8 @@ struct StarHandle : public FNoCopyable, public FNoAssignement { ...@@ -43,8 +43,8 @@ struct StarHandle : public FNoCopyable, public FNoAssignement {
/** Release the handle */ /** Release the handle */
~StarHandle(){ ~StarHandle(){
if( handle != ((void *)0) ){ if( handle != starpu_data_handle_t(0) ){
//starpu_data_unregister(handle); starpu_data_unregister(handle);
} }
} }
...@@ -69,7 +69,7 @@ struct StarHandle : public FNoCopyable, public FNoAssignement { ...@@ -69,7 +69,7 @@ struct StarHandle : public FNoCopyable, public FNoAssignement {
/** Release data */ /** Release data */
void unregisterData(){ void unregisterData(){
if( handle != ((void *)0) ){ if( handle != ((void *)0) ){
//starpu_data_unregister(handle); starpu_data_unregister(handle);
memset(&handle, 0, sizeof(starpu_data_handle_t)); memset(&handle, 0, sizeof(starpu_data_handle_t));
} }
} }
...@@ -259,6 +259,7 @@ class FFmmAlgorithmStarpu : protected FAssertable{ ...@@ -259,6 +259,7 @@ class FFmmAlgorithmStarpu : protected FAssertable{
KernelClass* const kernels; //< The kernels KernelClass* const kernels; //< The kernels
const int OctreeHeight; const int OctreeHeight;
const bool putNameInTask;
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
// Codelets // Codelets
...@@ -280,7 +281,7 @@ class FFmmAlgorithmStarpu : protected FAssertable{ ...@@ -280,7 +281,7 @@ class FFmmAlgorithmStarpu : protected FAssertable{
starpu_perfmodel l2p_model; starpu_perfmodel l2p_model;
// Init the codelet // Init the codelet
void initCodelets(const bool putNameInTask){ void initCodelets(){
memset(&p2p_model, 0, sizeof(p2p_model)); memset(&p2p_model, 0, sizeof(p2p_model));
p2p_model.type = STARPU_HISTORY_BASED; p2p_model.type = STARPU_HISTORY_BASED;
p2p_model.symbol = "P2P"; p2p_model.symbol = "P2P";
...@@ -341,6 +342,8 @@ class FFmmAlgorithmStarpu : protected FAssertable{ ...@@ -341,6 +342,8 @@ class FFmmAlgorithmStarpu : protected FAssertable{
l2p_cl.where = STARPU_CPU; l2p_cl.where = STARPU_CPU;
l2p_cl.cpu_funcs[0] = l2p_cpu; l2p_cl.cpu_funcs[0] = l2p_cpu;
l2p_cl.nbuffers = 2; l2p_cl.nbuffers = 2;
l2p_cl.modes[0] = STARPU_R;
l2p_cl.modes[1] = STARPU_RW;
if(putNameInTask) l2p_cl.model = &l2p_model; if(putNameInTask) l2p_cl.model = &l2p_model;
// M2M & L2L // M2M & L2L
...@@ -400,6 +403,29 @@ class FFmmAlgorithmStarpu : protected FAssertable{ ...@@ -400,6 +403,29 @@ class FFmmAlgorithmStarpu : protected FAssertable{
} }
void releaseHandles(){ 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: ...@@ -433,20 +459,33 @@ public:
* @param inKernels the kernels to call * @param inKernels the kernels to call
* An assert is launched if one of the arguments is null * An assert is launched if one of the arguments is null
*/ */
FFmmAlgorithmStarpu(OctreeClass* const inTree, KernelClass* const inKernels, const bool putNameInTask = false) FFmmAlgorithmStarpu(OctreeClass* const inTree, KernelClass* const inKernels, const bool inPutNameInTask = false)
: tree(inTree) , kernels(inKernels), OctreeHeight(tree->getHeight()) { : tree(inTree) , kernels(inKernels), OctreeHeight(tree->getHeight()), putNameInTask(inPutNameInTask) {
FDEBUG(FDebug::Controller << "FFmmAlgorithmStarpu\n"); 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 // Run starpu
starpu_init(NULL); starpu_init(&setup);
FDEBUG(FDebug::Controller << "Init starpu, there are " << starpu_worker_get_count() << " workers\n");
// Init // Init
initCodelets(putNameInTask); initCodelets();
initHandles(); initHandles();
initKernels(); initKernels();
} }
/** Default destructor */ /** Release starpu */
virtual ~FFmmAlgorithmStarpu(){ void releaseStarpu(){
// Release stuff // Release stuff
releaseCodelets(); releaseCodelets();
releaseHandles(); releaseHandles();
......
This diff is collapsed.
...@@ -87,20 +87,31 @@ int main(int argc, char ** argv){ ...@@ -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(); 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){ if( FParameters::findParameter(argc,argv,"-sequential") != FParameters::NotFound){
FmmClass algo(&tree,&kernels); FmmClass algo(&tree,&kernels);
counter.tic();
algo.execute(); algo.execute();
} }
else if( FParameters::findParameter(argc,argv,"-task") != FParameters::NotFound){ else if( FParameters::findParameter(argc,argv,"-task") != FParameters::NotFound){
FmmClassTask algo(&tree,&kernels); FmmClassTask algo(&tree,&kernels);
counter.tic();
algo.execute(); algo.execute();
} }
else { else {
FmmClassThread algo(&tree,&kernels); FmmClassThread algo(&tree,&kernels);
counter.tic();
algo.execute(); algo.execute();
} }
......
...@@ -92,21 +92,31 @@ int main(int argc, char ** argv){ ...@@ -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(); 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){ if( FParameters::findParameter(argc,argv,"-sequential") != FParameters::NotFound){
FmmClass algo(&tree,&kernels); FmmClass algo(&tree,&kernels);
counter.tic();
algo.execute(); algo.execute();
} }
else if( FParameters::findParameter(argc,argv,"-task") != FParameters::NotFound){ else if( FParameters::findParameter(argc,argv,"-task") != FParameters::NotFound){
FmmClassTask algo(&tree,&kernels); FmmClassTask algo(&tree,&kernels);
counter.tic();
algo.execute(); algo.execute();
} }
else { else {
FmmClassThread algo(&tree,&kernels); FmmClassThread algo(&tree,&kernels);
counter.tic();
algo.execute(); algo.execute();
} }
......
...@@ -93,21 +93,31 @@ int main(int argc, char ** argv){ ...@@ -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(); 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){ if( FParameters::findParameter(argc,argv,"-sequential") != FParameters::NotFound){
FmmClass algo(&tree,&kernels); FmmClass algo(&tree,&kernels);
counter.tic();
algo.execute(); algo.execute();
} }
else if( FParameters::findParameter(argc,argv,"-task") != FParameters::NotFound){ else if( FParameters::findParameter(argc,argv,"-task") != FParameters::NotFound){
FmmClassTask algo(&tree,&kernels); FmmClassTask algo(&tree,&kernels);
counter.tic();
algo.execute(); algo.execute();
} }
else { else {
FmmClassThread algo(&tree,&kernels); FmmClassThread algo(&tree,&kernels);
counter.tic();
algo.execute(); algo.execute();
} }
......
...@@ -130,14 +130,24 @@ int main(int argc, char ** argv){ ...@@ -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(); counter.tic();
KernelClass kernels(DevP, NbLevels,loader.getBoxWidth(),loader.getCenterOfBox(), BoundaryDeep); 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); FmmClass algo(&tree,&kernels,BoundaryDeep);
algo.execute();
counter.tic();
algo.execute();
counter.tac(); counter.tac();
std::cout << "Done " << "(@Algorithm = " << counter.elapsed() << "s)." << std::endl; std::cout << "Done " << "(@Algorithm = " << counter.elapsed() << "s)." << std::endl;
// ----------------------------------------------------- // -----------------------------------------------------
......
...@@ -254,16 +254,23 @@ int main(int argc, char ** argv){ ...@@ -254,16 +254,23 @@ int main(int argc, char ** argv){
counter.tac(); counter.tac();
std::cout << "Done " << "(@Creating and Inserting Particles = " << counter.elapsed() << "s)." << std::endl; 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; std::cout << "Working on particles ..." << std::endl;
counter.tic();
KernelClass kernels(DevP, NbLevels,loader.getBoxWidth(), loader.getCenterOfBox());
FmmClass algo(app.global(),&tree,&kernels); FmmClass algo(app.global(),&tree,&kernels);
algo.execute();
counter.tic();
algo.execute();
counter.tac(); counter.tac();
std::cout << "Done " << "(@Algorithm = " << counter.elapsed() << "s)." << std::endl; std::cout << "Done " << "(@Algorithm = " << counter.elapsed() << "s)." << std::endl;
{ // get sum forces&potential { // get sum forces&potential
...@@ -311,8 +318,8 @@ int main(int argc, char ** argv){ ...@@ -311,8 +318,8 @@ int main(int argc, char ** argv){
} }
std::cout << "Working on particles ..." << std::endl; std::cout << "Working on particles ..." << std::endl;
counter.tic();
FmmClassNoProc algoValide(&treeValide,&kernels); FmmClassNoProc algoValide(&treeValide,&kernels);
counter.tic();
algoValide.execute(); algoValide.execute();
counter.tac(); counter.tac();
std::cout << "Done " << "(@Algorithm = " << counter.elapsed() << "s)." << std::endl; std::cout << "Done " << "(@Algorithm = " << counter.elapsed() << "s)." << std::endl;
......
...@@ -87,21 +87,31 @@ int main(int argc, char ** argv){ ...@@ -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(); 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){ if( FParameters::findParameter(argc,argv,"-sequential") != FParameters::NotFound){
FmmClass algo(&tree,&kernels); FmmClass algo(&tree,&kernels);
counter.tic();
algo.execute(); algo.execute();
} }
else if( FParameters::findParameter(argc,argv,"-task") != FParameters::NotFound){ else if( FParameters::findParameter(argc,argv,"-task") != FParameters::NotFound){
FmmClassTask algo(&tree,&kernels); FmmClassTask algo(&tree,&kernels);
counter.tic();
algo.execute(); algo.execute();
} }
else { else {
FmmClassThread algo(&tree,&kernels); FmmClassThread algo(&tree,&kernels);
counter.tic();
algo.execute(); algo.execute();
} }
......
...@@ -82,15 +82,24 @@ int main(int argc, char ** argv){ ...@@ -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(); 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;
FmmClass algo(&tree,&kernels); FmmClass algo(&tree,&kernels);
algo.execute();
counter.tic();
algo.execute();
counter.tac(); counter.tac();
std::cout << "Done " << "(@Algorithm = " << counter.elapsed() << "s)." << std::endl; std::cout << "Done " << "(@Algorithm = " << counter.elapsed() << "s)." << std::endl;
{ // get sum forces&potential { // get sum forces&potential
......
...@@ -116,16 +116,18 @@ int main(int argc, char ** argv){ ...@@ -116,16 +116,18 @@ int main(int argc, char ** argv){
std::cout << "Done " << "(@Creating and Inserting Particles = " << counter.elapsed() << "s)." << std::endl; std::cout << "Done " << "(@Creating and Inserting Particles = " << counter.elapsed() << "s)." << std::endl;
// ----------------------------------------------------- // -----------------------------------------------------
std::cout << "Create kernels ..." << std::endl;
std::cout << "Working on particles ..." << std::endl;
counter.tic();
KernelClass kernels(DevP, NbLevels, BoxWidth, CenterOfBox); KernelClass kernels(DevP, NbLevels, BoxWidth, CenterOfBox);
KernelClassTyped kernelsTyped(DevP, NbLevels, BoxWidth, CenterOfBox); KernelClassTyped kernelsTyped(DevP, NbLevels, BoxWidth, CenterOfBox);
std::cout << "Working on particles ..." << std::endl;
FmmClass algo(&tree,&kernels); FmmClass algo(&tree,&kernels);
FmmClassTyped algoTyped(&treeTyped,&kernelsTyped); FmmClassTyped algoTyped(&treeTyped,&kernelsTyped);
counter.tic();
algo.execute(); algo.execute();
algoTyped.execute(); algoTyped.execute();
......
...@@ -110,12 +110,15 @@ int main(int argc, char ** argv){ ...@@ -110,12 +110,15 @@ int main(int argc, char ** argv){
KernelClass kernel; KernelClass kernel;
AlgorithmClass algo( &tree, &kernel); AlgorithmClass algo( &tree, &kernel);
std::cout << "There are " << starpu_worker_get_count() << " workers" << std::endl; algo.initStarpu();
algo.execute();
counter.tic();
algo.execute();
counter.tac(); counter.tac();
std::cout << "Done " << "(@Algorithm = " << counter.elapsed() << "s)." << std::endl; std::cout << "Done " << "(@Algorithm = " << counter.elapsed() << "s)." << std::endl;
algo.releaseStarpu();
// Check result // Check result
ValidateFMMAlgo<OctreeClass, ParticleClass, CellClass, ContainerClass, LeafClass>(&tree); 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>