~ubuntu-branches/ubuntu/trusty/atlas/trusty

« back to all changes in this revision

Viewing changes to src/threads/ATL_DecGlobalAtomicCount.c

  • Committer: Package Import Robot
  • Author(s): Sébastien Villemot
  • Date: 2013-07-27 14:26:05 UTC
  • mfrom: (18.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20130727142605-5rh3p972h1whdo99
Tags: 3.10.1-2
* Allow the generic package to build on machines with CPU throttling
  enabled. Otherwise the package FTBFS on some buildds (e.g. biber).
  Implementation is done by reactivating the "-Si cputhrchk 0" flag
  (cpu-throtthling-check.diff), and using it in debian/rules.
* Add architectural defaults for armel and mips.
* armhf.diff: do not enforce 32-registers FPU for Fortran

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "atlas_misc.h"
 
2
#include "atlas_threads.h"
 
3
int ATL_DecGlobalAtomicCount(void *vp, int rank)
 
4
/*
 
5
 * This routine returns a global counter that has been distributed over
 
6
 * P local counters
 
7
 */
 
8
{
 
9
   int i, j, P, b, icnt, extra, nL, *ip=vp, *iloc;
 
10
   void **acnts;
 
11
 
 
12
   P = ip[0];
 
13
   b = ip[1];
 
14
   extra = ip[2];
 
15
   nL = ip[3];
 
16
   iloc = ip+4;
 
17
/*
 
18
 * See if I can get the index from purely local information
 
19
 */
 
20
   if (rank < P && rank >= 0 && nL)
 
21
   {
 
22
      j = iloc[rank];
 
23
      if (j)
 
24
      {
 
25
         iloc[rank]--;
 
26
         j += b * rank + Mmin(rank, extra);
 
27
//fprintf(stderr, "%d: j=%d, LRET\n", rank, j);
 
28
         return(j);
 
29
      }
 
30
   }
 
31
   acnts = (void**) (ip+4+(((P+3)>>2)<<2));
 
32
/*
 
33
 * Otherwise, find an atomic counter that still has count
 
34
 */
 
35
   for (i=0; i < P; i++)
 
36
   {
 
37
/*
 
38
 *    If I got a counter value, convert it from local to global
 
39
 */
 
40
      icnt = (rank+i)%P;
 
41
      if (j = ATL_DecAtomicCount(acnts[icnt]))
 
42
      {
 
43
         j += nL + b*icnt + Mmin(icnt,extra);
 
44
         break;
 
45
      }
 
46
   }
 
47
//fprintf(stderr, "%d: j=%d, icnt=%d, b=%d P=%d, e=%d\n", rank, j, icnt, b, P, extra);
 
48
   return(j);
 
49
}