Example #1
0
int
main(int argc, char* argv[])
{
    int i;
    for(i = 0; i < N_THREADS*N_ELEMS; ++i) {
        source[i] = i+1;
    }

    int tl_expected = SHMEMX_THREAD_MULTIPLE;
    int tl;

    shmemx_init_thread(tl_expected,&tl);

    if (tl_expected != tl) {
        printf("Could not initialize with desired thread level (%d "
               "requested, got %d)\n", tl_expected, tl);
        return 0;
    }

    if (shmem_n_pes() == 1) {
        printf("%s: Requires number of PEs > 1\n", argv[0]);
        shmem_finalize();
        return 0;
    }

    pthread_t threads[N_THREADS];

    pthread_barrier_init(&fencebar,NULL,N_THREADS);

    fprintf(stderr,"Starting threads\n");
    for(i = 0; i < N_THREADS; ++i) {
        /* fprintf(stderr,"Starting thread %d\n",i); */
        ptrdiff_t tid = i;
        pthread_create(&threads[i],NULL,&roundrobin,(void*)tid);
    }

    for(i = 0; i < N_THREADS; ++i) {
        pthread_join(threads[i],NULL);
    }
    pthread_barrier_destroy(&fencebar);

    if (0 != memcmp(source, target, sizeof(long) * N_THREADS*N_ELEMS)) {
        fprintf(stderr,"[%d] Src & Target mismatch?\n",shmem_my_pe());
        for (i = 0 ; i < 10 ; ++i) {
            printf("%ld,%ld ", source[i], target[i]);
        }
        printf("\n");
        shmem_global_exit(1);
    }

    shmem_finalize();

    return 0;
}
Example #2
0
File: get_nbi.c Project: caomw/SOS
int
main(int argc, char* argv[])
{
    int i, j, num_pes;
    int failed = 0;

    shmem_init();

    if (shmem_my_pe() == 0) {
        num_pes=shmem_n_pes();

        for(j = 0; j < num_pes; j++) {
            memset(target, 0, sizeof(long) * 10);
            shmem_long_get_nbi(target, source, 10, j);
            shmem_quiet();

            for (i = 0; i < 10; i++) {
                if (source[i] != target[i]) {
                    fprintf(stderr,"[%d] get_nbi from PE %d: target[%d] = %ld, expected %ld\n",
                            shmem_my_pe(), j, i, target[i], source[i]);
                    failed = 1;
                }
            }

            if (failed)
                shmem_global_exit(1);
        }
    }

    shmem_finalize();

    return 0;
}
Example #3
0
int
main(void)
{
    double *f;
    int me;

    shmem_init();
    me = shmem_my_pe();

    f = (double *) shmem_malloc(sizeof(*f));

    *f = PI;
    shmem_barrier_all();

    if (me == 0) {
        shmem_double_p(f, E, 1);
    }

    shmem_barrier_all();


    if (me == 1) {
        printf("PE %d: %f, %s\n",
               me, *f, (fabs(*f - E) < epsilon) ? "OK" : "FAIL");
    }

    shmem_free(f);

    shmem_finalize();

    return 0;
}
void swapnum(int i, int j){
    int temp = i;
    i = j;
    j = temp;
    //  start_pes(1);
    shmem_finalize();
}
Example #5
0
int  main(void)
{
    int i;
    int my_pe, num_pes;

    for (i = 0; i < SHMEM_BCAST_SYNC_SIZE; i += 1) {
        pSync[i] = _SHMEM_SYNC_VALUE;
    }

    shmem_init();

    my_pe = shmem_my_pe();
    num_pes = shmem_n_pes();

    for (i = 0; i < N; i += 1) {
        src[i] = my_pe + i;
    }

    shmem_barrier_all();

    shmem_long_max_to_all(dst, src, N, 0, 0, num_pes, pWrk, pSync);

    printf("%d/%d dst =", my_pe, num_pes);

    for (i = 0; i < N; i+= 1) {
        printf(" %ld", dst[i]);
    }

    printf("\n");
    shmem_finalize();

    return 0;
}
Example #6
0
int main(int argc, char * argv[])
{
	/* Get PE information */
	shmem_init();
	me = _my_pe();
	npes = _num_pes();

	/* Initialize and send on PE 0 */
	if (me == 0) {
		for (i = 0; i < 8; i++)
			src[i] = i + 1;
		/* Put source date at PE 0 to dest at PE 1+ */
		for (i = 1; i < npes; i++)
			shmem_put64(dest, src, 8 * sizeof(int) / 8, i);
	}

	/* Make sure the transfer is complete */
	shmem_barrier_all();

	/* Print from PE 1+ */
	if (me > 0) {
		printf("PE %d: %d", me, dest[0]);
		for (i = 1; i < 8; i++)
			printf(",%d", dest[i]);
		printf("\n");
	}
	shmem_finalize();

	return 0;
}
Example #7
0
int
main ()
{
    int i;

    for (i = 0; i < _SHMEM_REDUCE_SYNC_SIZE; i += 1) {
        pSync[i] = _SHMEM_SYNC_VALUE;
    }

    shmem_init ();

    for (i = 0; i < N; i += 1) {
        src[i] = shmem_my_pe () + i;
    }
    shmem_barrier_all ();

    shmem_long_max_to_all (dst, src, 3, 0, 0, 4, pWrk, pSync);

    printf ("%d/%d   dst =", shmem_my_pe (), shmem_n_pes ());
    for (i = 0; i < N; i += 1) {
        printf (" %ld", dst[i]);
    }
    printf ("\n");

    shmem_finalize ();

    return 0;
}
int
main (int argc, char **argv)
{
    int i;
    int nextpe;
    int me, npes;
    long src[N];
    long *dest;
    shmemx_request_handle_t handle;

    shmem_init ();
    me = shmem_my_pe ();
    npes = shmem_n_pes ();

    for (i = 0; i < N; i += 1) {
        src[i] = (long) me;
    }

    dest = (long *) shmem_malloc (N * sizeof (*dest));

    nextpe = (me + 1) % npes;

    shmemx_long_put_nb (dest, src, N, nextpe, &handle);

    shmemx_wait_req (handle);

    shmem_barrier_all ();

    shmem_free (dest);

    shmem_finalize ();

    return 0;
}
Example #9
0
int
main(void)
{
    long *f;
    int me;

    shmem_init();
    me = shmem_my_pe();

    f = (long *) shmem_malloc(sizeof(*f));

    *f = 3;
    shmem_barrier_all();

    printf("PE %d: before put, f = %ld\n", me, *f);

    if (me == 0) {
        shmem_long_p(f, 42, 1);
    }

    shmem_barrier_all();

    if (me == 1) {
        printf("PE %d:  after put, f = %ld, %s\n", me, *f,
               (*f == 42) ? "OK" : "FAIL");
    }

    shmem_finalize();

    return 0;
}
int
main(void)
{
    int i;

    shmem_init();
    npes = shmem_n_pes();
    me = shmem_my_pe();

    for (i = 0; i < DST_SIZE; i++) {
        dst[i] = -1;
    }

    for (i = 0; i < SHMEM_COLLECT_SYNC_SIZE; i += 1) {
        pSync[i] = SHMEM_SYNC_VALUE;
    }

    shmem_barrier_all();

    shmem_fcollect64(dst, src, 2, 0, 0, npes, pSync);

    shmem_barrier_all();

    show_dst("AFTER");

    shmem_finalize();

    return 0;
}
int main(int argc, char **argv)
{
  const long int ITER_CNT = 100;
  const long int MAX_MSG_SIZE = 1048576;
  int* source_addr;
  int peer;
  long int i=0,j=0, buff_size; 
  long long int start_time, stop_time, res;
  double time;

  shmem_init();

  int pe_id = shmem_my_pe();
  source_addr = (int*) malloc(MAX_MSG_SIZE);

  if(pe_id == 1) {
      if(shmem_n_pes()!=4)
      	fprintf(stderr,"Num PEs should be ==4");
      printf("#Message Cnt;Time(s);MR(msgs/sec)\n");
  }

  if (pe_id==1)
	  peer = 3;
  else if(pe_id==3)
	  peer = 1;
  get_rtc_res_(&res);

  for (i = 0; i < SHMEM_BARRIER_SYNC_SIZE; i += 1){
          pSync[i] = SHMEM_SYNC_VALUE;
  }

  /* Collective operation: Implicit barrier on return from attach */
  shmemx_am_attach(HANDLER_ID_REQ, &sample_req_handler);
  shmem_barrier_all();
  if(pe_id == 1 || pe_id == 3) {

  	for(buff_size=1; buff_size<=MAX_MSG_SIZE; buff_size*=2) {
  	    shmem_barrier(1,1,2,pSync);
  	    get_rtc_(&start_time);
  	    for(j=1;j<=ITER_CNT;j++) {
  	        if(pe_id == 1) {
  	    	    shmemx_am_request(peer, HANDLER_ID_REQ, source_addr, buff_size);
  	            shmemx_am_quiet();
  	        }
  	    }
  	    shmem_barrier(1,1,2,pSync);
  	    get_rtc_(&stop_time);
  	    time = (stop_time - start_time)*1.0/(double)res/ITER_CNT;
  	    if(pe_id == 1) {
  	   	 printf("%20ld;%20.12f;%20.12f\n", 
  	                buff_size, time, (double)buff_size/time);
  	    }
  	    fflush(stdout);
  	}
  }

  shmem_barrier_all();
  shmem_finalize();

}
Example #12
0
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;
}
Example #13
0
int main(int argc, char* argv[]) {
    int verbose = 0;
    if(argc > 1) {
        verbose = !strcmp("-v",argv[1]);
    }

    int errors = 0;

    int me, myshmem_n_pes;
    shmem_init();
    myshmem_n_pes = shmem_n_pes();
    me = shmem_my_pe();

    srand(1+me);

    int nextpe = (me+1)%myshmem_n_pes;

#define RUN_TEST(TYPENAME,TYPE) do { \
        errors += (TYPENAME##_rmaTest(nextpe,verbose)); \
    } while(0)

    SHMEM_DECLARE_FOR_RMA(RUN_TEST);

    shmem_finalize();

    return errors;
}
Example #14
0
int
main(void)
{
    shmem_init();

    shmem_clear_cache_inv();

    shmem_set_cache_inv();

    shmem_clear_cache_line_inv(&var);

    shmem_set_cache_line_inv(&var);

    shmem_udcflush();

    shmem_udcflush_line(&var);

    shmem_clear_cache_inv();

    shmem_set_cache_inv();

    shmem_clear_cache_line_inv(&var);

    shmem_set_cache_line_inv(&var);

    shmem_udcflush();

    shmem_udcflush_line(&var);

    shmem_finalize();

    return 0;
}
int main(int argc, char *argv[])
{
  shmem_init();
  input_file = argv[1];
  mype = shmem_my_pe();
  NumProcs = shmem_n_pes();
  shmemx_am_attach(hid_BESTPATH, &handler_master_bestpath);
  shmemx_am_attach(hid_SUBSCRIBE, &handler_master_subscribe);
  shmemx_am_attach(hid_PUTPATH, &handler_master_putpath);
  shmemx_am_mutex_init(&lock_shortestlen);
  shmemx_am_mutex_init(&lock_queue);
  shmemx_am_mutex_init(&lock_workers_stack);

  if (NumProcs<2) {
    printf("At least 2 processes are required\n");
    exit(-1);
  }  

  
  // Initialize distance matrix. Ususally done by one process 
  // and bcast, or initialized from a file in a shared file system.
  Fill_Dist();  // process 0 read the data and broadcast it to the others

  if (mype==0) 
    Master();
  else
    Worker();
  
  //TODO
//  shmemx_am_detach(hid_BESTPATH);
//  shmemx_am_detach(hid_SUBSCRIBE);
//  shmemx_am_detach(hid_PUTPATH);
  shmem_finalize();
  return 0;
}
Example #16
0
int
main ()
{
    int i;
    int me;
    int npes;

    for (i = 0; i < _SHMEM_REDUCE_SYNC_SIZE; i += 1) {
        pSync[i] = _SHMEM_SYNC_VALUE;
    }

    shmem_init ();
    me = shmem_my_pe ();
    npes = shmem_n_pes ();

    src = me + 1;
    shmem_barrier_all ();

    shmem_int_or_to_all (&dst, &src, 1, 0, 0, npes, pWrk, pSync);

    printf ("%d/%d   dst = %d\n", me, npes, dst);

    shmem_finalize ();

    return 0;
}
Example #17
0
int
main (int argc, char **argv)
{
    int dest;
    int src;
    int me, npes;

    shmem_init ();

    me = shmem_my_pe ();
    npes = shmem_n_pes ();

    src = 42;

    shmem_barrier_all ();

    if (me == 0) {
        shmem_int_put (&dest, &src, 1, 1);
    }

    shmem_barrier_all ();

    shmem_finalize ();

    return 0;
}
Example #18
0
int main(const int argc,  char ** argv)
{
  shmem_init();

  #ifdef EXTRA_STATS
  _timer_t total_time;
  if(shmem_my_pe() == 0) {
    printf("\n-----\nmkdir timedrun fake\n\n");
    timer_start(&total_time);
  }
#endif

  init_shmem_sync_array(pSync); 

  char * log_file = parse_params(argc, argv);

  int err = bucket_sort();

  log_times(log_file);

  #ifdef EXTRA_STATS
  if(shmem_my_pe() == 0) {
    just_timer_stop(&total_time);
    double tTime = ( total_time.stop.tv_sec - total_time.start.tv_sec ) + ( total_time.stop.tv_nsec - total_time.start.tv_nsec )/1E9;
    avg_time *= 1000;
    avg_time_all2all *= 1000;

    printf("\n============================ MMTk Statistics Totals ============================\n");
    if(NUM_ITERATIONS == 1) { //TODO: fix time calculation below for more number of iterations
      printf("time.mu\tt.ATA_KEYS\tt.MAKE_INPUT\tt.COUNT_BUCKET_SIZES\tt.BUCKETIZE\tt.COMPUTE_OFFSETS\tt.LOCAL_SORT\tBARRIER_AT_START\tBARRIER_AT_EXCHANGE\tBARRIER_AT_END\tnWorkers\tnPEs\n");
      double TIMES[TIMER_NTIMERS];
      memset(TIMES, 0x00, sizeof(double) * TIMER_NTIMERS);
      for(int i=0; i<NUM_PES; i++) {
        for(int t = 0; t < TIMER_NTIMERS; ++t){
          if(timers[t].all_times != NULL){
            TIMES[t] += timers[t].all_times[i];
          }
        }
      }
      for(int t = 0; t < TIMER_NTIMERS; ++t){
        printf("%.3f\t", (TIMES[t]/NUM_PES)*1000);
      }
      printf("1\t%d\n",NUM_PES);
      printf("Total time: %.3f\n",(TIMES[0]/NUM_PES)*1000);
    }
    else {
      printf("time.mu\ttimeAll2All\tnWorkers\tnPEs\n");
      printf("%.3f\t%.3f\t1\t%d\n",avg_time,avg_time_all2all,NUM_PES);
      printf("Total time: %.3f\n",avg_time);
    }
    printf("------------------------------ End MMTk Statistics -----------------------------\n");
    printf("===== TEST PASSED in %.3f msec =====\n",(tTime*1000));
  }
#endif

  shmem_finalize();
  return err;
}
Example #19
0
int main(int argc, char *argv[]){
	
		
	int i,next_pivot, pivot;	
	
	
	for (i=0; i < SHMEM_BCAST_SYNC_SIZE; i++) {
 		pSync[i] = _SHMEM_SYNC_VALUE;
		}	
	
	start_pes(0);
	me = shmem_my_pe();
	npes = shmem_n_pes();
	shmem_barrier_all();
	srand (me+time(NULL));

	N = atoi(argv[1]);
	
	//int *nelems = (int*) shmalloc(sizeof(int));

	//int *nelems_import= (int*) shmalloc(sizeof(int));;
	printf("%d: Size = %d with np=%d\n",me,N,npes);
	A = (int *)shmalloc((N/npes)*sizeof(int));
	temp_arr = (int *)shmalloc((2*N/npes)*sizeof(int));
	if(A==NULL){
		printf("\nOut of memory");
		return 1;
	}
	n= N/npes;
	i=0;
	while(i<N/npes){
		A[i] = rand()%(10000-0);
		i++;
	}
	printf("\nprocess %d elements:",me);
	for(i=0;i<(N/npes);i++){
                printf("%d, ", A[i]);
       		}
      
       		
      pivot = quicksort(A, 0, n-1);
     
      printf("Process %d the pivot:%d",me, pivot);
	shmem_barrier_all(); //just for the sake of clear display...can be removed in the end
	printf("\nThe sorted list is of process %d: ",me);
	for(i=0;i<N/npes;i++){
		printf("%d,  ",A[i]);
		}
	printf("\n");
	
	hyperquick(A,N/npes,npes);

	printf("\n");
	
shfree(temp_arr);
shfree(A);
shmem_finalize();
}
int main(int argc, char **argv)
{
  int i,j;
  long modj,oldj,oldxmodj;
  int my_pe,n_pes;
  size_t max_elements,max_elements_bytes;
  static long *x;

  shmem_init();
  my_pe = shmem_my_pe();
  n_pes = shmem_n_pes();
#ifdef HAVE_SET_CACHE_INV
  shmem_set_cache_inv();
#endif

/*  fail if trying to use only one processor  */
  if ( n_pes  <= 1 ){
        fprintf(stderr, "FAIL - test requires at least two PEs\n");
        exit(1);
  }

  if(my_pe == 0)
    fprintf(stderr, "shmem_long_finc(%s) n_pes=%d\n", argv[0],n_pes);

/*  shmalloc x on all pes (only use the one on PE 0)  */

  max_elements_bytes = (size_t) (sizeof(long) * n_pes);
  x = shmem_malloc( max_elements_bytes );
  for(i=0; i<n_pes; i++)
    x[i] = 0;
  count = 0;
  shmem_barrier_all();

  for(i=0; i<ITER; i++) {
    if (my_pe != 0) {
      oldj = shmem_long_finc(&count, 0);  /* get index oldj from PE 0 */
      modj = (oldj % (n_pes-1));  /* PE 0 is just the counter/checker */
        /* increment value in x[modj] */
      oldxmodj = shmem_long_finc(&x[modj], 0); 
      /* printf("PE=%d,oldj=%ld,modj=%ld,oldxmodj=%ld\n",my_pe,oldj,modj,oldxmodj); */
    }
  }
  shmem_barrier_all();

  if (my_pe == 0) {         /* check x[j] array on PE 0 */
    for(j=1 ; j<n_pes; j++) {
      if (x[j-1] != ITER)
        fprintf(stderr, "FAIL PE %d of %d: x[%d] = %ld expected = %ld\n", 
                         my_pe, n_pes, j-1, x[j-1], ITER);
    }
  }

  shmem_barrier_all();
#ifdef NEEDS_FINALIZE
  shmem_finalize(); 
#endif
  return 0;
}
Example #21
0
int
main(int argc, char* argv[], char *envp[])
{
    int me, myshmem_n_pes;
    /*
    ** Starts/Initializes SHMEM/OpenSHMEM
    */
    shmem_init();
    /*
    ** Fetch the number or processes
    ** Some implementations use num_pes();
    */
    myshmem_n_pes = shmem_n_pes();
    /*
    ** Assign my process ID to me
    */
    me = shmem_my_pe();

    srand(1+me);

    for(total = 0; total < NUM_POINTS; ++total) {
        double x,y;
        x = rand()/(double)RAND_MAX;
        y = rand()/(double)RAND_MAX;

        if(x*x + y*y < 1) {
            ++inside;
        }
    }

    shmem_barrier_all();

    int errors = 0;

    if(me == 0) {
        for(int i = 1; i < myshmem_n_pes; ++i) {
            long long remoteInside,remoteTotal;
            shmem_longlong_get(&remoteInside,&inside,1,i);
            shmem_longlong_get(&remoteTotal,&total,1,i);
            total += remoteTotal;
            inside += remoteInside;
        }

        double approx_pi = 4.0*inside/(double)total;

        if(fabs(M_PI-approx_pi) > 0.1) {
            ++errors;
        }

        if (NULL == getenv("MAKELEVEL")) {
            printf("Pi from %llu points on %d PEs: %lf\n",total,myshmem_n_pes,approx_pi);
        }
    }

    shmem_finalize();

    return errors;
}
Example #22
0
File: swap1.c Project: caomw/SOS
int
main(int argc, char* argv[])
{
    long source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    static long target[10] = { 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
    int i, bad = 0;

    shmem_init();

    if (shmem_n_pes() == 1) {
        printf("%s: Requires number of PEs > 1\n", argv[0]);
        shmem_finalize();
        return 0;
    }

    if (shmem_my_pe() == 0) {
        for (i = 0 ; i < 10 ; ++i) {
            source[i] = shmem_long_swap(target + i, source[i], 1);
        }
    }

    shmem_barrier_all();  /* sync sender and receiver */

    if (shmem_my_pe() == 0) {
        for (i = 0 ; i < 10 ; ++i) {
            if (source[i] != i + 11) bad = 1;
        }
    } else if (shmem_my_pe() == 1) {
        for (i = 0 ; i < 10 ; ++i) {
            if (target[i] != i + 1) bad = 1;
        }
    }

    if (bad) {
        fprintf(stderr, "[%02d] error: ", shmem_my_pe());
        for (i = 0 ; i < 10 ; ++i) {
            fprintf(stderr, "%ld ", (shmem_my_pe() == 0) ? source[i] : target[i]);
        }
        fprintf(stderr, "\n");
    }

    shmem_finalize();

    return bad;
}
Example #23
0
int main(int argc, char *argv[])
{
  shmem_init();

  bi_dir_bw_main(argc,argv);

  shmem_finalize();

  return 0;
}  /* end of main() */
Example #24
0
int main(int argc, char *argv[])
{
  shmem_init();

  uni_dir_bw_main(argc, argv);

  shmem_finalize();

  return 0;
}
Example #25
0
int
main(int argc, char* argv[])
{
    short source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    static short target[10];
    int me, num_pes;
    int ret = 0;

    shmem_init();
    me = shmem_my_pe();
    num_pes = shmem_n_pes();

    if (num_pes != 2) {
        printf("%s: Requires 2 PEs\n", argv[0]);
        shmem_finalize();
        return 0;
    }

    if (me == 0) {
        /* put 10 words into target on PE 1 */
        shmem_short_iput(target, source, 1, 2, 5, 1);
    }

    shmem_barrier_all();	/* sync sender and receiver */

    if (me == 1) {
        if (! (target[0] == source[0] &&
               target[1] == source[2] &&
               target[2] == source[4] &&
               target[3] == source[6] &&
               target[4] == source[8])) {
            printf("target on PE %d is %hd %hd %hd %hd %hd\n", me,
                   target[0], target[1], target[2],
                   target[3], target[4] );
            ret = 1;
        }
    }

    shmem_finalize();

    return ret;
}
Example #26
0
int main(int argc, char* argv[]) {
  shmem_init();

  int rc = EXIT_SUCCESS;
  TEST_SHMEM_INC(int);
  TEST_SHMEM_INC(long);
  TEST_SHMEM_INC(long long);

  shmem_finalize();
  return rc;
}
Example #27
0
int main(void)
{
   long source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
   static long dest[10];
   shmem_init();
   int me = shmem_my_pe();
   if (me == 0) /* put 10 words into dest on PE 1 */
      shmem_put(dest, source, 10, 1);
   shmem_barrier_all(); /* sync sender and receiver */
   printf("dest[0] on PE %d is %ld\n", me, dest[0]);
   shmem_finalize();
   return 0;
}
int main(int argc, char* argv[]) {
    shmem_init();

    int rc = EXIT_SUCCESS;
    TEST_SHMEM_FETCH(float);
    TEST_SHMEM_FETCH(double);
    TEST_SHMEM_FETCH(int);
    TEST_SHMEM_FETCH(long);
    TEST_SHMEM_FETCH(long long);

    shmem_finalize();
    return rc;
}
int
main ()
{
    long *x;

    shmem_init ();

    x = (long *) shmem_malloc (sizeof (*x));

    shmem_free (x);

    shmem_finalize ();

    return 0;
}
Example #30
0
int
main(int argc, char* argv[])
{
    int i;

    shmem_init();

    if (shmem_n_pes() == 1) {
        printf("%s: Requires number of PEs > 1\n", argv[0]);
        shmem_finalize();
        return 0;
    }

    if (shmem_my_pe() == 0) {
        memset(target, 0, sizeof(target));
        /* put 10 elements into target on PE 1 */
        shmem_long_get(target, source, 10, 1);
    }

    shmem_barrier_all();  /* sync sender and receiver */

    if (shmem_my_pe() == 0) {
        if (0 != memcmp(source, target, sizeof(long) * 10)) {
            fprintf(stderr,"[%d] Src & Target mismatch?\n",shmem_my_pe());
            for (i = 0 ; i < 10 ; ++i) {
                printf("%ld,%ld ", source[i], target[i]);
            }
            printf("\n");
            shmem_global_exit(1);
        }
    }

    shmem_finalize();

    return 0;
}