


























 
#define CONTENTION_FREE_RANDOM_SIZE   53
#define CONTENTION_FREE_INIT_FREQ     4

#define init_contention_free_communication()                \
  do {                                                      \
    int temp_mod;                                           \
    if (_bsp_nprocs==1) {                                   \
	/* do nothing */                                    \
    } else if (contentionfree.next==contentionfree.last)    \
      contentionfree.next += (_bsp_nprocs-1);               \
    else if (temp_mod=contentionfree.next%(_bsp_nprocs-1))  \
      contentionfree.next += (_bsp_nprocs-1)-temp_mod;      \
    else {                                                  \
      /* donothing, at next already */                      \
    }                                                       \
    if (contentionfree.next>=contentionfree.size)           \
      contentionfree.next=0;                                \
    contentionfree.last=contentionfree.next;                \
  } while(0)

#define next_contention_free_pid() \
  contentionfree.randoms[contentionfree.next++]




typedef struct {
   int *randoms;
   int  next;
   int  last;
   int  size;
} _BSPcontention;

extern _BSPcontention contentionfree;
extern void config_contention_free_communication();


