1
#include "atlas_misc.h"
2
#include "atlas_threads.h"
3
int ATL_DecGlobalAtomicCount(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)
26
j += b * rank + Mmin(rank, extra);
27
//fprintf(stderr, "%d: j=%d, LRET\n", rank, j);
31
acnts = (void**) (ip+4+(((P+3)>>2)<<2));
33
* Otherwise, find an atomic counter that still has count
38
* If I got a counter value, convert it from local to global
41
if (j = ATL_DecAtomicCount(acnts[icnt]))
43
j += nL + b*icnt + Mmin(icnt,extra);
47
//fprintf(stderr, "%d: j=%d, icnt=%d, b=%d P=%d, e=%d\n", rank, j, icnt, b, P, extra);