1
#include "atlas_misc.h"
2
#include "atlas_threads.h"
3
int ATL_GetGlobalAtomicCount(void *vp, int rank)
5
* This routine returns a global counter that has been distributed over
9
int i, j, P, b, icnt, extra, nL, *ip=vp, *iloc;
18
* See if I can get the index from purely local information
20
if (rank < P && rank >= 0 && nL)
25
j += b * rank + Mmin(rank, extra);
26
//fprintf(stderr, "%d: j=%d, LRET\n", rank, j);
30
acnts = (void**) (ip+4+(((P+3)>>2)<<2));
32
* Otherwise, find an atomic counter that still has count
37
* If I got a counter value, convert it from local to global
40
if (j = ATL_GetAtomicCount(acnts[icnt]))
42
j += nL + b*icnt + Mmin(icnt,extra);
46
//fprintf(stderr, "%d: j=%d, icnt=%d, b=%d P=%d, e=%d\n", rank, j, icnt, b, P, extra);