OSHMEM: added bunch of examples according to SPEC 1.0
fixed by Roman, reviewed by Igor/Mike cmr=v1.8.2:reviewer=ompi-rm1.8 This commit was SVN r31449.
Этот коммит содержится в:
родитель
3a8d2a0421
Коммит
daaf1d441d
@ -61,7 +61,13 @@ EXAMPLES = \
|
|||||||
ring_oshmem \
|
ring_oshmem \
|
||||||
ring_oshmemfh \
|
ring_oshmemfh \
|
||||||
Ring.class \
|
Ring.class \
|
||||||
connectivity_c
|
connectivity_c \
|
||||||
|
oshmem_shmalloc \
|
||||||
|
oshmem_circular_shift \
|
||||||
|
oshmem_max_reduction \
|
||||||
|
oshmem_strided_puts \
|
||||||
|
oshmem_symmetric_data
|
||||||
|
|
||||||
|
|
||||||
# Default target. Always build the C MPI examples. Only build the
|
# Default target. Always build the C MPI examples. Only build the
|
||||||
# others if we have the appropriate Open MPI / OpenSHMEM language
|
# others if we have the appropriate Open MPI / OpenSHMEM language
|
||||||
@ -100,6 +106,11 @@ oshmem:
|
|||||||
@ if oshmem_info --parsable | grep oshmem:bindings:c:yes >/dev/null; then \
|
@ if oshmem_info --parsable | grep oshmem:bindings:c:yes >/dev/null; then \
|
||||||
$(MAKE) hello_oshmem; \
|
$(MAKE) hello_oshmem; \
|
||||||
$(MAKE) ring_oshmem; \
|
$(MAKE) ring_oshmem; \
|
||||||
|
$(MAKE) oshmem_shmalloc; \
|
||||||
|
$(MAKE) oshmem_circular_shift; \
|
||||||
|
$(MAKE) oshmem_max_reduction; \
|
||||||
|
$(MAKE) oshmem_strided_puts; \
|
||||||
|
$(MAKE) oshmem_symmetric_data; \
|
||||||
fi
|
fi
|
||||||
@ if oshmem_info --parsable | grep oshmem:bindings:fort:yes >/dev/null; then \
|
@ if oshmem_info --parsable | grep oshmem:bindings:fort:yes >/dev/null; then \
|
||||||
$(MAKE) hello_oshmemfh; \
|
$(MAKE) hello_oshmemfh; \
|
||||||
@ -143,3 +154,18 @@ ring_oshmem: ring_oshmem_c.c
|
|||||||
ring_oshmemfh: ring_oshmemfh.f90
|
ring_oshmemfh: ring_oshmemfh.f90
|
||||||
$(SHMEMFC) $(FCFLAGS) $? -o $@
|
$(SHMEMFC) $(FCFLAGS) $? -o $@
|
||||||
|
|
||||||
|
oshmem_shmalloc: oshmem_shmalloc.c
|
||||||
|
$(SHMEMFC) $(FCFLAGS) $? -o $@
|
||||||
|
|
||||||
|
oshmem_circular_shift: oshmem_circular_shift.c
|
||||||
|
$(SHMEMCC) $(CFLAGS) $? -o $@
|
||||||
|
|
||||||
|
oshmem_max_reduction: oshmem_max_reduction.c
|
||||||
|
$(SHMEMCC) $(CFLAGS) $? -o $@
|
||||||
|
|
||||||
|
oshmem_strided_puts: oshmem_strided_puts.c
|
||||||
|
$(SHMEMCC) $(CFLAGS) $? -o $@
|
||||||
|
|
||||||
|
oshmem_symmetric_data: oshmem_symmetric_data.c
|
||||||
|
$(SHMEMCC) $(CFLAGS) $? -o $@
|
||||||
|
|
||||||
|
@ -48,5 +48,10 @@ EXTRA_DIST += \
|
|||||||
examples/ring_oshmem_c.c \
|
examples/ring_oshmem_c.c \
|
||||||
examples/ring_oshmemfh.f90 \
|
examples/ring_oshmemfh.f90 \
|
||||||
examples/connectivity_c.c \
|
examples/connectivity_c.c \
|
||||||
|
examples/oshmem_shmalloc.c \
|
||||||
|
examples/oshmem_circular_shift.c \
|
||||||
|
examples/oshmem_max_reduction.c \
|
||||||
|
examples/oshmem_strided_puts.c \
|
||||||
|
examples/oshmem_symmetric_data.c \
|
||||||
examples/Hello.java \
|
examples/Hello.java \
|
||||||
examples/Ring.java
|
examples/Ring.java
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013 Mellanox Technologies, Inc.
|
* Copyright (c) 2014 Mellanox Technologies, Inc.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
!
|
!
|
||||||
! Copyright (c) 2013 Mellanox Technologies, Inc.
|
! Copyright (c) 2014 Mellanox Technologies, Inc.
|
||||||
! All rights reserved.
|
! All rights reserved.
|
||||||
! Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
|
! Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
|
||||||
! $COPYRIGHT$
|
! $COPYRIGHT$
|
||||||
|
34
examples/oshmem_circular_shift.c
Обычный файл
34
examples/oshmem_circular_shift.c
Обычный файл
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014 Mellanox Technologies, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
* $COPYRIGHT$
|
||||||
|
*
|
||||||
|
* Additional copyrights may follow
|
||||||
|
*
|
||||||
|
* $HEADER$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <shmem.h>
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
{
|
||||||
|
static int aaa, bbb;
|
||||||
|
int num_pes, my_pe, peer;
|
||||||
|
|
||||||
|
start_pes(0);
|
||||||
|
|
||||||
|
num_pes = _num_pes();
|
||||||
|
my_pe = _my_pe();
|
||||||
|
|
||||||
|
peer = (my_pe + 1) % num_pes;
|
||||||
|
|
||||||
|
printf("Process %d gets message from %d (%d processes in ring)\n", my_pe, peer, num_pes);
|
||||||
|
shmem_int_get(&aaa, &bbb, 1, peer);
|
||||||
|
|
||||||
|
shmem_barrier_all();
|
||||||
|
printf("Process %d exiting\n", my_pe);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
58
examples/oshmem_max_reduction.c
Обычный файл
58
examples/oshmem_max_reduction.c
Обычный файл
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014 Mellanox Technologies, Inc.
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
start_pes(0);
|
||||||
|
|
||||||
|
my_pe = _my_pe();
|
||||||
|
num_pes = _num_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(" %d", dst[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
28
examples/oshmem_shmalloc.c
Обычный файл
28
examples/oshmem_shmalloc.c
Обычный файл
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014 Mellanox Technologies, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
* $COPYRIGHT$
|
||||||
|
*
|
||||||
|
* Additional copyrights may follow
|
||||||
|
*
|
||||||
|
* $HEADER$
|
||||||
|
*
|
||||||
|
* This sample allocates (shmalloc) symmetric memory (1 long integer),
|
||||||
|
* and then frees it. Success of allocation is not checked.
|
||||||
|
*
|
||||||
|
* Produces no output.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <shmem.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
long *x;
|
||||||
|
|
||||||
|
start_pes(0);
|
||||||
|
|
||||||
|
x = (long *) shmalloc(sizeof(*x));
|
||||||
|
|
||||||
|
shfree(x);
|
||||||
|
}
|
||||||
|
|
54
examples/oshmem_strided_puts.c
Обычный файл
54
examples/oshmem_strided_puts.c
Обычный файл
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014 Mellanox Technologies, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
* $COPYRIGHT$
|
||||||
|
*
|
||||||
|
* Additional copyrights may follow
|
||||||
|
*
|
||||||
|
* $HEADER$
|
||||||
|
*
|
||||||
|
* This program is an adaptation of examples found in the man pages
|
||||||
|
* of SGI’s SHMEM implementation.
|
||||||
|
*
|
||||||
|
* In this program, iput is used to select 5 elements from array source separated by
|
||||||
|
* a stride of 2 and write them to array target using a stride of 1.
|
||||||
|
*
|
||||||
|
* Given the array source = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
|
||||||
|
* iput will select 5 elements from array source on PE 0, using a stride of 2:
|
||||||
|
*
|
||||||
|
* selected elements = { 1, 3, 5, 7, 9 }
|
||||||
|
*
|
||||||
|
* These elements will then be written to the array source on PE 1 using a stride of 1:
|
||||||
|
*
|
||||||
|
* target = { 1, 3, 5, 7, 9 }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <shmem.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
short source[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||||
|
static short target[10];
|
||||||
|
int me;
|
||||||
|
|
||||||
|
start_pes(0);
|
||||||
|
me = _my_pe();
|
||||||
|
|
||||||
|
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) {
|
||||||
|
printf("target on PE %d is %hd %hd %hd %hd %hd\n", me,
|
||||||
|
target[0], target[1], target[2],
|
||||||
|
target[3], target[4] );
|
||||||
|
}
|
||||||
|
shmem_barrier_all(); /* sync before exiting */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
55
examples/oshmem_symmetric_data.c
Обычный файл
55
examples/oshmem_symmetric_data.c
Обычный файл
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014 Mellanox Technologies, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
* $COPYRIGHT$
|
||||||
|
*
|
||||||
|
* Additional copyrights may follow
|
||||||
|
*
|
||||||
|
* $HEADER$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <shmem.h>
|
||||||
|
|
||||||
|
#define SIZE 16
|
||||||
|
|
||||||
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
short source[SIZE];
|
||||||
|
static short target[SIZE];
|
||||||
|
int i;
|
||||||
|
int num_pe, my_pe;
|
||||||
|
|
||||||
|
start_pes(0);
|
||||||
|
|
||||||
|
num_pe = _num_pes();
|
||||||
|
my_pe = _my_pe();
|
||||||
|
|
||||||
|
if (my_pe == 0) {
|
||||||
|
/* initialize array */
|
||||||
|
for(i = 0; i < SIZE; i++) {
|
||||||
|
source[i] = i;
|
||||||
|
}
|
||||||
|
/* local, not symmetric */
|
||||||
|
/* static makes it symmetric */
|
||||||
|
/* put "size" words into target on each PE */
|
||||||
|
for(i = 1; i < num_pe; i++) {
|
||||||
|
shmem_short_put(target, source, SIZE, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
shmem_barrier_all(); /* sync sender and receiver */
|
||||||
|
|
||||||
|
if (my_pe != 0) {
|
||||||
|
printf("Target on PE %d is \t", my_pe);
|
||||||
|
|
||||||
|
for(i = 0; i < SIZE; i++) {
|
||||||
|
printf("%hd \t", target[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
shmem_barrier_all(); /* sync before exiting */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013 Mellanox Technologies, Inc.
|
* Copyright (c) 2014 Mellanox Technologies, Inc.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
!
|
!
|
||||||
! Copyright (c) 2013 Mellanox Technologies, Inc.
|
! Copyright (c) 2014 Mellanox Technologies, Inc.
|
||||||
! All rights reserved.
|
! All rights reserved.
|
||||||
! Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
|
! Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
|
||||||
! $COPYRIGHT$
|
! $COPYRIGHT$
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user