2014-04-19 09:03:44 +04:00
|
|
|
/*
|
2016-10-21 09:36:53 +03:00
|
|
|
* Copyright (c) 2014-2016 Mellanox Technologies, Inc.
|
2014-04-19 09:03:44 +04:00
|
|
|
* All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*
|
|
|
|
* reduce [0,1,2] + _my_pe() across 4 PEs with MAX()
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <shmem.h>
|
|
|
|
|
|
|
|
long pSync[_SHMEM_BCAST_SYNC_SIZE];
|
|
|
|
|
|
|
|
#define N 3
|
|
|
|
|
|
|
|
long src[N];
|
|
|
|
long dst[N];
|
|
|
|
long pWrk[_SHMEM_REDUCE_SYNC_SIZE];
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-10-21 09:36:53 +03:00
|
|
|
shmem_init();
|
2014-04-19 09:03:44 +04:00
|
|
|
|
2016-10-21 09:36:53 +03:00
|
|
|
my_pe = shmem_my_pe();
|
|
|
|
num_pes = shmem_n_pes();
|
2014-04-19 09:03:44 +04:00
|
|
|
|
|
|
|
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) {
|
2014-05-22 10:51:28 +04:00
|
|
|
printf(" %ld", dst[i]);
|
2014-04-19 09:03:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n");
|
2016-10-21 09:36:53 +03:00
|
|
|
shmem_finalize();
|
2014-04-19 09:03:44 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|