Loading src/NoPthreadsNg.h +4 −3 Original line number Diff line number Diff line Loading @@ -105,9 +105,10 @@ public: // no weights, no balancer ==> create weights, set all weigths to 1, delegate void loopCreate(PthreadFunctionHolderType& pfh) { SizeType ntasks = pfh.tasks(); VectorSizeType weights(ntasks,1); loopCreate(pfh,weights); LoadBalancerType* loadBalancer = new LoadBalancerType(pfh.tasks(), 1); loopCreate(pfh, *loadBalancer); delete loadBalancer; loadBalancer = 0; } // weights, no balancer ==> create balancer with weights ==> delegate Loading src/Parallelizer.h +5 −5 Original line number Diff line number Diff line Loading @@ -113,7 +113,7 @@ DISCLOSED WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS. #endif // USE_PTHREADS namespace PsimagLite { template<typename InstanceType> template<typename InstanceType, typename LoadBalancerType=LoadBalancerDefault> class Parallelizer #ifdef USE_PTHREADS Loading @@ -122,8 +122,8 @@ class Parallelizer : public PthreadsAndMpi<InstanceType> { typedef PthreadsAndMpi<InstanceType> BaseType; #else : public ActualPthreadsName<InstanceType> { typedef ActualPthreadsName<InstanceType> BaseType; : public ActualPthreadsName<InstanceType, LoadBalancerType> { typedef ActualPthreadsName<InstanceType, LoadBalancerType> BaseType; #endif #else Loading @@ -131,8 +131,8 @@ class Parallelizer : public Mpi<InstanceType> { typedef Mpi<InstanceType> BaseType; #else : public ActualNoPthreadsName<InstanceType> { typedef ActualNoPthreadsName<InstanceType> BaseType; : public ActualNoPthreadsName<InstanceType, LoadBalancerType> { typedef ActualNoPthreadsName<InstanceType, LoadBalancerType> BaseType; #endif #endif Loading src/PthreadsNg.h +15 −12 Original line number Diff line number Diff line Loading @@ -107,7 +107,7 @@ DISCLOSED WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS. namespace PsimagLite { template<typename PthreadFunctionHolderType, typename LoadBalancerType=LoadBalancerDefault> template<typename PthreadFunctionHolderType, typename LoadBalancerType> struct PthreadFunctionStruct { PthreadFunctionStruct() : pfh(0),loadBalancer(0),threadNum(0),nthreads(0),total(0),cpu(0) Loading @@ -121,11 +121,12 @@ struct PthreadFunctionStruct { SizeType cpu; }; template<typename PthreadFunctionHolderType> template<typename PthreadFunctionHolderType, typename LoadBalancerType> void *thread_function_wrapper(void *dummyPtr) { PthreadFunctionStruct<PthreadFunctionHolderType> *pfs = static_cast<PthreadFunctionStruct<PthreadFunctionHolderType> *>(dummyPtr); PthreadFunctionStruct<PthreadFunctionHolderType, LoadBalancerType> *pfs = static_cast<PthreadFunctionStruct<PthreadFunctionHolderType, LoadBalancerType> *> (dummyPtr); PthreadFunctionHolderType *pfh = pfs->pfh; Loading @@ -139,7 +140,7 @@ void *thread_function_wrapper(void *dummyPtr) for (SizeType p=0; p < blockSize; ++p) { SizeType taskNumber = pfs->loadBalancer->taskNumber(pfs->threadNum, p); if (taskNumber > pfs->total) break; if (taskNumber >= pfs->total) break; pfh->doTask(taskNumber, pfs->threadNum); } Loading Loading @@ -186,9 +187,10 @@ public: // no weights, no balancer ==> create weights, set all weigths to 1, delegate void loopCreate(PthreadFunctionHolderType& pfh) { SizeType ntasks = pfh.tasks(); VectorSizeType weights(ntasks,1); loopCreate(pfh,weights); LoadBalancerType* loadBalancer = new LoadBalancerType(pfh.tasks(), nthreads_); loopCreate(pfh, *loadBalancer); delete loadBalancer; loadBalancer = 0; } // weights, no balancer ==> create balancer with weights ==> delegate Loading @@ -204,8 +206,8 @@ public: void loopCreate(PthreadFunctionHolderType& pfh, const LoadBalancerType& loadBalancer) { PthreadFunctionStruct<PthreadFunctionHolderType>* pfs; pfs = new PthreadFunctionStruct<PthreadFunctionHolderType>[nthreads_]; PthreadFunctionStruct<PthreadFunctionHolderType, LoadBalancerType>* pfs; pfs = new PthreadFunctionStruct<PthreadFunctionHolderType, LoadBalancerType>[nthreads_]; pthread_t* thread_id = new pthread_t[nthreads_]; pthread_attr_t** attr = new pthread_attr_t*[nthreads_]; SizeType ntasks = pfh.tasks(); Loading Loading @@ -256,7 +258,8 @@ public: ret = pthread_create(&thread_id[j], attr[j], thread_function_wrapper<PthreadFunctionHolderType>, thread_function_wrapper<PthreadFunctionHolderType, LoadBalancerType>, &pfs[j]); checkForError(ret); } Loading Loading
src/NoPthreadsNg.h +4 −3 Original line number Diff line number Diff line Loading @@ -105,9 +105,10 @@ public: // no weights, no balancer ==> create weights, set all weigths to 1, delegate void loopCreate(PthreadFunctionHolderType& pfh) { SizeType ntasks = pfh.tasks(); VectorSizeType weights(ntasks,1); loopCreate(pfh,weights); LoadBalancerType* loadBalancer = new LoadBalancerType(pfh.tasks(), 1); loopCreate(pfh, *loadBalancer); delete loadBalancer; loadBalancer = 0; } // weights, no balancer ==> create balancer with weights ==> delegate Loading
src/Parallelizer.h +5 −5 Original line number Diff line number Diff line Loading @@ -113,7 +113,7 @@ DISCLOSED WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS. #endif // USE_PTHREADS namespace PsimagLite { template<typename InstanceType> template<typename InstanceType, typename LoadBalancerType=LoadBalancerDefault> class Parallelizer #ifdef USE_PTHREADS Loading @@ -122,8 +122,8 @@ class Parallelizer : public PthreadsAndMpi<InstanceType> { typedef PthreadsAndMpi<InstanceType> BaseType; #else : public ActualPthreadsName<InstanceType> { typedef ActualPthreadsName<InstanceType> BaseType; : public ActualPthreadsName<InstanceType, LoadBalancerType> { typedef ActualPthreadsName<InstanceType, LoadBalancerType> BaseType; #endif #else Loading @@ -131,8 +131,8 @@ class Parallelizer : public Mpi<InstanceType> { typedef Mpi<InstanceType> BaseType; #else : public ActualNoPthreadsName<InstanceType> { typedef ActualNoPthreadsName<InstanceType> BaseType; : public ActualNoPthreadsName<InstanceType, LoadBalancerType> { typedef ActualNoPthreadsName<InstanceType, LoadBalancerType> BaseType; #endif #endif Loading
src/PthreadsNg.h +15 −12 Original line number Diff line number Diff line Loading @@ -107,7 +107,7 @@ DISCLOSED WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS. namespace PsimagLite { template<typename PthreadFunctionHolderType, typename LoadBalancerType=LoadBalancerDefault> template<typename PthreadFunctionHolderType, typename LoadBalancerType> struct PthreadFunctionStruct { PthreadFunctionStruct() : pfh(0),loadBalancer(0),threadNum(0),nthreads(0),total(0),cpu(0) Loading @@ -121,11 +121,12 @@ struct PthreadFunctionStruct { SizeType cpu; }; template<typename PthreadFunctionHolderType> template<typename PthreadFunctionHolderType, typename LoadBalancerType> void *thread_function_wrapper(void *dummyPtr) { PthreadFunctionStruct<PthreadFunctionHolderType> *pfs = static_cast<PthreadFunctionStruct<PthreadFunctionHolderType> *>(dummyPtr); PthreadFunctionStruct<PthreadFunctionHolderType, LoadBalancerType> *pfs = static_cast<PthreadFunctionStruct<PthreadFunctionHolderType, LoadBalancerType> *> (dummyPtr); PthreadFunctionHolderType *pfh = pfs->pfh; Loading @@ -139,7 +140,7 @@ void *thread_function_wrapper(void *dummyPtr) for (SizeType p=0; p < blockSize; ++p) { SizeType taskNumber = pfs->loadBalancer->taskNumber(pfs->threadNum, p); if (taskNumber > pfs->total) break; if (taskNumber >= pfs->total) break; pfh->doTask(taskNumber, pfs->threadNum); } Loading Loading @@ -186,9 +187,10 @@ public: // no weights, no balancer ==> create weights, set all weigths to 1, delegate void loopCreate(PthreadFunctionHolderType& pfh) { SizeType ntasks = pfh.tasks(); VectorSizeType weights(ntasks,1); loopCreate(pfh,weights); LoadBalancerType* loadBalancer = new LoadBalancerType(pfh.tasks(), nthreads_); loopCreate(pfh, *loadBalancer); delete loadBalancer; loadBalancer = 0; } // weights, no balancer ==> create balancer with weights ==> delegate Loading @@ -204,8 +206,8 @@ public: void loopCreate(PthreadFunctionHolderType& pfh, const LoadBalancerType& loadBalancer) { PthreadFunctionStruct<PthreadFunctionHolderType>* pfs; pfs = new PthreadFunctionStruct<PthreadFunctionHolderType>[nthreads_]; PthreadFunctionStruct<PthreadFunctionHolderType, LoadBalancerType>* pfs; pfs = new PthreadFunctionStruct<PthreadFunctionHolderType, LoadBalancerType>[nthreads_]; pthread_t* thread_id = new pthread_t[nthreads_]; pthread_attr_t** attr = new pthread_attr_t*[nthreads_]; SizeType ntasks = pfh.tasks(); Loading Loading @@ -256,7 +258,8 @@ public: ret = pthread_create(&thread_id[j], attr[j], thread_function_wrapper<PthreadFunctionHolderType>, thread_function_wrapper<PthreadFunctionHolderType, LoadBalancerType>, &pfs[j]); checkForError(ret); } Loading