From 757b31ed42b026b3a4eb7612d05720b42907ef0e Mon Sep 17 00:00:00 2001 From: paboyle Date: Wed, 4 Nov 2015 03:22:14 -0800 Subject: [PATCH] Threading for KNC mods. --- lib/Threads.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Threads.h b/lib/Threads.h index f453b860..2a1f74bb 100644 --- a/lib/Threads.h +++ b/lib/Threads.h @@ -45,12 +45,15 @@ class GridThread { static int SumArraySize(void) {return _threads;}; static void GetWork(int nwork, int me, int & mywork, int & myoff){ - int basework = nwork/_threads; - int backfill = _threads-(nwork%_threads); - if ( me >= _threads ) { + GetWork(nwork,me,mywork,myoff,_threads); + } + static void GetWork(int nwork, int me, int & mywork, int & myoff,int units){ + int basework = nwork/units; + int backfill = units-(nwork%units); + if ( me >= units ) { mywork = myoff = 0; } else { - mywork = (nwork+me)/_threads; + mywork = (nwork+me)/units; myoff = basework * me; if ( me > backfill ) myoff+= (me-backfill);