root/examples/oshmem_symmetric_data.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. main

   1 /*
   2  * Copyright (c) 2014-2016 Mellanox Technologies, Inc.
   3  *                         All rights reserved.
   4  * $COPYRIGHT$
   5  *
   6  * Additional copyrights may follow
   7  *
   8  * $HEADER$
   9  */
  10 
  11 #include <stdio.h>
  12 #include <shmem.h>
  13 
  14 #define SIZE 16
  15 
  16 int main(int argc, char* argv[])
  17 {
  18     short source[SIZE];
  19     static short target[SIZE];
  20     int i;
  21     int num_pe, my_pe;
  22 
  23     shmem_init();
  24 
  25     num_pe = shmem_n_pes();
  26     my_pe = shmem_my_pe();
  27 
  28     if (my_pe == 0) {
  29         /* initialize array */
  30         for(i = 0; i < SIZE; i++) {
  31             source[i] = i;
  32         }
  33         /* local, not symmetric */
  34         /* static makes it symmetric */
  35         /* put "size" words into target on each PE */
  36         for(i = 1; i < num_pe; i++) {
  37             shmem_short_put(target, source, SIZE, i);
  38         }
  39     }
  40 
  41     shmem_barrier_all(); /* sync sender and receiver */
  42 
  43     if (my_pe != 0) {
  44         printf("Target on PE %d is \t", my_pe);
  45 
  46         for(i = 0; i < SIZE; i++) {
  47             printf("%hd \t", target[i]);
  48         }
  49         printf("\n");
  50     }
  51 
  52     shmem_barrier_all(); /* sync before exiting */
  53     shmem_finalize();
  54 
  55     return 0;
  56 }

/* [<][>][^][v][top][bottom][index][help] */