Commit 6732fbf1 authored by Alvarez, Gonzalo's avatar Alvarez, Gonzalo
Browse files

PthreadNg: threads <= tasks

parent 07d588dd
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ Please see full open source license included in file LICENSE.
#include <cstdlib>
#define USE_PTHREADS_OR_NOT_NG
#include "Parallelizer.h"
#include "LoadBalancerWeights.h"

class MyHelper {

@@ -74,7 +75,6 @@ int main(int argc,char *argv[])
{
	typedef PsimagLite::Concurrency ConcurrencyType;


	if (argc!=3) {
		std::cout<<"USAGE: "<<argv[0]<<" nthreads ntasks\n";
		return 1;
@@ -86,7 +86,7 @@ int main(int argc,char *argv[])
	ConcurrencyType concurrency(&argc,&argv,nthreads);

	typedef MyHelper HelperType;
	typedef PsimagLite::Parallelizer<HelperType> ParallelizerType;
	typedef PsimagLite::Parallelizer<HelperType, PsimagLite::LoadBalancerWeights> ParallelizerType;
	ParallelizerType threadObject(ConcurrencyType::codeSectionParams);

	HelperType helper(ntasks, nthreads);
+5 −0
Original line number Diff line number Diff line
@@ -14,6 +14,11 @@ public:
	LoadBalancerDefault(SizeType ntasks, SizeType nthreads)
	    : blockSize_(ntasks/nthreads)
	{
		if (ntasks < nthreads) {
			nthreads = ntasks;
			blockSize_ = 1;
		}

		if ((ntasks % nthreads) != 0) ++blockSize_;
	}

+2 −1
Original line number Diff line number Diff line
@@ -18,8 +18,9 @@ public:
	LoadBalancerWeights(const VectorSizeType& weights, SizeType nthreads)
	    : taskNumber_(nthreads)
	{
		VectorSizeType workLoad(nthreads, 0);
		SizeType ntasks = weights.size();
		if (ntasks < nthreads) nthreads = ntasks;
		VectorSizeType workLoad(nthreads, 0);
		VectorSizeType weights2 = weights;
		VectorSizeType iperm(ntasks, 0);
		Sort<VectorSizeType> sort;
+1 −1
Original line number Diff line number Diff line
@@ -280,7 +280,7 @@ public:

	String name() const { return "PthreadsNg"; }

	SizeType threads() const { return nthreads_; }
	//SizeType threads() const { return nthreads_; }

	SizeType mpiProcs() const { return 1; }