root/examples/oshmem_strided_puts.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  * This program is an adaptation of examples found in the man pages
  11  * of SGI’s SHMEM implementation.
  12  *
  13  * In this program, iput is used to select 5 elements from array source separated by
  14  * a stride of 2 and write them to array target using a stride of 1.
  15  *
  16  * Given the array source = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
  17  * iput will select 5 elements from array source on PE 0, using a stride of 2:
  18  *
  19  * selected elements = { 1, 3, 5, 7, 9 }
  20  *
  21  * These elements will then be written to the array source on PE 1 using a stride of 1:
  22  *
  23  * target = { 1, 3, 5, 7, 9 }
  24  *
  25  */
  26 
  27 #include <stdio.h>
  28 #include <shmem.h>
  29 
  30 int main(void)
  31 {
  32     short source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
  33     static short target[10];
  34     int me;
  35 
  36     shmem_init();
  37     me = shmem_my_pe();
  38 
  39     if (me == 0) {
  40         /* put 10 words into target on PE 1 */
  41         shmem_short_iput(target, source, 1, 2, 5, 1);
  42     }
  43 
  44     shmem_barrier_all(); /* sync sender and receiver */
  45 
  46     if (me == 1) {
  47         printf("target on PE %d is %hd %hd %hd %hd %hd\n", me,
  48         target[0], target[1], target[2],
  49         target[3], target[4] );
  50     }
  51     shmem_barrier_all(); /* sync before exiting */
  52     shmem_finalize();
  53 
  54     return 0;
  55 }

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