Changes between Version 3 and Version 4 of MessagePassing


Ignore:
Timestamp:
07/11/13 20:41:11 (13 years ago)
Author:
siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MessagePassing

    v3 v4  
    44
    55{{{
     6
     7#define MPI_ANY_SOURCE -1
     8#define MPI_ANY_TAG -2
     9#define MPI_INT 1
     10#define MPI_FLOAT 2
     11#define MPI_DOUBLE 3
     12// etc.
     13
    614$input int NPROCS;
    715$assume NPROCS >= 1;
     
    1321 * Each queue is a doubly-linked list of Message objects.
    1422 */
    15 typedef struct Message {
    16   struct Message *<top> next;
    17   struct Message *<top> prev;
     23typedef struct MPI_Message {
     24  struct MPI_Message *<top> next;
     25  struct MPI_Message *<top> prev;
    1826  int tag;
    1927  int size;
    2028  void *<top> data;
    21 } Message;
     29} MPI_Message;
    2230
    23 typedef struct Comm_struct {
    24   Message *<top> buf_front[NPROCS][NPROCS];
    25   Message *<top> buf_back[NPROCS][NPROCS];
    26 } Comm_struct;
     31typedef struct MPI_Comm_struct {
     32  MPI_Message *<top> buf_front[NPROCS][NPROCS];
     33  MPI_Message *<top> buf_back[NPROCS][NPROCS];
     34} MPI_Comm_struct;
    2735
    28 typedef Comm_struct *Comm;
     36typedef MPI_Comm_struct *MPI_Comm;
    2937
    3038/* As in MPI, when a receive returns, this structure
     
    3240 * which you need if you used wildcards,  Also size.
    3341 */
    34 typedef struct Status {
     42typedef struct MPI_Status {
    3543  int source;
    3644  int tag;
    3745  int size;
    38 } Status;
     46} MPI_Status;
    3947
    40 Comm _Comm_world;
     48typedef int MPI_Datatype;
    4149
    42 /* The user will use COMM_WORLD */
    43 Comm *<top> COMM_WORLD = &_Comm_world;
     50/* This is the actual MPI Comm world structure */
     51MPI_Comm_struct MPI_Comm_world_struct;
    4452
    45 
     53/* The user will use MPI_COMM_WORLD */
     54MPI_Comm MPI_COMM_WORLD = &MPI_Comm_world_struct;
    4655
    4756void init() {
     
    5059  for (int i=0; i<NPROCS; i++)
    5160    for (int j=0; j<NPROCS; j++) {
    52       COMM_WORLD->buf_front[i][j] = NULL;
    53       COMM_WORLD->buf_back[i][j] = NULL;
     61      MPI_COMM_WORLD->buf_front[i][j] = NULL;
     62      MPI_COMM_WORLD->buf_back[i][j] = NULL;
    5463    }
    55 }   
     64}
    5665
    57 void send(int source, void *buf, int size, int tag, int dest, Comm comm) {
     66int sizeofDatatype(MPI_Datatype type) {
     67  switch (type) {
     68    case MPI_INT: return sizeof(int);
     69    case MPI_FLOAT: return sizeof(float);
     70    case MPI_DOUBLE: return sizeof(double);
     71    default: exit(-1); // not yet implemented
     72  }
     73}
     74
     75void MPI_process(int pid) {
     76
     77  void MPI_Send(void *buf, int size, int tag, int dest, MPI_Comm comm) {
    5878  // create a message
    5979  Message message;
     
    6989// can I use a function as a guard?  not now
    7090// can always use busy-wait loop?
    71 boolean probe(…) {
     91boolean recv_guard(int source, int dest, int tag, Comm comm) {
    7292
    7393}