Loading src/NoPthreadsNg.h +0 −2 Original line number Diff line number Diff line Loading @@ -100,8 +100,6 @@ public: size_t stackSize() const { return 0; } void setStackSize(size_t) {} // no weights, no balancer ==> create weights, set all weigths to 1, delegate void loopCreate(PthreadFunctionHolderType& pfh) { Loading src/Parallelizer2OpenMP.h +4 −2 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ #define PARALLELIZER2OPENMP_H #include "Vector.h" #include <omp.h> #include "CodeSectionParams.h" namespace PsimagLite { Loading @@ -10,9 +11,10 @@ class Parallelizer2 { public: Parallelizer2(SizeType threads) : threads_(threads) Parallelizer2(const CodeSectionParams& codeParams) : threads_(codeParams.npthreads) { omp_set_num_threads(threads); omp_set_num_threads(codeParams.npthreads); } template<typename SomeLambdaType> Loading src/Parallelizer2Pthread.h +15 −4 Original line number Diff line number Diff line Loading @@ -74,8 +74,8 @@ public: typedef LoadBalancerDefault::VectorSizeType VectorSizeType; Parallelizer2(SizeType nthreads) : nthreads_(nthreads) {} Parallelizer2(const CodeSectionParams& codeParams) : nthreads_(codeParams.npthreads), stackSize_(codeParams.stackSize) {} SizeType numberOfThreads() const { return nthreads_; } Loading Loading @@ -125,8 +125,18 @@ public: pfs[j].nthreads = nthreads_; attr[j] = new pthread_attr_t; int ret = (stackSize_ > 0) ? pthread_attr_setstacksize(attr[j], stackSize_) : 0; if (ret != 0) { std::cerr<<__FILE__; std::cerr<<"\tpthread_attr_setstacksize() has returned non-zero "<<ret<<"\n"; std::cerr<<"\tIt is possible (but no certain) that the following error"; std::cerr<<"\thappened.\n"; std::cerr<<"\tEINVAL The stack size is less than "; std::cerr<<"PTHREAD_STACK_MIN (16384) bytes.\n"; std::cerr<<"\tI will ignore this error and let you continue\n"; } int ret = pthread_attr_init(attr[j]); ret = pthread_attr_init(attr[j]); checkForError(ret); ret = pthread_create(&thread_id[j], Loading Loading @@ -158,6 +168,7 @@ private: } SizeType nthreads_; size_t stackSize_; }; } #endif // PARALLELIZER2PTHREAD_H src/Parallelizer2Serial.h +3 −2 Original line number Diff line number Diff line #ifndef PARALLELIZER2SERIAL_H #define PARALLELIZER2SERIAL_H #include "Vector.h" #include "CodeSectionParams.h" namespace PsimagLite { Loading @@ -9,9 +10,9 @@ class Parallelizer2 { public: Parallelizer2(SizeType threads) Parallelizer2(const CodeSectionParams& codeParams) { if (threads != 1) if (codeParams.npthreads != 1) throw RuntimeError("Please compile with -DUSE_PTHREADS\n"); } Loading src/PthreadsNg.h +0 −13 Original line number Diff line number Diff line Loading @@ -171,19 +171,6 @@ public: setAffinities_ = flag; } void setStackSize(size_t stackSize) { if (stackSize > 0 && stackSize < PTHREAD_STACK_MIN) { String str(__FILE__); str += ": You are asking PthreadsNg to set stacksize to "; str += ttos(stackSize) + " which is smaller than "; str += "PTHREAD_STACK_MIN= " + ttos(PTHREAD_STACK_MIN); throw RuntimeError(str + "\n"); } stackSize_ = stackSize; } // no weights, no balancer ==> create weights, set all weigths to 1, delegate void loopCreate(PthreadFunctionHolderType& pfh) { Loading Loading
src/NoPthreadsNg.h +0 −2 Original line number Diff line number Diff line Loading @@ -100,8 +100,6 @@ public: size_t stackSize() const { return 0; } void setStackSize(size_t) {} // no weights, no balancer ==> create weights, set all weigths to 1, delegate void loopCreate(PthreadFunctionHolderType& pfh) { Loading
src/Parallelizer2OpenMP.h +4 −2 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ #define PARALLELIZER2OPENMP_H #include "Vector.h" #include <omp.h> #include "CodeSectionParams.h" namespace PsimagLite { Loading @@ -10,9 +11,10 @@ class Parallelizer2 { public: Parallelizer2(SizeType threads) : threads_(threads) Parallelizer2(const CodeSectionParams& codeParams) : threads_(codeParams.npthreads) { omp_set_num_threads(threads); omp_set_num_threads(codeParams.npthreads); } template<typename SomeLambdaType> Loading
src/Parallelizer2Pthread.h +15 −4 Original line number Diff line number Diff line Loading @@ -74,8 +74,8 @@ public: typedef LoadBalancerDefault::VectorSizeType VectorSizeType; Parallelizer2(SizeType nthreads) : nthreads_(nthreads) {} Parallelizer2(const CodeSectionParams& codeParams) : nthreads_(codeParams.npthreads), stackSize_(codeParams.stackSize) {} SizeType numberOfThreads() const { return nthreads_; } Loading Loading @@ -125,8 +125,18 @@ public: pfs[j].nthreads = nthreads_; attr[j] = new pthread_attr_t; int ret = (stackSize_ > 0) ? pthread_attr_setstacksize(attr[j], stackSize_) : 0; if (ret != 0) { std::cerr<<__FILE__; std::cerr<<"\tpthread_attr_setstacksize() has returned non-zero "<<ret<<"\n"; std::cerr<<"\tIt is possible (but no certain) that the following error"; std::cerr<<"\thappened.\n"; std::cerr<<"\tEINVAL The stack size is less than "; std::cerr<<"PTHREAD_STACK_MIN (16384) bytes.\n"; std::cerr<<"\tI will ignore this error and let you continue\n"; } int ret = pthread_attr_init(attr[j]); ret = pthread_attr_init(attr[j]); checkForError(ret); ret = pthread_create(&thread_id[j], Loading Loading @@ -158,6 +168,7 @@ private: } SizeType nthreads_; size_t stackSize_; }; } #endif // PARALLELIZER2PTHREAD_H
src/Parallelizer2Serial.h +3 −2 Original line number Diff line number Diff line #ifndef PARALLELIZER2SERIAL_H #define PARALLELIZER2SERIAL_H #include "Vector.h" #include "CodeSectionParams.h" namespace PsimagLite { Loading @@ -9,9 +10,9 @@ class Parallelizer2 { public: Parallelizer2(SizeType threads) Parallelizer2(const CodeSectionParams& codeParams) { if (threads != 1) if (codeParams.npthreads != 1) throw RuntimeError("Please compile with -DUSE_PTHREADS\n"); } Loading
src/PthreadsNg.h +0 −13 Original line number Diff line number Diff line Loading @@ -171,19 +171,6 @@ public: setAffinities_ = flag; } void setStackSize(size_t stackSize) { if (stackSize > 0 && stackSize < PTHREAD_STACK_MIN) { String str(__FILE__); str += ": You are asking PthreadsNg to set stacksize to "; str += ttos(stackSize) + " which is smaller than "; str += "PTHREAD_STACK_MIN= " + ttos(PTHREAD_STACK_MIN); throw RuntimeError(str + "\n"); } stackSize_ = stackSize; } // no weights, no balancer ==> create weights, set all weigths to 1, delegate void loopCreate(PthreadFunctionHolderType& pfh) { Loading