int PARMCI_GetV( armci_giov_t darr[], /* descriptor array */ int len, /* length of descriptor array */ int proc /* remote process(or) ID */ ) { int rc=0, i,direct=1; if(len<1) return FAIL; for(i=0;i<len;i++){ if(darr[i].src_ptr_array==NULL ||darr[i].dst_ptr_array==NULL)return FAIL2; if(darr[i].bytes<1)return FAIL3; if(darr[i].ptr_array_len <1) return FAIL4; } if(proc<0 || proc >= armci_nproc)return FAIL5; ORDER(GET,proc); /* ensure ordering */ #ifndef QUADRICS direct=SAMECLUSNODE(proc); #endif if(direct){ if(!SAMECLUSNODE(proc))DO_FENCE(proc,DIRECT_GET); rc = armci_copy_vector(GET, darr, len, proc); } else{ DO_FENCE(proc,SERVER_GET); rc = armci_pack_vector(GET, NULL, darr, len, proc,NULL); } if(rc) return FAIL6; else return 0; }
void ARMCI_Fence(int proc) { if (!SAMECLUSNODE(proc)) armci_profile_start(ARMCI_PROF_FENCE); PARMCI_Fence(proc); if (!SAMECLUSNODE(proc)) armci_profile_stop(ARMCI_PROF_FENCE); }
/*\ Non-blocking vector API \*/ int PARMCI_NbPutV( armci_giov_t darr[], /* descriptor array */ int len, /* length of descriptor array */ int proc, /* remote process(or) ID */ armci_hdl_t* usr_hdl /*non-blocking request handle*/ ) { armci_ihdl_t nb_handle = (armci_ihdl_t)usr_hdl; int rc=0, i,direct=1; if(len<1) return FAIL; for(i=0;i<len;i++){ if(darr[i].src_ptr_array == NULL || darr[i].dst_ptr_array ==NULL) return FAIL2; if(darr[i].bytes<1)return FAIL3; if(darr[i].ptr_array_len <1) return FAIL4; } if(proc<0 || proc >= armci_nproc)return FAIL5; direct=SAMECLUSNODE(proc); /* aggregate put */ if(nb_handle && nb_handle->agg_flag == SET) { if(!direct) { rc=armci_agg_save_giov_descriptor(darr, len, proc, PUT, nb_handle); return rc; } } else { /*ORDER(PUT,proc); ensure ordering */ UPDATE_FENCE_INFO(proc); /*set tag and op in the nb handle*/ if(nb_handle){ nb_handle->tag = GET_NEXT_NBTAG(); nb_handle->op = PUT; nb_handle->proc= proc; nb_handle->bufid=NB_NONE; } else nb_handle = armci_set_implicit_handle(PUT, proc); } if(direct){ if(!SAMECLUSNODE(proc))DO_FENCE(proc,DIRECT_PUT); rc = armci_copy_vector(PUT, darr, len, proc); } else{ DO_FENCE(proc,SERVER_NBPUT); rc = armci_pack_vector(PUT, NULL, darr, len, proc,nb_handle); } if(rc) return FAIL6; else return 0; }
int PARMCI_AccV( int op, /* oeration code */ void *scale, /*scaling factor for accumulate */ armci_giov_t darr[], /* descriptor array */ int len, /* length of descriptor array */ int proc /* remote process(or) ID */ ) { int rc=0, i,direct=0; if(len<1) return FAIL; for(i=0;i<len;i++){ if(darr[i].src_ptr_array==NULL ||darr[i].dst_ptr_array==NULL)return FAIL2; if(darr[i].bytes<1)return FAIL3; if(darr[i].ptr_array_len <1) return FAIL4; } if(proc<0 || proc >= armci_nproc)return FAIL5; ORDER(op,proc); /* ensure ordering */ direct=SAMECLUSNODE(proc); # if defined(ACC_COPY) && !defined(ACC_SMP) if(armci_me != proc) direct=0; # error "grrr" # endif if(direct) { rc = armci_acc_vector( op, scale, darr, len, proc); } else { DO_FENCE(proc,SERVER_PUT); rc = armci_pack_vector(op, scale, darr, len, proc,NULL); } if(rc) return FAIL6; else return 0; }
void PARMCI_Lock(int mutex, int proc) { #if defined(SERVER_LOCK) int direct; #endif if(DEBUG)fprintf(stderr,"%d enter lock\n",armci_me); if(!num_mutexes) armci_die("armci_lock: create mutexes first",0); if(mutex > glob_mutex[proc].count) armci_die2("armci_lock: mutex not allocated", mutex, glob_mutex[proc].count); if(armci_nproc == 1) return; # if defined(SERVER_LOCK) direct=SAMECLUSNODE(proc); if(!direct) armci_rem_lock(mutex,proc, glob_mutex[proc].tickets + mutex ); else # endif armci_generic_lock(mutex,proc); if(DEBUG)fprintf(stderr,"%d leave lock\n",armci_me); }
void ARMCI_DoFence(int proc) { int i; if(!SAMECLUSNODE(proc) && (armci_nclus >1)){ int cluster = armci_clus_id(proc); armci_rem_ack(cluster); } }
/* Check whether the oricess is in the same domain */ int armci_domain_same_id (armci_domain_t domain, int proc) { #if 0 int rc = SAMECLUSNODE(proc); return rc; #else assert(0); #endif }
int PARMCI_NbAccV( int op, /* oeration code */ void *scale, /*scaling factor for accumulate */ armci_giov_t darr[], /* descriptor array */ int len, /* length of descriptor array */ int proc, /* remote process(or) ID */ armci_hdl_t* usr_hdl /*non-blocking request handle*/ ) { armci_ihdl_t nb_handle = (armci_ihdl_t)usr_hdl; int rc=0, i,direct=1; if(len<1) return FAIL; for(i=0;i<len;i++) { if(darr[i].src_ptr_array==NULL ||darr[i].dst_ptr_array==NULL)return FAIL2; if(darr[i].bytes<1)return FAIL3; if(darr[i].ptr_array_len <1) return FAIL4; } if(proc<0 || proc >= armci_nproc)return FAIL5; UPDATE_FENCE_INFO(proc); direct=SAMECLUSNODE(proc); if(nb_handle){ nb_handle->tag = GET_NEXT_NBTAG(); nb_handle->op = op; nb_handle->proc= proc; nb_handle->bufid=NB_NONE; } else nb_handle = armci_set_implicit_handle(op, proc); # if defined(ACC_COPY) && !defined(ACC_SMP) if(armci_me != proc) direct=0; # endif if(direct) rc = armci_acc_vector( op, scale, darr, len, proc); else{ DO_FENCE(proc,SERVER_NBPUT); rc = armci_pack_vector(op, scale, darr, len, proc,nb_handle); } if(rc) return FAIL6; else return 0; }
int armci_copy_vector(int op, /* operation code */ armci_giov_t darr[], /* descriptor array */ int len, /* length of descriptor array */ int proc /* remote process(or) ID */ ) { int i,s,shmem= SAMECLUSNODE(proc); int armci_th_idx = ARMCI_THREAD_IDX; if(shmem){ /* local/shared memory copy */ for(i = 0; i< len; i++){ for( s=0; s< darr[i].ptr_array_len; s++){ armci_copy(darr[i].src_ptr_array[s],darr[i].dst_ptr_array[s],darr[i].bytes); } } }else { switch(op){ case PUT: for(i = 0; i< len; i++){ UPDATE_FENCE_STATE(proc, PUT, darr[i].ptr_array_len); for( s=0; s< darr[i].ptr_array_len; s++){ armci_put(darr[i].src_ptr_array[s],darr[i].dst_ptr_array[s], darr[i].bytes, proc); } } break; case GET: for(i = 0; i< len; i++){ for( s=0; s< darr[i].ptr_array_len; s++){ armci_get(darr[i].src_ptr_array[s],darr[i].dst_ptr_array[s], darr[i].bytes,proc); } } break; default: armci_die("armci_copy_vector: wrong optype",op); } } return 0; }
int ARMCI_Rmw(int op, int *ploc, int *prem, int extra, int proc) { if(!SAMECLUSNODE(proc)){ armci_rem_rmw(op, ploc, prem, extra, proc); return 0; } switch (op) { case ARMCI_FETCH_AND_ADD: case ARMCI_FETCH_AND_ADD_LONG: case ARMCI_SWAP: case ARMCI_SWAP_LONG: armci_generic_rmw(op, ploc, prem, extra, proc); break; default: armci_die("rmw: operation not supported",op); } return 0; }
int armci_gpc_local_exec(int h, int to, int from, void *hdr, int hlen, void *data, int dlen, void *rhdr, int rhlen, void *rdata, int rdlen, int rtype) { int rhsize, rdsize; int (*func)(); int hnd = -h + GPC_OFFSET; if(hnd <0 || hnd>= GPC_SLOTS) armci_die2("armci_gpc_local_exec: bad callback handle",hnd,GPC_SLOTS); if(!_table[hnd]) armci_die("armci_gpc_local_exec: NULL function",hnd); func = _table[hnd]; if(!SAMECLUSNODE(to)) armci_die("armci_gpc_local_exec: GPC call to a different node received!", armci_me); /* func(to, from, hdr, hlen, data, dlen, rhdr, rhlen, &rhsize, */ /* rdata, rdlen, &rdsize); */ /* return 0; */ return func(to, from, hdr, hlen, data, dlen, rhdr, rhlen, &rhsize, rdata, rdlen, &rdsize, rtype); }
/*\ Send Request to Execute callback function in a global address space * Arguments: * f - handle to the callback function * p - remote processor * hdr - header data - used to pack extra args for callback (local buffer) * hlen - size of header data < ARMCI_GPC_HLEN * data - bulk data passed to callback (local buffer) * dlen - length of bulk data * rhdr - ptr to reply header (return args from callback) * rhlen - length of buffer to store reply header < ARMCI_GPC_HLEN * rdata - ptr to where reply data from callback should be stored (local buf) * rdlen - size of the buffer to store reply data * nbh - nonblocking handle * \*/ int ARMCI_Gpc_exec(int h, int p, void *hdr, int hlen, void *data, int dlen, void *rhdr, int rhlen, void *rdata, int rdlen, gpc_hdl_t* nbh) { int hnd = -h + GPC_OFFSET; int err = 0; armci_hdl_t *ahdl = (nbh ? &(nbh->ahdl): NULL); if(hnd <0 || hnd>= GPC_SLOTS) err += fprintf(stderr, "ARMCI_Gpc_exec: bad callback handle %d: %d\n",hnd,GPC_SLOTS); if(!_table[hnd]) err += fprintf(stderr, "ARMCI_Gpc_exec: NULL function %d",hnd); if(hlen<0 || hlen>=ARMCI_Gpc_get_hlen()) err += fprintf(stderr, "ARMCI_Gpc_exec: Invalid send header size %d %d\n", hlen, ARMCI_Gpc_get_hlen()); if(rhlen<0 || rhlen>=ARMCI_Gpc_get_hlen()) err += fprintf(stderr, "ARMCI_Gpc_exec: Invalid recv header size %d %d\n", rhlen, ARMCI_Gpc_get_hlen()); if(dlen<0 || dlen>=ARMCI_Gpc_get_dlen()) err += fprintf(stderr, "ARMCI_Gpc_exec: Invalid send data size %d %d\n", dlen, ARMCI_Gpc_get_dlen()); if(rdlen<0 || rdlen>=ARMCI_Gpc_get_dlen()) err += fprintf(stderr, "ARMCI_Gpc_exec: Invalid recv data size %d %d\n", rdlen, ARMCI_Gpc_get_dlen()); if(hlen>0 && hdr==NULL) err += fprintf(stderr, "ARMCI_Gpc_exec: Null send header for non-zero header size %d\n", hlen); if(rhlen>0 && rhdr==NULL) err += fprintf(stderr, "ARMCI_Gpc_exec: Null recv header for non-zero header size %d\n", rhlen); if(dlen>0 && data==NULL) err += fprintf(stderr, "ARMCI_Gpc_exec: Null send data for non-zero data size %d\n", dlen); if(rdlen>0 && rdata==NULL) err += fprintf(stderr, "ARMCI_Gpc_exec: Null recv data for non-zero header size %d\n", rdlen); if(p<0 || p >= armci_nproc) err += fprintf(stderr, "ARMCI_Gpc_exec: Invalid target processor id %d\n", p, armci_nproc); if(err) return FAIL; if(rhlen + rdlen == 0) armci_die("Zero reply header + data length not yet supported", 0); if(nbh) nbh->proc = p; #if 1 if(SAMECLUSNODE(p) && armci_nproc==1) { int rhsize, rdsize; int (*func)(); /* fprintf(stderr, "%d:: armci gpc exec. SAMECLUSNODE\n", armci_me); */ func = _table[hnd]; if(func(p, armci_me, hdr, hlen, data, dlen, rhdr, rhlen, &rhsize, rdata, rdlen, &rdsize, GPC_INIT) != GPC_DONE) { func(p, armci_me, hdr, hlen, data, dlen, rhdr, rhlen, &rhsize, rdata, rdlen, &rdsize, GPC_WAIT); } #ifndef VAPI PARMCI_Fence(p); #endif return 0; } #endif /* fprintf(stderr, "%d:: armci gpc exec. invoking armci gpc\n", armci_me); */ return armci_gpc(h, p, hdr, hlen, data, dlen, rhdr, rhlen, rdata, rdlen, ahdl); }
void ARMCI_Gpc_test(gpc_hdl_t *nbh) { if(SAMECLUSNODE(nbh->proc)) return; PARMCI_Test(&nbh->ahdl); }
int armci_domain_same_id (armci_domain_t domain, int proc) { int rc = SAMECLUSNODE(proc); return(rc); }
void ARMCI_Gpc_wait(gpc_hdl_t *nbh) { if(SAMECLUSNODE(nbh->proc)) return; ARMCI_Wait(&nbh->ahdl); }