int main() { int me, npes; setbuf(stdout, NULL); shmem_init(); me = shmem_my_pe(); npes = shmem_n_pes(); if (me == 0) { int i; for (i = 1; i < npes; i += 1) { printf("From %d: PE %d is ", me, i); printf("%s", shmem_pe_accessible(i) ? "" : "NOT "); printf("accessible\n"); } } else { ; } shmem_finalize(); return 0; }
int main(int argc, char* argv[]) { int me, npes; setbuf(stdout, NULL); start_pes(0); me = _my_pe(); npes = _num_pes(); if (me == 0) { int i; int verbose = (NULL == getenv("MAKELEVEL")) ? 1 : 0; for (i = 1; i < npes; i += 1) { if (verbose) { printf("From %d: PE %d is ", me, i); printf("%s", shmem_pe_accessible(i) ? "" : "NOT "); printf("accessible\n"); } if (! shmem_pe_accessible(i)) return 1; } } return 0; }
int main(void) { int me, npes; setbuf(stdout, NULL); start_pes(0); me = _my_pe(); npes = _num_pes(); if (me == 0) { int i; for (i = 1; i < npes; i += 1) { printf("From %d: PE %d is ", me, i); printf("%s", shmem_pe_accessible(i) ? "" : "NOT "); printf("accessible\n"); } } return 0; }
int FORTRANIFY (shmem_pe_accessible) (int *pe) { return shmem_pe_accessible (*pe); }
int main(int argc, char* argv[]) { int c, j, loops, k, l; int my_pe, nProcs, nWorkers; int nWords=1; int failures=0; char *prog_name; long *wp,work_sz; for(j=0; j < SHMEM_BARRIER_SYNC_SIZE; j++) { pSync0[j] = pSync1[j] = pSync2[j] = pSync3[j] = pSync4[j] = SHMEM_SYNC_VALUE; } shmem_init(); my_pe = shmem_my_pe(); nProcs = shmem_n_pes(); nWorkers = nProcs - 1; if (nProcs == 1) { Rfprintf(stderr, "ERR - Requires > 1 PEs\n"); shmem_finalize(); return 0; } for(j=0; j < nProcs; j++) if ( shmem_pe_accessible(j) != 1 ) { fprintf(stderr, "ERR - pe %d not accessible from pe %d\n", j, my_pe); } prog_name = strrchr(argv[0],'/'); if ( prog_name ) prog_name++; else prog_name = argv[0]; while((c=getopt(argc,argv,"hvM:s")) != -1) { switch(c) { case 's': Slow++; break; case 'v': Verbose++; break; case 'M': output_mod = atoi(optarg); if (output_mod <= 0) { Rfprintf(stderr, "ERR - output modulo arg out of " "bounds '%d'?\n", output_mod); shmem_finalize(); return 1; } Rfprintf(stderr,"%s: output modulo %d\n", prog_name,output_mod); break; case 'h': Rfprintf(stderr, "usage: %s {nWords-2-put(%d)K/M} {Loop-count(%d)K/M}\n", prog_name, DFLT_NWORDS, DFLT_LOOPS); shmem_finalize(); return 1; default: shmem_finalize(); return 1; } } if (optind == argc) nWords = DFLT_NWORDS; else { nWords = atoi_scaled(argv[optind++]); if (nWords <= 0) { Rfprintf(stderr, "ERR - Bad nWords arg '%d'?\n", nWords); shmem_finalize(); return 1; } } if (optind == argc) loops = DFLT_LOOPS; else { loops = atoi_scaled(argv[optind++]); if (loops <= 0 || loops > 1000000) { Rfprintf(stderr, "ERR - loops arg out of bounds '%d'?\n", loops); shmem_finalize(); return 1; } } work_sz = (nProcs*nWords) * sizeof(long); work = shmem_malloc( work_sz ); if ( !work ) { fprintf(stderr,"[%d] ERR - work = shmem_malloc(%ld) ?\n",my_pe,work_sz); shmem_global_exit(1); } Target = shmem_malloc( 2 * nWords * sizeof(long) ); if ( !Target ) { fprintf(stderr,"[%d] ERR - Target = shmem_malloc(%ld) ?\n", my_pe, (nWords * sizeof(long))); shmem_global_exit(1); } src = &Target[nWords]; #if _DEBUG Rprintf("%s: %d loops of %d longs per put\n",prog_name,loops,nWords); #endif for(j=0; j < nWords; j++) src[j] = VAL; for(j=0; j < loops; j++) { #if _DEBUG if ( Verbose && (j==0 || (j % output_mod) == 0) ) fprintf(stderr,"[%d] +(%d)\n", my_pe,j); #endif shmem_barrier(0, 0, nProcs, pSync0); if ( my_pe == 0 ) { int p; for(p=1; p < nProcs; p++) shmem_long_put(Target, src, nWords, p); } else { if (Slow) { /* wait for each put to complete */ for(k=0; k < nWords; k++) shmem_wait(&Target[k],my_pe); } else { /* wait for last word to be written */ shmem_wait(&Target[nWords-1],my_pe); } } #if _DEBUG if ( Verbose && (j==0 || (j % output_mod) == 0) ) fprintf(stderr,"[%d] -(%d)\n", shmem_my_pe(),j); #endif shmem_barrier(0, 0, nProcs, pSync1); RDprintf("Workers[1 ... %d] verify Target data put by proc0\n", nWorkers); /* workers verify put data is expected */ if ( my_pe != 0 ) { for(k=0; k < nWords; k++) { if (Target[k] != VAL) { fprintf(stderr, "[%d] Target[%d] %#lx " "!= %#x?\n", my_pe,k,Target[k],VAL); failures++; } assert(Target[k] == VAL); Target[k] = my_pe; } } else /* clear results buffer, workers will put here */ memset(work, 0, work_sz); shmem_barrier(0, 0, nProcs, pSync2); RDprintf("Workers[1 ... %d] put Target data to PE0 work " "vector\n",nWorkers); if ( my_pe != 0 ) { /* push nWords of val my_pe back to PE zero */ shmem_long_put(&work[my_pe * nWords], Target, nWords, 0); } else { /* wait for procs 1 ... nProcs to complete put()s */ for(l=1; l < nProcs; l++) { wp = &work[ l*nWords ]; // procs nWords chunk #if 1 /* wait for last long to be written from each PE */ shmem_wait(&wp[nWords-1],0); #else for(k=0; k < nWords; k++) shmem_wait(&wp[k],0); #endif } } shmem_barrier(0, 0, nProcs, pSync3); if ( my_pe == 0 ) { RDprintf("Loop(%d) PE0 verifing work data.\n",j); for(l=1; l < nProcs; l++) { wp = &work[ l*nWords ]; // procs nWords chunk for(k=0; k < nWords; k++) { if (wp[k] != l) { fprintf(stderr, "[0] PE(%d)_work[%d] %ld " "!= %d?\n", l,k,work[k],l); failures++; } assert(wp[k] == l); break; } if (failures) break; } } shmem_barrier(0, 0, nProcs, pSync4); #if _DEBUG if (loops > 1) { Rfprintf(stderr,"."); RDprintf("Loop(%d) Pass.\n",j); } #endif } shmem_free( work ); shmem_free( Target ); #if _DEBUG Rfprintf(stderr,"\n");fflush(stderr); shmem_barrier_all(); RDprintf("%d(%d) Exit(%d)\n", my_pe, nProcs, failures); #endif shmem_finalize(); return failures; }
int main (int argc, char *argv[]) { long local_dest; int *shm_dest; int me, npes, i; int pe_acc_success = 0; int fail_count = 0; shmem_init (); me = shmem_my_pe (); npes = shmem_n_pes (); shm_dest = (int *) shmem_malloc (sizeof (int)); shmem_barrier_all (); if (me == 0) { if (!check_it (&global_dest)) { /* long global: yes */ printf ("Test Global Address Accessible: Failed\n"); fail_count++; } else { printf ("Test Global Address Accessible: Passed\n"); } if (!check_it (&static_dest)) { /* static int global: yes */ printf ("Test Static Global Address Accessible: Failed\n"); fail_count++; } else { printf ("Test Static Global Address Accessible: Passed\n"); } if (check_it (&local_dest)) { /* main() stack: no */ printf ("Test Stack Address Accessible: Failed\n"); fail_count++; } else { printf ("Test Stack Address Accessible: Passed\n"); } if (!check_it (shm_dest)) { /* shmem_malloc: yes */ printf ("Test Shmalloc-ed Address Accessible: Failed\n"); fail_count++; } else { printf ("Test Shmalloc-ed Address Accessible: Passed\n"); } for (i = 1; i < npes; i++) { if (shmem_pe_accessible (i) != 1) { pe_acc_success = 1; } } if (pe_acc_success == 1) { printf ("Test shmem_pe_accessible: Failed\n"); fail_count++; } else { printf ("Test shmem_pe_accessible: Passed\n"); } if (fail_count == 0) printf("All Tests Passed\n"); else printf("%d Tests Failed\n", fail_count); } shmem_free (shm_dest); shmem_finalize (); return 0; }