Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

Commit b6b4b5e3 authored by Quentin Khan's avatar Quentin Khan
Browse files

Added the possibility to set chunk size in FFmmAlgorithmThread

parent 065e8bef
......@@ -64,15 +64,7 @@ class FFmmAlgorithmThread : public FAbstractAlgorithm, public FAlgorithmTimers{
const int leafLevelSeperationCriteria;
template <class NumType>
NumType getChunkSize(const NumType inSize) const {
if(staticSchedule){
return FMath::Max(NumType(1) , NumType(double(inSize)/double(omp_get_max_threads())) );
}
else{
return FMath::Max(NumType(1) , inSize/NumType(omp_get_max_threads()*omp_get_max_threads()));
}
}
unsigned int ompChunkSize = 0;
public:
/** Class constructor
......@@ -89,24 +81,24 @@ public:
: tree(inTree) , kernels(nullptr), iterArray(nullptr), leafsNumber(0),
MaxThreads(omp_get_max_threads()), OctreeHeight(tree->getHeight()),
staticSchedule(inStaticSchedule), leafLevelSeperationCriteria(inLeafLevelSeperationCriteria) {
FAssertLF(tree, "tree cannot be null");
this->kernels = new KernelClass*[MaxThreads];
#pragma omp parallel for schedule(static)
for(int idxThread = 0 ; idxThread < MaxThreads ; ++idxThread){
#pragma omp critical (InitFFmmAlgorithmThread)
#pragma omp critical (InitFFmmAlgorithmThread)
{
this->kernels[idxThread] = new KernelClass(*inKernels);
}
}
FAbstractAlgorithm::setNbLevelsInTree(tree->getHeight());
FLOG(FLog::Controller << "FFmmAlgorithmThread (Max Thread " << omp_get_max_threads() << ")\n");
FLOG(FLog::Controller << "\t static schedule " << (staticSchedule?"TRUE":"FALSE") << ")\n");
}
/** Default destructor */
virtual ~FFmmAlgorithmThread(){
for(int idxThread = 0 ; idxThread < MaxThreads ; ++idxThread){
......@@ -114,7 +106,29 @@ public:
}
delete [] this->kernels;
}
template <class NumType>
NumType getChunkSize(const NumType inSize) const {
if(staticSchedule){
return FMath::Max(NumType(1) , NumType(double(inSize)/double(omp_get_max_threads())) );
}
else{
if (ompChunkSize > 0) {
return ompChunkSize;
}
else {
return FMath::Max(NumType(1) , inSize/NumType(omp_get_max_threads()*omp_get_max_threads()));
}
}
}
template <class NumType>
void setChunkSize(const NumType size) {
ompChunkSize = size;
}
protected:
/**
* Runs the complete algorithm.
......
......@@ -6,6 +6,7 @@
#define _ALGOLOADERTHREAD_HPP_
#include <memory>
#include <sstream>
#include "PerfTestUtils.hpp"
......@@ -31,6 +32,7 @@ public:
KernelLoader& _kernelLoader;
bool _omp_static_schedule;
unsigned int _omp_chunk_size;
std::unique_ptr<FMMClass> _algo;
......@@ -40,6 +42,7 @@ public:
_treeLoader(treeLoader),
_kernelLoader(kernelLoader),
_omp_static_schedule(params.omp_static_schedule),
_omp_chunk_size(params.omp_chunk_size),
_algo(nullptr) {
}
......@@ -48,9 +51,19 @@ public:
_algo = std::unique_ptr<FMMClass>(
new FMMClass(&(_treeLoader._tree), &(_kernelLoader._kernel),
_omp_static_schedule));
_algo->setChunkSize(_omp_chunk_size);
_algo->execute();
}
virtual std::string getRunInfoString() const {
std::stringstream sstr;
sstr << "chunksize:" << _omp_chunk_size << " ";
return sstr.str();
}
};
#endif
......@@ -72,6 +72,12 @@ void runperf(FPerfTestParams& params)
}
namespace ParName {
const FParameterNames Algo = {{"--algo"},"Algorithm to run (costzones, basic, task)"};
const FParameterNames Schedule = {{"--schedule"},"OpenMP scheduling policy (static, dynamic)."};
const FParameterNames ChunkSize = {{"--chunk", "--chunk-size"},"OpenMP chunk size for basic dynamic algorithm."};
}
int main (int argc, char** argv)
{
FHelpDescribeAndExit(argc, argv,
......@@ -80,20 +86,22 @@ int main (int argc, char** argv)
FParameterDefinitions::OctreeHeight,
FParameterDefinitions::OctreeSubHeight,
FParameterDefinitions::NbThreads,
{{"--algo"},"Algorithm to run (costzones, basic, task)"},
{{"--schedule"},"OpenMP scheduling policy (static, dynamic)."});
ParName::Algo,
ParName::Schedule,
ParName::ChunkSize);
FPerfTestParams params;
{
using namespace FParameterDefinitions;
using namespace FParameters;
params.filename = getStr(argc,argv,InputFile.options,
params.filename = getStr(argc,argv,InputFile.options,
"../Data/unitCubeXYZQ100.bfma");
params.treeHeight = getValue(argc, argv, OctreeHeight.options, 5);
params.treeHeight = getValue(argc, argv, OctreeHeight.options, 5);
params.subTreeHeight = getValue(argc, argv, OctreeSubHeight.options, 2);
params.nbThreads = getValue(argc, argv, NbThreads.options, 1);
params.algo = getStr(argc,argv,{"--algo"},"task");
params.nbThreads = getValue(argc, argv, NbThreads.options, 1);
params.algo = getStr(argc,argv,ParName::Algo.options,"task");
params.omp_static_schedule =
getStr(argc,argv,{"--schedule"},"dynamic") == std::string("static");
getStr(argc,argv,ParName::Schedule.options,"dynamic") == std::string("static");
params.omp_chunk_size = getValue(argc, argv, ParName::ChunkSize.options, 0);
}
omp_set_num_threads(params.nbThreads);
......
......@@ -22,6 +22,7 @@ struct FPerfTestParams {
std::string filename = ""; ///< Particles file.
std::string algo = "task"; ///< Algorithm to run.
bool omp_static_schedule = false; ///< OpenMP static or dynamic schedule.
int omp_chunk_size = 0;
};
......
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