Commit 73eb143c authored by BRAMAS Berenger's avatar BRAMAS Berenger
Browse files

Add a not found parameter value, and now -task or -sequential can be used with...

Add a not found parameter value, and now -task or -sequential can be used with testSphericalAlgorithm
parent 8f400d90
......@@ -20,6 +20,8 @@
*/
namespace FParameters{
/** If it is not found */
const static int NotFound = -1;
/**
* This function gives a parameter in a standart type
* @parameter inArg parameter position has to be strictly less than argc/userParemetersCount
......@@ -73,7 +75,7 @@ namespace FParameters{
return idxArg;
}
}
return -1;
return NotFound;
}
/** To get a value like :
......@@ -84,7 +86,7 @@ namespace FParameters{
template <class VariableType>
const VariableType getValue(const int argc, const char* const * const argv, const char* const inName, const VariableType& defaultValue = VariableType(), const bool caseSensible = false){
const int position = findParameter(argc,argv,inName,caseSensible);
if(position == -1 || position == argc - 1){
if(position == NotFound || position == argc - 1){
return defaultValue;
}
return StrToOther(argv[position+1],defaultValue);
......@@ -94,7 +96,7 @@ namespace FParameters{
*/
const char* getStr(const int argc, const char* const * const argv, const char* const inName, const char* const inDefault, const bool caseSensible = false){
const int position = findParameter(argc,argv,inName,caseSensible);
if(position == -1 || position == argc - 1){
if(position == NotFound || position == argc - 1){
return inDefault;
}
return argv[position+1];
......
......@@ -74,7 +74,7 @@ int main(int argc, char ** argv){
FReal data[4];
data[3] = FReal(0.1);
if( !FParameters::findParameter(argc,argv,"-double") ){
if( FParameters::findParameter(argc,argv,"-double") == FParameters::NotFound ){
const FReal rayon = FReal(0.4);
const FReal thresh = FReal(0.15);
const FReal threshDiv2 = thresh/2;
......
......@@ -64,7 +64,7 @@ int main(int argc, char ** argv){
// System properties
myfile << NbParticles << " " << BoxWidth << " " << XCenter << " " << YCenter << " " << ZCenter;
if( !FParameters::findParameter(argc,argv,"-double") ){
if( FParameters::findParameter(argc,argv,"-double") == FParameters::NotFound){
const FReal rayon = FReal(0.4);
const FReal thresh = FReal(0.15);
const FReal threshDiv2 = thresh/2;
......
......@@ -48,10 +48,13 @@ int main(int argc, char ** argv){
typedef FSimpleLeaf<ParticleClass, ContainerClass > LeafClass;
typedef FOctree<ParticleClass, CellClass, ContainerClass , LeafClass > OctreeClass;
typedef FSphericalKernel<ParticleClass, CellClass, ContainerClass > KernelClass;
// FFmmAlgorithmTask FFmmAlgorithm FFmmAlgorithmThread
typedef FFmmAlgorithmTask<OctreeClass, ParticleClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass;
typedef FFmmAlgorithm<OctreeClass, ParticleClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass;
typedef FFmmAlgorithmThread<OctreeClass, ParticleClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClassThread;
typedef FFmmAlgorithmTask<OctreeClass, ParticleClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClassTask;
///////////////////////What we do/////////////////////////////
std::cout << ">> This executable has to be used to test Spherical algorithm.\n";
std::cout << ">> You can pass -sequential or -task (thread by default).\n";
//////////////////////////////////////////////////////////////
const int DevP = FParameters::getValue(argc,argv,"-p", 8);
const int NbLevels = FParameters::getValue(argc,argv,"-h", 5);
......@@ -88,8 +91,18 @@ int main(int argc, char ** argv){
counter.tic();
KernelClass kernels(DevP, NbLevels,loader.getBoxWidth(), loader.getCenterOfBox());
FmmClass algo(&tree,&kernels);
algo.execute();
if( FParameters::findParameter(argc,argv,"-sequential") != FParameters::NotFound){
FmmClass algo(&tree,&kernels);
algo.execute();
}
else if( FParameters::findParameter(argc,argv,"-task") != FParameters::NotFound){
FmmClassTask algo(&tree,&kernels);
algo.execute();
}
else {
FmmClassThread algo(&tree,&kernels);
algo.execute();
}
counter.tac();
std::cout << "Done " << "(@Algorithm = " << counter.elapsed() << "s)." << std::endl;
......
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