From e894a89db8dae168db76b30a445b27b206eb197f Mon Sep 17 00:00:00 2001 From: Boris Karasev Date: Fri, 21 Oct 2016 12:36:53 +0600 Subject: [PATCH] oshmem: updated API oshmem examples to OSHMEM 1.3 --- examples/oshmem_circular_shift.c | 11 +++++------ examples/oshmem_max_reduction.c | 11 +++++------ examples/oshmem_shmalloc.c | 12 ++++++------ examples/oshmem_strided_puts.c | 9 ++++----- examples/oshmem_symmetric_data.c | 11 +++++------ 5 files changed, 25 insertions(+), 29 deletions(-) diff --git a/examples/oshmem_circular_shift.c b/examples/oshmem_circular_shift.c index f3e409e492..3ff2d6d0c8 100644 --- a/examples/oshmem_circular_shift.c +++ b/examples/oshmem_circular_shift.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Mellanox Technologies, Inc. + * Copyright (c) 2014-2016 Mellanox Technologies, Inc. * All rights reserved. * $COPYRIGHT$ * @@ -11,17 +11,15 @@ #include #include -#warning This application uses deprecated API see http://www.open-mpi.org/ - int main (void) { static int aaa, bbb; int num_pes, my_pe, peer; - start_pes(0); + shmem_init(); - num_pes = _num_pes(); - my_pe = _my_pe(); + num_pes = shmem_n_pes(); + my_pe = shmem_my_pe(); peer = (my_pe + 1) % num_pes; @@ -30,6 +28,7 @@ int main (void) shmem_barrier_all(); printf("Process %d exiting\n", my_pe); + shmem_finalize(); return 0; } diff --git a/examples/oshmem_max_reduction.c b/examples/oshmem_max_reduction.c index 1bf026292e..d0dec673af 100644 --- a/examples/oshmem_max_reduction.c +++ b/examples/oshmem_max_reduction.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Mellanox Technologies, Inc. + * Copyright (c) 2014-2016 Mellanox Technologies, Inc. * All rights reserved. * $COPYRIGHT$ * @@ -15,8 +15,6 @@ #include -#warning This application uses deprecated API see http://www.open-mpi.org/ - long pSync[_SHMEM_BCAST_SYNC_SIZE]; #define N 3 @@ -34,10 +32,10 @@ int main(void) pSync[i] = _SHMEM_SYNC_VALUE; } - start_pes(0); + shmem_init(); - my_pe = _my_pe(); - num_pes = _num_pes(); + my_pe = shmem_my_pe(); + num_pes = shmem_n_pes(); for (i = 0; i < N; i += 1) { src[i] = my_pe + i; @@ -54,6 +52,7 @@ int main(void) } printf("\n"); + shmem_finalize(); return 0; } diff --git a/examples/oshmem_shmalloc.c b/examples/oshmem_shmalloc.c index 2c3f4cb674..e5f9ab9090 100644 --- a/examples/oshmem_shmalloc.c +++ b/examples/oshmem_shmalloc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Mellanox Technologies, Inc. + * Copyright (c) 2014-2016 Mellanox Technologies, Inc. * All rights reserved. * $COPYRIGHT$ * @@ -15,16 +15,16 @@ #include -#warning This application uses deprecated API see http://www.open-mpi.org/ - int main(void) { long *x; - start_pes(0); + shmem_init(); - x = (long *) shmalloc(sizeof(*x)); + x = (long *) shmem_malloc(sizeof(*x)); - shfree(x); + shmem_free(x); + + shmem_finalize(); } diff --git a/examples/oshmem_strided_puts.c b/examples/oshmem_strided_puts.c index 5ec2441977..e9f31ddb74 100644 --- a/examples/oshmem_strided_puts.c +++ b/examples/oshmem_strided_puts.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Mellanox Technologies, Inc. + * Copyright (c) 2014-2016 Mellanox Technologies, Inc. * All rights reserved. * $COPYRIGHT$ * @@ -27,16 +27,14 @@ #include #include -#warning This application uses deprecated API see http://www.open-mpi.org/ - 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(); + shmem_init(); + me = shmem_my_pe(); if (me == 0) { /* put 10 words into target on PE 1 */ @@ -51,6 +49,7 @@ int main(void) target[3], target[4] ); } shmem_barrier_all(); /* sync before exiting */ + shmem_finalize(); return 0; } diff --git a/examples/oshmem_symmetric_data.c b/examples/oshmem_symmetric_data.c index 9aaaeabac1..7c5a1db6b5 100644 --- a/examples/oshmem_symmetric_data.c +++ b/examples/oshmem_symmetric_data.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Mellanox Technologies, Inc. + * Copyright (c) 2014-2016 Mellanox Technologies, Inc. * All rights reserved. * $COPYRIGHT$ * @@ -11,8 +11,6 @@ #include #include -#warning This application uses deprecated API see http://www.open-mpi.org/ - #define SIZE 16 int main(int argc, char* argv[]) @@ -22,10 +20,10 @@ int main(int argc, char* argv[]) int i; int num_pe, my_pe; - start_pes(0); + shmem_init(); - num_pe = _num_pes(); - my_pe = _my_pe(); + num_pe = shmem_n_pes(); + my_pe = shmem_my_pe(); if (my_pe == 0) { /* initialize array */ @@ -52,6 +50,7 @@ int main(int argc, char* argv[]) } shmem_barrier_all(); /* sync before exiting */ + shmem_finalize(); return 0; }