root/examples/oshmem_max_reduction.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  * reduce [0,1,2] + _my_pe() across 4 PEs with MAX()
  11  */
  12 
  13 #include <stdio.h>
  14 #include <string.h>
  15 
  16 #include <shmem.h>
  17 
  18 long pSync[_SHMEM_BCAST_SYNC_SIZE];
  19 
  20 #define N 3
  21 
  22 long src[N];
  23 long dst[N];
  24 long pWrk[_SHMEM_REDUCE_SYNC_SIZE];
  25 
  26 int  main(void)
  27 {
  28     int i;
  29     int my_pe, num_pes;
  30 
  31     for (i = 0; i < SHMEM_BCAST_SYNC_SIZE; i += 1) {
  32         pSync[i] = _SHMEM_SYNC_VALUE;
  33     }
  34 
  35     shmem_init();
  36 
  37     my_pe = shmem_my_pe();
  38     num_pes = shmem_n_pes();
  39 
  40     for (i = 0; i < N; i += 1) {
  41         src[i] = my_pe + i;
  42     }
  43 
  44     shmem_barrier_all();
  45 
  46     shmem_long_max_to_all(dst, src, N, 0, 0, num_pes, pWrk, pSync);
  47 
  48     printf("%d/%d dst =", my_pe, num_pes);
  49 
  50     for (i = 0; i < N; i+= 1) {
  51         printf(" %ld", dst[i]);
  52     }
  53 
  54     printf("\n");
  55     shmem_finalize();
  56 
  57     return 0;
  58 }
  59 

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