Commit 02af1768 authored by BRAMAS Berenger's avatar BRAMAS Berenger

add a env variable SCALFMM_ALGO_NUM_THREADS to set the number of openmp threads in the algo

parent abc94b1b
......@@ -37,6 +37,7 @@
#include "../Src/BalanceTree/FCoordColour.hpp"
#include "../Src/BalanceTree/FCostZones.hpp"
#include "../Utils/FEnv.hpp"
#include <vector>
......@@ -122,7 +123,7 @@ public:
const std::vector<std::vector<ZoneBoundClass>>& leafCostzones) :
tree(inTree) ,
kernels(nullptr),
MaxThreads(omp_get_max_threads()),
MaxThreads(FEnv::GetValue("SCALFMM_ALGO_NUM_THREADS",omp_get_max_threads())),
OctreeHeight(tree->getHeight()),
costzones(internalCostzones),
leafcostzones(leafCostzones) {
......@@ -136,11 +137,11 @@ public:
// Allocation of one kernel per thread (in case of impossible concurent use)
this->kernels = new KernelClass*[MaxThreads];
// Allocation is done so that kernels are closest to their core.
#pragma omp parallel for schedule(static)
for(int idxThread = 0 ; idxThread < MaxThreads ; ++idxThread) {
#pragma omp parallel num_threads(MaxThreads)
{
#pragma omp critical (InitFFmmAlgorithmThreadBalanced)
{
this->kernels[idxThread] = new KernelClass(*inKernel);
this->kernels[omp_get_thread_num()] = new KernelClass(*inKernel);
}
}
......@@ -208,7 +209,7 @@ protected:
FLOG( std::cerr << "\tStart Bottom Pass" << std::endl );
FLOG( FTic timer );
#pragma omp parallel
#pragma omp parallel num_threads(MaxThreads)
{
// Thread index ( = zone index )
const int threadIdx = omp_get_thread_num();
......@@ -255,7 +256,7 @@ protected:
FLOG( FTic levelTimer );
FLOG( std::cerr << "\t\t>> Level " << level << std::flush);
#pragma omp parallel
#pragma omp parallel num_threads(MaxThreads)
{
// Thread index ( = zone index)
const int threadNum = omp_get_thread_num();
......@@ -308,7 +309,7 @@ protected:
FLOG( std::cerr << "\t\t>> Level " << level << std::flush );
FLOG( FTic levelTimer );
#pragma omp parallel
#pragma omp parallel num_threads(MaxThreads)
{
// Thread index ( = zone index)
......@@ -374,7 +375,7 @@ protected:
FLOG( std::cerr << "\t\t>> Level " << level << std::flush);
FLOG( FTic levelTimer );
#pragma omp parallel
#pragma omp parallel num_threads(MaxThreads)
{
// Thread index ( = zone index)
const int threadNum = omp_get_thread_num();
......@@ -430,7 +431,7 @@ protected:
ContainerClass* sources; ///< Sources for P2P kernel
};
#pragma omp parallel
#pragma omp parallel num_threads(MaxThreads)
{
// Thread index ( = zone index)
const int threadNum = omp_get_thread_num();
......
......@@ -12,6 +12,7 @@
#include "../Containers/FOctree.hpp"
#include "../Containers/FVector.hpp"
#include "../Utils/FAlgorithmTimers.hpp"
#include "../Utils/FEnv.hpp"
#include "FCoreCommon.hpp"
#include "FP2PExclusion.hpp"
......@@ -115,7 +116,7 @@ public:
*/
FFmmAlgorithmOmp4(OctreeClass* const inTree, KernelClass* const inKernels, const int inLeafLevelSeperationCriteria = 1)
: tree(inTree) , kernels(nullptr),
MaxThreads(omp_get_max_threads()), OctreeHeight(tree->getHeight()), leafLevelSeparationCriteria(inLeafLevelSeperationCriteria),
MaxThreads(FEnv::GetValue("SCALFMM_ALGO_NUM_THREADS",omp_get_max_threads())), OctreeHeight(tree->getHeight()), leafLevelSeparationCriteria(inLeafLevelSeperationCriteria),
p2pPrioCriteria(0)
{
......
......@@ -22,6 +22,7 @@
#include "../Utils/FLog.hpp"
#include "../Utils/FTic.hpp"
#include "../Utils/FEnv.hpp"
#include "../Containers/FOctree.hpp"
#include "../Containers/FVector.hpp"
......@@ -69,7 +70,7 @@ public:
const int inLeafLevelSeparationCriteria = 1) :
tree(inTree) ,
kernels(0),
MaxThreads(omp_get_max_threads()),
MaxThreads(FEnv::GetValue("SCALFMM_ALGO_NUM_THREADS",omp_get_max_threads())),
OctreeHeight(tree->getHeight()),
leafLevelSeparationCriteria(inLeafLevelSeparationCriteria) {
......
......@@ -20,6 +20,7 @@
#include "../Utils/FGlobal.hpp"
#include "../Utils/FAssert.hpp"
#include "../Utils/FLog.hpp"
#include "../Utils/FEnv.hpp"
#include "../Utils/FTic.hpp"
......@@ -59,7 +60,7 @@ public:
*/
FFmmAlgorithmTask(OctreeClass* const inTree, KernelClass* const inKernels, const int inLeafLevelSeperationCriteria = 1)
: tree(inTree) , kernels(nullptr),
MaxThreads(omp_get_max_threads()), OctreeHeight(tree->getHeight()), leafLevelSeparationCriteria(inLeafLevelSeperationCriteria)
MaxThreads(FEnv::GetValue("SCALFMM_ALGO_NUM_THREADS",omp_get_max_threads())), OctreeHeight(tree->getHeight()), leafLevelSeparationCriteria(inLeafLevelSeperationCriteria)
{
FAssertLF(tree, "tree cannot be null");
......
......@@ -23,6 +23,7 @@
#include "../Utils/FTic.hpp"
#include "../Utils/FGlobal.hpp"
#include "Utils/FAlgorithmTimers.hpp"
#include "../Utils/FEnv.hpp"
#include "../Containers/FOctree.hpp"
......@@ -79,7 +80,7 @@ public:
FFmmAlgorithmThread(OctreeClass* const inTree, KernelClass* const inKernels,
const int inUserChunkSize = 10, const int inLeafLevelSeperationCriteria = 1)
: tree(inTree) , kernels(nullptr), iterArray(nullptr), leafsNumber(0),
MaxThreads(omp_get_max_threads()), OctreeHeight(tree->getHeight()),
MaxThreads(FEnv::GetValue("SCALFMM_ALGO_NUM_THREADS",omp_get_max_threads())), OctreeHeight(tree->getHeight()),
userChunkSize(inUserChunkSize), leafLevelSeparationCriteria(inLeafLevelSeperationCriteria) {
FAssertLF(tree, "tree cannot be null");
FAssertLF(leafLevelSeparationCriteria < 3, "Separation criteria should be < 3");
......
......@@ -9,6 +9,7 @@
#include "Utils/FAlgorithmTimers.hpp"
#include "../Containers/FOctree.hpp"
#include "../Utils/FEnv.hpp"
#include "FCoreCommon.hpp"
#include "FP2PExclusion.hpp"
......@@ -57,7 +58,7 @@ public:
FFmmAlgorithmThreadBalance(OctreeClass* const inTree, KernelClass* const inKernels,
const int inLeafLevelSeperationCriteria = 1)
: tree(inTree) , kernels(nullptr),
MaxThreads(omp_get_max_threads()), OctreeHeight(tree->getHeight()),
MaxThreads(FEnv::GetValue("SCALFMM_ALGO_NUM_THREADS",omp_get_max_threads())), OctreeHeight(tree->getHeight()),
leafLevelSeparationCriteria(inLeafLevelSeperationCriteria) {
FAssertLF(tree, "tree cannot be null");
FAssertLF(leafLevelSeparationCriteria < 3, "Separation criteria should be < 3");
......
......@@ -30,6 +30,7 @@
#include "../Containers/FBoolArray.hpp"
#include "../Containers/FOctree.hpp"
#include "../Containers/FLightOctree.hpp"
#include "../Utils/FEnv.hpp"
#include "../Containers/FBufferWriter.hpp"
#include "../Containers/FBufferReader.hpp"
......@@ -150,7 +151,7 @@ public:
iterArray(nullptr),
iterArrayComm(nullptr),
numberOfLeafs(0),
MaxThreads(omp_get_max_threads()),
MaxThreads(FEnv::GetValue("SCALFMM_ALGO_NUM_THREADS",omp_get_max_threads())),
nbProcess(inComm.processCount()),
idProcess(inComm.processId()),
OctreeHeight(tree->getHeight()),
......
......@@ -23,6 +23,7 @@
#include "../Utils/FTic.hpp"
#include "../Utils/FGlobal.hpp"
#include "../Utils/FMemUtils.hpp"
#include "../Utils/FEnv.hpp"
#include "../Containers/FBoolArray.hpp"
#include "../Containers/FOctree.hpp"
......@@ -32,6 +33,7 @@
#include "../Containers/FBufferReader.hpp"
#include "../Containers/FMpiBufferWriter.hpp"
#include "../Containers/FMpiBufferReader.hpp"
#include "../Utils/FEnv.hpp"
#include "../Utils/FMpi.hpp"
......@@ -145,7 +147,7 @@ public:
const int inUpperLevel = 2, const int inLeafLevelSeperationCriteria = 1)
: tree(inTree) , kernels(nullptr), comm(inComm), nbLevelsAboveRoot(inUpperLevel), offsetRealTree(inUpperLevel + 2),
numberOfLeafs(0),
MaxThreads(omp_get_max_threads()), nbProcess(inComm.processCount()), idProcess(inComm.processId()),
MaxThreads(FEnv::GetValue("SCALFMM_ALGO_NUM_THREADS",omp_get_max_threads())), nbProcess(inComm.processCount()), idProcess(inComm.processId()),
OctreeHeight(tree->getHeight()),
leafLevelSeparationCriteria(inLeafLevelSeperationCriteria),
intervals(new Interval[inComm.processCount()]),
......
......@@ -25,6 +25,7 @@
#include "../Utils/FAlgorithmTimers.hpp"
#include "../Containers/FOctree.hpp"
#include "FCoreCommon.hpp"
#include "../Utils/FEnv.hpp"
#include <omp.h>
......@@ -65,7 +66,7 @@ public:
*/
FFmmAlgorithmThreadTsm(OctreeClass* const inTree, KernelClass* const inKernels, const int inLeafLevelSeperationCriteria = 1)
: tree(inTree) , kernels(nullptr), iterArray(nullptr),
MaxThreads(omp_get_max_threads()) , OctreeHeight(tree->getHeight()), leafLevelSeparationCriteria(inLeafLevelSeperationCriteria) {
MaxThreads(FEnv::GetValue("SCALFMM_ALGO_NUM_THREADS",omp_get_max_threads())) , OctreeHeight(tree->getHeight()), leafLevelSeparationCriteria(inLeafLevelSeperationCriteria) {
FAssertLF(tree, "tree cannot be null");
FAssertLF(leafLevelSeparationCriteria < 3, "Separation criteria should be < 3");
......
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