Commit e5c3bc40 authored by Alvarez, Gonzalo's avatar Alvarez, Gonzalo
Browse files

Parallelizer2 accepts balancers

parent 7882a0d3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
#include "Parallelizer2.h"
#include "Vector.h"
#include "LoadBalancerWeights.h"

int main(int argc, char** argv)
{
+4 −0
Original line number Diff line number Diff line
@@ -11,6 +11,10 @@ public:

	typedef PsimagLite::Vector<SizeType>::Type VectorSizeType;

	LoadBalancerWeights(SizeType ntasks, SizeType nthreads)
	    : LoadBalancerWeights(VectorSizeType(ntasks, 1), nthreads) // ctor delegation
	{}

	LoadBalancerWeights(const VectorSizeType& weights, SizeType nthreads)
	    : taskNumber_(nthreads)
	{
+6 −6
Original line number Diff line number Diff line
@@ -40,11 +40,11 @@ struct PthreadFunctionStruct {
	SizeType cpu;
};

template<typename SomeLambdaType>
template<typename SomeLambdaType, typename SomeLoadBalancer>
void *thread_function_wrapper(void *dummyPtr)
{
	PthreadFunctionStruct<SomeLambdaType> *pfs =
	        static_cast<PthreadFunctionStruct<SomeLambdaType> *>(dummyPtr);
	PthreadFunctionStruct<SomeLambdaType, SomeLoadBalancer> *pfs =
	        static_cast<PthreadFunctionStruct<SomeLambdaType, SomeLoadBalancer> *>(dummyPtr);

	const SomeLambdaType* pfh = pfs->pfh;

@@ -111,8 +111,8 @@ public:
	                 const SomeLambdaType& lambda,
	                 const LoadBalancerType& loadBalancer)
	{
		PthreadFunctionStruct<SomeLambdaType>* pfs =
		new PthreadFunctionStruct<SomeLambdaType>[nthreads_];
		PthreadFunctionStruct<SomeLambdaType, LoadBalancerType>* pfs =
		new PthreadFunctionStruct<SomeLambdaType, LoadBalancerType>[nthreads_];
		pthread_t* thread_id = new pthread_t[nthreads_];
		pthread_attr_t** attr = new pthread_attr_t*[nthreads_];

@@ -131,7 +131,7 @@ public:

			ret = pthread_create(&thread_id[j],
			                     attr[j],
			                     thread_function_wrapper<SomeLambdaType>,
			                     thread_function_wrapper<SomeLambdaType, LoadBalancerType>,
			                     &pfs[j]);
			checkForError(ret);
		}