wiki:MessagePassing

Version 1 (modified by siegel, 13 years ago) ( diff )

--

Message Passing

First attempt:

$input int NPROCS;
$assume NPROCS >= 1;
$scope top;
$heap mp_heap;
$proc procs[NPROCS];

typedef struct Message {
  struct Message *<top> next;
  struct Message *<top> prev;
  int tag;
  int size;
  void *<top> data;
} Message;

typedef struct Comm {
  Message *<top> buf_front[NPROCS][NPROCS];
  Message *<top> buf_back[NPROCS][NPROCS];
} Comm;

Comm _Comm_world;

Comm *<top> COMM_WORLD = &_Comm_world;

void init() {
  for (int i=0; i<NPROCS; i++)
    procs[i] = $spawn proc(i);
  for (int i=0; i<NPROCS; i++)
    for (int j=0; j<NPROCS; j++) {
      COMM_WORLD->buf_front[i][j] = NULL;
      COMM_WORLD->buf_back[i][j] = NULL;
    }
  





Note: See TracWiki for help on using the wiki.