32 #ifndef PLANCK_SHARE_UTILS_H 33 #define PLANCK_SHARE_UTILS_H 42 int64 myshare, int64 &lo, int64 &hi)
44 int64 nwork = ghi-glo;
45 int64 nbase = nwork/nshares;
46 int64 additional = nwork%nshares;
47 lo = glo+myshare*nbase + ((myshare<additional) ? myshare : additional);
48 hi = lo+nbase+(myshare<additional);
51 inline int64 shareSize (int64 glo, int64 ghi, int64 nshares, int64 myshare)
53 int64 nwork = ghi-glo;
54 int64 nbase = nwork/nshares;
55 int64 additional = nwork%nshares;
56 return (myshare<additional) ? nbase+1 : nbase;
64 uint64 s_full, s_chunk, offset;
71 : s_full(s_full_), s_chunk(s_chunk_), offset(0) {}
75 {
return 1 + (s_full-1)/s_chunk; }
80 bool getNext (uint64 &start, uint64 &size)
83 if (offset>=s_full)
return false;
85 size=min(s_chunk,s_full-offset);
void calcShareGeneral(int64 glo, int64 ghi, int64 nshares, int64 myshare, int64 &lo, int64 &hi)
bool getNext(uint64 &start, uint64 &size)
chunkMaker(uint64 s_full_, uint64 s_chunk_)