00001
00002
00003
00004
00005 #include "armci_impl.h"
00006
00007
00008
00009 int armci_nproc;
00010
00011
00012
00013
00014
00015 CLINKAGE int ARMCI_Init(void) {
00016 TCHARM_API_TRACE("ARMCI_Init", "armci");
00017 if (TCHARM_Element()==0) {
00018 CkArrayID threadsAID;
00019 int nChunks;
00020 CkArrayOptions opts = TCHARM_Attach_start(&threadsAID, &nChunks);
00021 CkArrayID aid = CProxy_ArmciVirtualProcessor::ckNew(threadsAID, opts);
00022 CProxy_ArmciVirtualProcessor vpProxy = CProxy_ArmciVirtualProcessor(aid);
00023 }
00024
00025 ArmciVirtualProcessor *vp=(ArmciVirtualProcessor *)
00026 TCharm::get()->semaGet(ARMCI_TCHARM_SEMAID);
00027 return 0;
00028 }
00029
00030 CLINKAGE int ARMCI_Finalize(void) {
00031 TCHARM_API_TRACE("ARMCI_Finalize", "armci");
00032 TCHARM_Done(0);
00033 return 0;
00034 }
00035
00036 CLINKAGE void ARMCI_Cleanup(void) {
00037 TCHARM_API_TRACE("ARMCI_Cleanup", "armci");
00038 }
00039
00040 CLINKAGE void ARMCI_Error(char *message, int code) {
00041 TCHARM_API_TRACE("ARMCI_Error", "armci");
00042 ckerr << "armci error: " << message << " | code = " << code << endl;
00043 }
00044
00045
00046 CLINKAGE int ARMCI_Procs(int *procs){
00047 TCHARM_API_TRACE("ARMCI_Procs", "armci");
00048 *procs = TCHARM_Num_elements();
00049 return 0;
00050 }
00051 CLINKAGE int ARMCI_Myid(int *myid){
00052 TCHARM_API_TRACE("ARMCI_Myid", "armci");
00053 *myid = TCHARM_Element();
00054 return 0;
00055 }
00056
00057 CLINKAGE int ARMCI_GetV(
00058 armci_giov_t darr[],
00059 int len,
00060 int proc
00061 ){
00062 return 0;
00063 }
00064
00065 CLINKAGE int ARMCI_NbGetV(
00066 armci_giov_t *dsrc_arr,
00067 int arr_len,
00068 int proc,
00069 armci_hdl_t* handle
00070 ){
00071 return 0;
00072 }
00073
00074 CLINKAGE int ARMCI_PutV(
00075 armci_giov_t darr[],
00076 int len,
00077 int proc
00078 ){
00079 return 0;
00080 }
00081
00082 CLINKAGE int ARMCI_NbPutV(
00083 armci_giov_t *dsrc_arr,
00084 int arr_len,
00085 int proc,
00086 armci_hdl_t* handle
00087 ){
00088 return 0;
00089 }
00090
00091 CLINKAGE int ARMCI_AccV(
00092 int op,
00093 void *scale,
00094 armci_giov_t darr[],
00095 int len,
00096 int proc
00097 ){
00098 return 0;
00099 }
00100
00101 CLINKAGE int ARMCI_NbAccV(
00102 int datatype,
00103 void *scale,
00104 armci_giov_t *dsrc_arr,
00105 int arr_len,
00106 int proc,
00107 armci_hdl_t* handle
00108 ){
00109 return 0;
00110 }
00111
00112
00113 CLINKAGE int ARMCI_Put(void *src, void *dst, int bytes, int proc) {
00114 TCHARM_API_TRACE("ARMCI_Put", "armci");
00115 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00116 vp->put(src, dst, bytes, proc);
00117 return 0;
00118 }
00119
00120 CLINKAGE int ARMCI_NbPut(void *src, void* dst, int bytes, int proc, armci_hdl_t *handle){
00121 TCHARM_API_TRACE("ARMCI_NbPut", "armci");
00122 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00123 if (handle != NULL) {
00124 *handle = vp->nbput(src, dst, bytes, proc);
00125 } else {
00126 vp->nbput_implicit(src, dst, bytes, proc);
00127 }
00128 return 0;
00129 }
00130
00131
00132 CLINKAGE int ARMCI_Get(void *src, void *dst, int bytes, int proc) {
00133 TCHARM_API_TRACE("ARMCI_Get", "armci");
00134 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00135 vp->get(src, dst, bytes, proc);
00136 return 0;
00137 }
00138
00139 CLINKAGE int ARMCI_NbGet(void *src, void* dst, int bytes, int proc, armci_hdl_t *handle){
00140 TCHARM_API_TRACE("ARMCI_NbGet", "armci");
00141 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00142 if (handle != NULL) {
00143 *handle = vp->nbget(src, dst, bytes, proc);
00144 } else {
00145 vp->nbget_implicit(src, dst, bytes, proc);
00146 }
00147 return 0;
00148 }
00149
00150 CLINKAGE int ARMCI_Acc(int datatype, void *scale, void* src, void* dst, int bytes, int proc){
00151 return 0;
00152 }
00153
00154 CLINKAGE int ARMCI_NbAcc(int datatype, void *scale, void* src, void* dst, int bytes, int proc, armci_hdl_t* handle) {
00155 return 0;
00156 }
00157
00158
00159 CLINKAGE int ARMCI_PutS(void *src_ptr, int src_stride_ar[],
00160 void *dst_ptr, int dst_stride_ar[],
00161 int count[], int stride_levels, int proc) {
00162 TCHARM_API_TRACE("ARMCI_PutS", "armci");
00163 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00164 vp->puts(src_ptr, src_stride_ar, dst_ptr, dst_stride_ar, count, stride_levels, proc);
00165 return 0;
00166 }
00167
00168 CLINKAGE int ARMCI_NbPutS(
00169 void *src_ptr,
00170 int src_stride_ar[],
00171 void* dst_ptr,
00172 int dst_stride_ar[],
00173 int count[],
00174
00175 int stride_levels,
00176 int proc,
00177 armci_hdl_t *handle
00178
00179
00180
00181
00182
00183 ){
00184 TCHARM_API_TRACE("ARMCI_NbPutS", "armci");
00185 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00186 if (handle != NULL) {
00187 *handle = vp->nbputs(src_ptr, src_stride_ar, dst_ptr, dst_stride_ar,
00188 count, stride_levels, proc);
00189 } else {
00190 vp->nbputs_implicit(src_ptr, src_stride_ar, dst_ptr, dst_stride_ar,
00191 count, stride_levels, proc);
00192 }
00193 return 0;
00194 }
00195
00196 CLINKAGE int ARMCI_GetS(
00197 void *src_ptr,
00198 int src_stride_ar[],
00199 void* dst_ptr,
00200 int dst_stride_ar[],
00201 int count[],
00202
00203 int stride_levels,
00204 int proc
00205 ){
00206 TCHARM_API_TRACE("ARMCI_GetS", "armci");
00207 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00208 vp->gets(src_ptr, src_stride_ar, dst_ptr, dst_stride_ar, count, stride_levels, proc);
00209 return 0;
00210 }
00211
00212 CLINKAGE int ARMCI_NbGetS(
00213 void *src_ptr,
00214 int src_stride_ar[],
00215 void* dst_ptr,
00216 int dst_stride_ar[],
00217 int count[],
00218
00219 int stride_levels,
00220 int proc,
00221 armci_hdl_t *handle
00222
00223
00224
00225
00226
00227 ){
00228 TCHARM_API_TRACE("ARMCI_NbGetS", "armci");
00229 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00230 if (handle != NULL) {
00231 *handle = vp->nbgets(src_ptr, src_stride_ar, dst_ptr, dst_stride_ar,
00232 count, stride_levels, proc);
00233 } else {
00234 vp->nbgets_implicit(src_ptr, src_stride_ar, dst_ptr, dst_stride_ar,
00235 count, stride_levels, proc);
00236 }
00237 return 0;
00238 }
00239
00240 CLINKAGE int ARMCI_AccS(
00241 int optype,
00242 void *scale,
00243 void *src_ptr,
00244 int src_stride_arr[],
00245 void* dst_ptr,
00246 int dst_stride_arr[],
00247 int count[],
00248
00249 int stride_levels,
00250 int proc
00251 ){
00252 return 0;
00253 }
00254
00255 CLINKAGE int ARMCI_NbAccS(
00256 int optype,
00257 void *scale,
00258 void *src_ptr,
00259 int src_stride_arr[],
00260 void* dst_ptr,
00261 int dst_stride_arr[],
00262 int count[],
00263
00264 int stride_levels,
00265 int proc,
00266 armci_hdl_t *handle
00267
00268
00269
00270
00271
00272 ){
00273 return 0;
00274 }
00275
00276 CLINKAGE int ARMCI_PutValueLong(long src, void* dst, int proc) { return 0; }
00277 CLINKAGE int ARMCI_PutValueInt(int src, void* dst, int proc) { return 0; }
00278 CLINKAGE int ARMCI_PutValueFloat(float src, void* dst, int proc) { return 0; }
00279 CLINKAGE int ARMCI_PutValueDouble(double src, void* dst, int proc) { return 0; }
00280 CLINKAGE int ARMCI_NbPutValueLong(long src, void* dst, int proc, armci_hdl_t* handle) { return 0; }
00281 CLINKAGE int ARMCI_NbPutValueInt(int src, void* dst, int proc, armci_hdl_t* handle) { return 0; }
00282 CLINKAGE int ARMCI_NbPutValueFloat(float src, void* dst, int proc, armci_hdl_t* handle) { return 0; }
00283 CLINKAGE int ARMCI_NbPutValueDouble(double src, void* dst, int proc, armci_hdl_t* handle) { return 0; }
00284 CLINKAGE long ARMCI_GetValueLong(void *src, int proc) { return 0; }
00285 CLINKAGE int ARMCI_GetValueInt(void *src, int proc) { return 0; }
00286 CLINKAGE float ARMCI_GetValueFloat(void *src, int proc) { return 0.0; }
00287 CLINKAGE double ARMCI_GetValueDouble(void *src, int proc) { return 0.0; }
00288 CLINKAGE long ARMCI_NbGetValueLong(void *src, int proc, armci_hdl_t* handle) { return 0; }
00289 CLINKAGE int ARMCI_NbGetValueInt(void *src, int proc, armci_hdl_t* handle) { return 0; }
00290 CLINKAGE float ARMCI_NbGetValueFloat(void *src, int proc, armci_hdl_t* handle) { return 0.0; }
00291 CLINKAGE double ARMCI_NbGetValueDouble(void *src, int proc, armci_hdl_t* handle) { return 0.0; }
00292
00293
00294 CLINKAGE int ARMCI_Wait(armci_hdl_t *handle){
00295 TCHARM_API_TRACE("ARMCI_Wait", "armci");
00296 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00297 if (handle != NULL) {
00298 vp->wait(*handle);
00299 } else {
00300 CmiAbort("ARMCI ERROR: Cannot pass NULL to ARMCI_Wait\n");
00301 }
00302 return 0;
00303 }
00304
00305 CLINKAGE int ARMCI_WaitProc(int proc){
00306 TCHARM_API_TRACE("ARMCI_WaitProc", "armci");
00307 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00308 vp->waitproc(proc);
00309 return 0;
00310 }
00311
00312 CLINKAGE int ARMCI_WaitAll(){
00313 TCHARM_API_TRACE("ARMCI_WaitAll", "armci");
00314 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00315 vp->waitall();
00316 return 0;
00317 }
00318
00319 CLINKAGE int ARMCI_Test(armci_hdl_t *handle){
00320 TCHARM_API_TRACE("ARMCI_Test", "armci");
00321 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00322 if(vp->test(*handle))
00323 return 0;
00324 else
00325 return 1;
00326 }
00327
00328 CLINKAGE int ARMCI_Barrier(){
00329 TCHARM_API_TRACE("ARMCI_Barrier", "armci");
00330 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00331 vp->barrier();
00332 return 0;
00333 }
00334
00335
00336 CLINKAGE int ARMCI_Fence(int proc) {
00337 TCHARM_API_TRACE("ARMCI_Fence", "armci");
00338 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00339 vp->fence(proc);
00340 return 0;
00341 }
00342
00343 CLINKAGE int ARMCI_AllFence(void) {
00344 TCHARM_API_TRACE("ARMCI_AllFence", "armci");
00345 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00346 vp->allfence();
00347 return 0;
00348 }
00349
00350
00351
00352
00353
00354 CLINKAGE int ARMCI_Malloc(void *ptr_arr[], armci_size_t bytes) {
00355 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00356
00357 pointer ptr = vp->BlockMalloc(bytes);
00358
00359 TCHARM_API_TRACE("ARMCI_Malloc", "armci");
00360 vp->requestAddresses(ptr, ptr_arr, bytes);
00361 return 0;
00362 }
00363
00364
00365
00366
00367 CLINKAGE int ARMCI_Free(void *address) {
00368 CmiIsomallocBlockListFree(address);
00369
00370 TCHARM_API_TRACE("ARMCI_Free", "armci");
00371 return 0;
00372 }
00373 CLINKAGE void *ARMCI_Malloc_local(armci_size_t bytes){
00374 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00375 pointer ptr = vp->BlockMalloc(bytes);
00376 TCHARM_API_TRACE("ARMCI_Malloc_local", "armci");
00377
00378 return ptr;
00379 }
00380
00381 CLINKAGE int ARMCI_Free_local(void *ptr){
00382 CmiIsomallocBlockListFree(ptr);
00383 TCHARM_API_TRACE("ARMCI_Free_local", "armci");
00384
00385 return 0;
00386 }
00387
00388 CLINKAGE void ARMCI_SET_AGGREGATE_HANDLE (armci_hdl_t* handle) { }
00389 CLINKAGE void ARMCI_UNSET_AGGREGATE_HANDLE (armci_hdl_t* handle) { }
00390
00391 CLINKAGE int ARMCI_Rmw(int op, int *ploc, int *prem, int extra, int proc){
00392 return 0;
00393 }
00394
00395 CLINKAGE int ARMCI_Create_mutexes(int num){
00396 return 0;
00397 }
00398 CLINKAGE int ARMCI_Destroy_mutexes(void){
00399 return 0;
00400 }
00401 CLINKAGE void ARMCI_Lock(int mutex, int proc){
00402 }
00403 CLINKAGE void ARMCI_Unlock(int mutex, int proc){
00404 }
00405
00406 CLINKAGE int armci_notify(int proc){
00407 TCHARM_API_TRACE("armci_notify", "armci");
00408 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00409 vp->notify(proc);
00410 return 0;
00411 }
00412
00413 CLINKAGE int armci_notify_wait(int proc, int *pval){
00414 TCHARM_API_TRACE("armci_notify_wait", "armci");
00415 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00416 vp->notify_wait(proc);
00417 return 0;
00418 }
00419
00420
00421
00422 CLINKAGE void armci_msg_brdcst(void *buffer, int len, int root) {
00423 armci_msg_bcast(buffer, len, root);
00424 }
00425
00426 CLINKAGE void armci_msg_bcast(void *buffer, int len, int root) {
00427 TCHARM_API_TRACE("armci_msg_bcast", "armci");
00428 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00429 vp->msgBcast(buffer, len, root);
00430 }
00431
00432
00433 CLINKAGE void armci_msg_gop2(void *x, int n, int type, char *op) {
00434 }
00435
00436 CLINKAGE void armci_msg_igop(int *x, int n, char *op) {
00437 TCHARM_API_TRACE("armci_msg_dgop", "armci");
00438 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00439 vp->msgGop(x, n, op, ARMCI_INT);
00440 }
00441
00442 CLINKAGE void armci_msg_lgop(CmiInt8 *x, int n, char *op) {
00443 TCHARM_API_TRACE("armci_msg_lgop", "armci");
00444 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00445 vp->msgGop(x, n, op, ARMCI_LONG);
00446 }
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456 CLINKAGE void armci_msg_fgop(float *x, int n, char *op) {
00457 TCHARM_API_TRACE("armci_msg_fgop", "armci");
00458 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00459 vp->msgGop(x, n, op, ARMCI_FLOAT);
00460 }
00461
00462 CLINKAGE void armci_msg_dgop(double *x, int n, char *op) {
00463 TCHARM_API_TRACE("armci_msg_dgop", "armci");
00464 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00465 vp->msgGop(x, n, op, ARMCI_DOUBLE);
00466 }
00467
00468 CLINKAGE void armci_msg_barrier(void) {
00469 }
00470
00471 CLINKAGE void armci_msg_reduce(void *x, int n, char *op, int type) {
00472 }
00473
00474
00475
00476 CLINKAGE int armci_domain_nprocs(armci_domain_t domain, int id) {
00477 return -1;
00478 }
00479
00480 CLINKAGE int armci_domain_count(armci_domain_t domain) {
00481 return -1;
00482 }
00483
00484 CLINKAGE int armci_domain_id(armci_domain_t domain, int glob_proc_id) {
00485 return -1;
00486 }
00487
00488 CLINKAGE int armci_domain_glob_proc_id(armci_domain_t domain, int id,
00489 int loc_proc_id) {
00490 return -1;
00491 }
00492
00493 CLINKAGE int armci_domain_my_id(armci_domain_t domain) {
00494 return -1;
00495 }
00496
00497
00498
00499
00500 CLINKAGE void ARMCI_Migrate(void){
00501 TCHARM_API_TRACE("ARMCI_Migrate", "armci");
00502 TCHARM_Migrate();
00503 }
00504 CLINKAGE void ARMCI_Async_Migrate(void){
00505 TCHARM_API_TRACE("ARMCI_Async_Migrate", "armci");
00506 TCHARM_Async_Migrate();
00507 }
00508 CLINKAGE void ARMCI_Checkpoint(char* dname){
00509 TCHARM_API_TRACE("ARMCI_Checkpoint", "armci");
00510 ARMCI_Barrier();
00511 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00512 vp->startCheckpoint(dname);
00513 }
00514 CLINKAGE void ARMCI_MemCheckpoint(void){
00515 TCHARM_API_TRACE("ARMCI_MemCheckpoint", "armci");
00516 ARMCI_Barrier();
00517 ArmciVirtualProcessor *vp = CtvAccess(_armci_ptr);
00518 vp->startCheckpoint("");
00519 }
00520