Skip to content

Commit

Permalink
SFC load balance: add background loads for a more even distribution o…
Browse files Browse the repository at this point in the history
…f chares.

Also a little cleanup of MultistepLB_notopo.
  • Loading branch information
trquinn committed Jul 23, 2024
1 parent ec82526 commit 1edd4c7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
14 changes: 13 additions & 1 deletion MultistepLB_SFC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ void MultistepLB_SFC::work2(BaseLB::LDStats *stats){

int numProcessed = 0;

double dBgLoad = 0.0;
for(int i = 0; i < stats->nprocs(); i++){
dBgLoad += stats->procs[i].bg_walltime;
}
dBgLoad /= numobjs;

dTotalLoad = 0.0;
for(int i = 0; i < numobjs; i++){
if(!stats->objData[i].migratable) continue;
Expand All @@ -140,14 +146,20 @@ void MultistepLB_SFC::work2(BaseLB::LDStats *stats){
load = udata->myNumParticles;
}
else{
load = stats->objData[i].wallTime;
// give each piece a portion of the background load
load = stats->objData[i].wallTime + dBgLoad;
}

tp_array[numProcessed] = SFCObject(i, load);
tp_array[numProcessed].centroid = udata->vec;
numProcessed++;
dTotalLoad += load;
}

if(verbosity > 0)
CkPrintf("Avg active load %g; Avg bg load %g\n", dTotalLoad/numobjs,
dBgLoad);

CkAssert(numProcessed==nmig);

sfcPrepare(tp_array, nmig, stats);
Expand Down
7 changes: 2 additions & 5 deletions MultistepLB_notopo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool MultistepLB_notopo::QueryBalanceNow(int step){
}

// helper functions for multistepping
#ifdef MCLBMS
#ifdef MCLBMSV

void MultistepLB_notopo::makeActiveProcessorList(BaseLB::LDStats *stats, int numActiveObjs){
int objsPerProc = 8;
Expand All @@ -54,9 +54,7 @@ void MultistepLB_notopo::makeActiveProcessorList(BaseLB::LDStats *stats, int num
procsNeeded = expandFactor*numActiveObjs/objsPerProc > stats->nprocs() ? stats->nprocs() : expandFactor*numActiveObjs/objsPerProc;

/* currently, only the first procsNeeded procs are used - could do something more sophisticated here in the future - FIXME */
#ifdef MCLBMSV
CkPrintf("Processors 0 to %d active\n", procsNeeded-1);
#endif
}
#endif

Expand Down Expand Up @@ -129,10 +127,9 @@ void MultistepLB_notopo::work(BaseLB::LDStats* stats)

// select processors
#ifdef MCLBMSV
//printData(*stats, phase, NULL);
CkPrintf("making active processor list\n");
#endif
makeActiveProcessorList(stats, numActiveObjects);
#endif
count = stats->nprocs();

// let the strategy take over on this modified instrumented data and processor information
Expand Down
3 changes: 2 additions & 1 deletion MultistepLB_notopo.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ class MultistepLB_notopo : public CBase_MultistepLB_notopo, public Orb3dCommon {
private:
void init();
bool QueryBalanceNow(int step);
#ifdef MCLBMSV
void makeActiveProcessorList(BaseLB::LDStats *stats, int numActiveObjs);

#endif

public:
MultistepLB_notopo(const CkLBOptions &);
Expand Down

0 comments on commit 1edd4c7

Please sign in to comment.