11 #if !defined(FAIL_H) || !defined(TYPES_H)
12 #warning "comm.h" requires "fail.h" and "types.h"
74 #define comm_allreduce PREFIXED_NAME(comm_allreduce)
75 #define comm_scan PREFIXED_NAME(comm_scan )
76 #define comm_dot PREFIXED_NAME(comm_dot )
80 #define comm_gbl_id PREFIXED_NAME(comm_gbl_id)
81 #define comm_gbl_np PREFIXED_NAME(comm_gbl_np)
101 void *
p,
size_t n,
uint src,
int tag);
103 void *
p,
size_t n,
uint dst,
int tag);
110 void *v,
uint vn,
void *buf);
114 #define DEFINE_REDUCE(T) \
115 T PREFIXED_NAME(comm_reduce__##T)( \
116 const struct comm *comm, gs_op op, const T *in, uint n); \
117 static T comm_reduce_##T(const struct comm *c, gs_op op, const T *v, uint vn) \
118 { return PREFIXED_NAME(comm_reduce__##T)(c,op,v,vn); }
122 #define comm_reduce_sint \
123 TYPE_LOCAL(comm_reduce_int,comm_reduce_long,comm_reduce_long_long)
124 #define comm_reduce_slong \
125 TYPE_GLOBAL(comm_reduce_int,comm_reduce_long,comm_reduce_long_long)
137 MPI_Comm_dup(ce, &c->
c);
141 c->
id = 0, c->
np = 1;
146 const char *file,
unsigned line)
151 fail(1,file,line,
"comm_init_check: passed P=%u, "
152 "but MPI_Comm_size gives P=%u",
153 (
unsigned)np,(
unsigned)c->
np);
157 fail(1,file,line,
"comm_init_check: passed P=%u, "
158 "but not compiled with -DMPI",(
unsigned)np);
161 #define comm_init_check(c,ce,np) comm_init_check_(c,ce,np,__FILE__,__LINE__)
165 const char *file,
unsigned line)
169 MPI_Comm_dup(s->
c,&d->
c);
171 if(s->
np!=1)
fail(1,file,line,
"%s not compiled with -DMPI\n",file);
174 #define comm_dup(d,s) comm_dup_(d,s,__FILE__,__LINE__)
179 MPI_Comm_free(&c->
c);
203 # ifndef MPI_STATUS_IGNORE
205 MPI_Recv(p,n,MPI_UNSIGNED_CHAR,src,tag,c->
c,&stat);
207 MPI_Recv(p,n,MPI_UNSIGNED_CHAR,src,tag,c->
c,MPI_STATUS_IGNORE);
216 MPI_Send(p,n,MPI_UNSIGNED_CHAR,dst,tag,c->
c);
221 void *
p,
size_t n,
uint src,
int tag)
224 MPI_Irecv(p,n,MPI_UNSIGNED_CHAR,src,tag,c->
c,req);
229 void *
p,
size_t n,
uint dst,
int tag)
232 MPI_Isend(p,n,MPI_UNSIGNED_CHAR,dst,tag,c->
c,req);
239 # ifndef MPI_STATUSES_IGNORE
240 MPI_Status status[8];
241 while(n>=8) MPI_Waitall(8,req,status), req+=8, n-=8;
242 if(n>0) MPI_Waitall(n,req,status);
244 MPI_Waitall(n,req,MPI_STATUSES_IGNORE);
252 MPI_Bcast(p,n,MPI_UNSIGNED_CHAR,root,c->
c);
static void comm_barrier(const struct comm *c)
static void comm_recv(const struct comm *c, void *p, size_t n, uint src, int tag)
static void comm_wait(comm_req *req, int n)
static void comm_send(const struct comm *c, void *p, size_t n, uint dst, int tag)
static double comm_time(void)
static void comm_free(struct comm *c)
static void comm_bcast(const struct comm *c, void *p, size_t n, uint root)
static void comm_irecv(comm_req *req, const struct comm *c, void *p, size_t n, uint src, int tag)
static void comm_init_check_(struct comm *c, MPI_Fint ce, uint np, const char *file, unsigned line)
#define GS_FOR_EACH_DOMAIN(macro)
static void comm_init(struct comm *c, comm_ext ce)
static void comm_isend(comm_req *req, const struct comm *c, void *p, size_t n, uint dst, int tag)
void fail(int status, const char *file, unsigned line, const char *fmt,...)
static void comm_dup_(struct comm *d, const struct comm *s, const char *file, unsigned line)