Skip to content

Commit 3a03435

Browse files
committed
OSHMEM: v1.3: adds shmem_fetch and shmem_set AMOs
The commit adds atomic set and fetch functions as described in oshmem 1.3 spec.
1 parent 0663702 commit 3a03435

33 files changed

+868
-0
lines changed

oshmem/include/pshmem.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,13 @@ OSHMEM_DECLSPEC int pshmem_int_swap(int *target, int value, int pe);
210210
OSHMEM_DECLSPEC long pshmem_long_swap(long *target, long value, int pe);
211211
OSHMEM_DECLSPEC long long pshmem_longlong_swap(long long*target, long long value, int pe);
212212

213+
/* Atomic set */
214+
OSHMEM_DECLSPEC void pshmem_int_set(int *target, int value, int pe);
215+
OSHMEM_DECLSPEC void pshmem_long_set(long *target, long value, int pe);
216+
OSHMEM_DECLSPEC void pshmem_longlong_set(long long*target, long long value, int pe);
217+
OSHMEM_DECLSPEC void pshmem_float_set(float *target, float value, int pe);
218+
OSHMEM_DECLSPEC void pshmem_double_set(double *target, double value, int pe);
219+
213220
/* Atomic conditional swap */
214221
OSHMEM_DECLSPEC int pshmem_int_cswap(int *target, int cond, int value, int pe);
215222
OSHMEM_DECLSPEC long pshmem_long_cswap(long *target, long cond, long value, int pe);
@@ -220,6 +227,14 @@ OSHMEM_DECLSPEC int pshmem_int_fadd(int *target, int value, int pe);
220227
OSHMEM_DECLSPEC long pshmem_long_fadd(long *target, long value, int pe);
221228
OSHMEM_DECLSPEC long long pshmem_longlong_fadd(long long *target, long long value, int pe);
222229

230+
/* Atomic Fetch */
231+
OSHMEM_DECLSPEC int pshmem_int_fetch(const int *target, int pe);
232+
OSHMEM_DECLSPEC long pshmem_long_fetch(const long *target, int pe);
233+
OSHMEM_DECLSPEC long long pshmem_longlong_fetch(const long long *target, int pe);
234+
OSHMEM_DECLSPEC float pshmem_float_fetch(const float *target, int pe);
235+
OSHMEM_DECLSPEC double pshmem_double_fetch(const double *target, int pe);
236+
237+
223238
/* Atomic Fetch&Inc */
224239
OSHMEM_DECLSPEC int pshmem_int_finc(int *target, int pe);
225240
OSHMEM_DECLSPEC long pshmem_long_finc(long *target, int pe);

oshmem/include/pshmemx.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ OSHMEM_DECLSPEC void pshmemx_iget16(void* target, const void* source, ptrdiff_t
8181
OSHMEM_DECLSPEC int32_t pshmemx_int32_swap(int32_t *target, int32_t value, int pe);
8282
OSHMEM_DECLSPEC int64_t pshmemx_int64_swap(int64_t *target, int64_t value, int pe);
8383

84+
/*Atomic set */
85+
OSHMEM_DECLSPEC void pshmemx_int32_set(int32_t *target, int32_t value, int pe);
86+
OSHMEM_DECLSPEC void pshmemx_int64_set(int64_t *target, int64_t value, int pe);
87+
8488
/* Atomic conditional swap */
8589
OSHMEM_DECLSPEC int32_t pshmemx_int32_cswap(int32_t *target, int32_t cond, int32_t value, int pe);
8690
OSHMEM_DECLSPEC int64_t pshmemx_int64_cswap(int64_t *target, int64_t cond, int64_t value, int pe);
@@ -89,6 +93,10 @@ OSHMEM_DECLSPEC int64_t pshmemx_int64_cswap(int64_t *target, int64_t cond, int64
8993
OSHMEM_DECLSPEC int32_t pshmemx_int32_fadd(int32_t *target, int32_t value, int pe);
9094
OSHMEM_DECLSPEC int64_t pshmemx_int64_fadd(int64_t *target, int64_t value, int pe);
9195

96+
/* Atomic Fetch */
97+
OSHMEM_DECLSPEC int32_t pshmemx_int32_fetch(const int32_t *target, int pe);
98+
OSHMEM_DECLSPEC int64_t pshmemx_int64_fetch(const int64_t *target, int pe);
99+
92100
/* Atomic Fetch&Inc */
93101
OSHMEM_DECLSPEC int32_t pshmemx_int32_finc(int32_t *target, int pe);
94102
OSHMEM_DECLSPEC int64_t pshmemx_int64_finc(int64_t *target, int pe);
@@ -160,15 +168,25 @@ OSHMEM_DECLSPEC void pshmemx_int64_prod_to_all(int64_t *target, const int64_t *s
160168

161169
#define pshmem_int32_swap pshmemx_int32_swap
162170
#define pshmem_int64_swap pshmemx_int64_swap
171+
172+
#define pshmem_int32_set pshmemx_int32_set
173+
#define pshmem_int64_set pshmemx_int64_set
174+
163175
#define pshmem_int32_cswap pshmemx_int32_cswap
164176
#define pshmem_int64_cswap pshmemx_int64_cswap
165177

166178
#define pshmem_int32_fadd pshmemx_int32_fadd
167179
#define pshmem_int64_fadd pshmemx_int64_fadd
180+
181+
#define pshmem_int32_fetch pshmemx_int32_fetch
182+
#define pshmem_int64_fetch pshmemx_int64_fetch
183+
168184
#define pshmem_int32_finc pshmemx_int32_finc
169185
#define pshmem_int64_finc pshmemx_int64_finc
186+
170187
#define pshmem_int32_add pshmemx_int32_add
171188
#define pshmem_int64_add pshmemx_int64_add
189+
172190
#define pshmem_int32_inc pshmemx_int32_inc
173191
#define pshmem_int64_inc pshmemx_int64_inc
174192

oshmem/include/shmem.h.in

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,13 @@ OSHMEM_DECLSPEC int shmem_int_swap(int *target, int value, int pe);
275275
OSHMEM_DECLSPEC long shmem_long_swap(long *target, long value, int pe);
276276
OSHMEM_DECLSPEC long long shmem_longlong_swap(long long*target, long long value, int pe);
277277

278+
/* Atomic set */
279+
OSHMEM_DECLSPEC void shmem_int_set(int *target, int value, int pe);
280+
OSHMEM_DECLSPEC void shmem_long_set(long *target, long value, int pe);
281+
OSHMEM_DECLSPEC void shmem_longlong_set(long long*target, long long value, int pe);
282+
OSHMEM_DECLSPEC void shmem_float_set(float *target, float value, int pe);
283+
OSHMEM_DECLSPEC void shmem_double_set(double *target, double value, int pe);
284+
278285
/* Atomic conditional swap */
279286
OSHMEM_DECLSPEC int shmem_int_cswap(int *target, int cond, int value, int pe);
280287
OSHMEM_DECLSPEC long shmem_long_cswap(long *target, long cond, long value, int pe);
@@ -285,6 +292,13 @@ OSHMEM_DECLSPEC int shmem_int_fadd(int *target, int value, int pe);
285292
OSHMEM_DECLSPEC long shmem_long_fadd(long *target, long value, int pe);
286293
OSHMEM_DECLSPEC long long shmem_longlong_fadd(long long *target, long long value, int pe);
287294

295+
/* Atomic Fetch */
296+
OSHMEM_DECLSPEC int shmem_int_fetch(const int *target, int pe);
297+
OSHMEM_DECLSPEC long shmem_long_fetch(const long *target, int pe);
298+
OSHMEM_DECLSPEC long long shmem_longlong_fetch(const long long *target, int pe);
299+
OSHMEM_DECLSPEC float shmem_float_fetch(const float *target, int pe);
300+
OSHMEM_DECLSPEC double shmem_double_fetch(const double *target, int pe);
301+
288302
/* Atomic Fetch&Inc */
289303
OSHMEM_DECLSPEC int shmem_int_finc(int *target, int pe);
290304
OSHMEM_DECLSPEC long shmem_long_finc(long *target, int pe);

oshmem/include/shmemx.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ OSHMEM_DECLSPEC void shmemx_iget16(void* target, const void* source, ptrdiff_t t
6666
OSHMEM_DECLSPEC int32_t shmemx_int32_swap(int32_t *target, int32_t value, int pe);
6767
OSHMEM_DECLSPEC int64_t shmemx_int64_swap(int64_t *target, int64_t value, int pe);
6868

69+
/* Atomic set */
70+
OSHMEM_DECLSPEC void shmemx_int32_set(int32_t *target, int32_t value, int pe);
71+
OSHMEM_DECLSPEC void shmemx_int64_set(int64_t *target, int64_t value, int pe);
72+
6973
/* Atomic conditional swap */
7074
OSHMEM_DECLSPEC int32_t shmemx_int32_cswap(int32_t *target, int32_t cond, int32_t value, int pe);
7175
OSHMEM_DECLSPEC int64_t shmemx_int64_cswap(int64_t *target, int64_t cond, int64_t value, int pe);
@@ -74,6 +78,10 @@ OSHMEM_DECLSPEC int64_t shmemx_int64_cswap(int64_t *target, int64_t cond, int64_
7478
OSHMEM_DECLSPEC int32_t shmemx_int32_fadd(int32_t *target, int32_t value, int pe);
7579
OSHMEM_DECLSPEC int64_t shmemx_int64_fadd(int64_t *target, int64_t value, int pe);
7680

81+
/* Atomic Fetch */
82+
OSHMEM_DECLSPEC int32_t shmemx_int32_fetch(const int32_t *target, int pe);
83+
OSHMEM_DECLSPEC int64_t shmemx_int64_fetch(const int64_t *target, int pe);
84+
7785
/* Atomic Fetch&Inc */
7886
OSHMEM_DECLSPEC int32_t shmemx_int32_finc(int32_t *target, int pe);
7987
OSHMEM_DECLSPEC int64_t shmemx_int64_finc(int64_t *target, int pe);
@@ -145,13 +153,22 @@ OSHMEM_DECLSPEC void shmemx_int64_prod_to_all(int64_t *target, const int64_t *so
145153

146154
#define shmem_int32_swap shmemx_int32_swap
147155
#define shmem_int64_swap shmemx_int64_swap
156+
157+
#define shmem_int32_set shmemx_int32_set
158+
#define shmem_int64_set shmemx_int64_set
159+
148160
#define shmem_int32_cswap shmemx_int32_cswap
149161
#define shmem_int64_cswap shmemx_int64_cswap
150162

151163
#define shmem_int32_fadd shmemx_int32_fadd
152164
#define shmem_int64_fadd shmemx_int64_fadd
165+
166+
#define shmem_int32_fetch shmemx_int32_fetch
167+
#define shmem_int64_fetch shmemx_int64_fetch
168+
153169
#define shmem_int32_finc shmemx_int32_finc
154170
#define shmem_int64_finc shmemx_int64_finc
171+
155172
#define shmem_int32_add shmemx_int32_add
156173
#define shmem_int64_add shmemx_int64_add
157174
#define shmem_int32_inc shmemx_int32_inc

oshmem/shmem/c/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ OSHMEM_API_SOURCES = \
5151
shmem_clear_cache_line_inv.c \
5252
shmem_reduce.c \
5353
shmem_swap.c \
54+
shmem_set.c \
5455
shmem_cswap.c \
5556
shmem_fadd.c \
57+
shmem_fetch.c \
5658
shmem_finc.c \
5759
shmem_add.c \
5860
shmem_inc.c \

oshmem/shmem/c/profile/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ OSHMEM_API_SOURCES = \
6363
pshmem_clear_cache_line_inv.c \
6464
pshmem_reduce.c \
6565
pshmem_swap.c \
66+
pshmem_set.c \
6667
pshmem_cswap.c \
6768
pshmem_fadd.c \
69+
pshmem_fetch.c \
6870
pshmem_finc.c \
6971
pshmem_add.c \
7072
pshmem_inc.c \

oshmem/shmem/c/profile/defines.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,14 @@
203203
#define shmemx_int32_swap pshmemx_int32_swap
204204
#define shmemx_int64_swap pshmemx_int64_swap
205205

206+
/* Atomic set */
207+
#define shmem_double_set pshmem_double_set
208+
#define shmem_float_set pshmem_float_set
209+
#define shmem_int_set pshmem_int_set
210+
#define shmem_long_set pshmem_long_set
211+
#define shmem_longlong_set pshmem_longlong_set
212+
#define shmemx_int32_set pshmemx_int32_set
213+
#define shmemx_int64_set pshmemx_int64_set
206214

207215
/* Atomic conditional swap */
208216
#define shmem_int_cswap pshmem_int_cswap
@@ -219,6 +227,15 @@
219227
#define shmemx_int32_fadd pshmemx_int32_fadd
220228
#define shmemx_int64_fadd pshmemx_int64_fadd
221229

230+
/* Atomic Fetch */
231+
#define shmem_double_fetch pshmem_double_fetch
232+
#define shmem_float_fetch pshmem_float_fetch
233+
#define shmem_int_fetch pshmem_int_fetch
234+
#define shmem_long_fetch pshmem_long_fetch
235+
#define shmem_longlong_fetch pshmem_longlong_fetch
236+
#define shmemx_int32_fetch pshmemx_int32_fetch
237+
#define shmemx_int64_fetch pshmemx_int64_fetch
238+
222239
/* Atomic Fetch&Inc */
223240
#define shmem_int_finc pshmem_int_finc
224241
#define shmem_long_finc pshmem_long_finc

oshmem/shmem/c/shmem_fetch.c

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright (c) 2016 Mellanox Technologies, Inc.
3+
* All rights reserved.
4+
* $COPYRIGHT$
5+
*
6+
* Additional copyrights may follow
7+
*
8+
* $HEADER$
9+
*/
10+
#include "oshmem_config.h"
11+
12+
#include "oshmem/constants.h"
13+
#include "oshmem/include/shmem.h"
14+
15+
#include "oshmem/runtime/runtime.h"
16+
17+
#include "oshmem/op/op.h"
18+
#include "oshmem/mca/atomic/atomic.h"
19+
20+
/*
21+
* These routines perform an atomic fetch operation.
22+
* The fetch routines retrieve the value at address target on PE pe.
23+
* The operation must be completed without the possibility of another process
24+
* updating target during the fetch.
25+
*/
26+
#define SHMEM_TYPE_FETCH(type_name, type, prefix) \
27+
type prefix##type_name##_fetch(const type *target, int pe) \
28+
{ \
29+
int rc = OSHMEM_SUCCESS; \
30+
size_t size = 0; \
31+
type out_value; \
32+
type value = 0; \
33+
oshmem_op_t* op = oshmem_op_sum##type_name; \
34+
\
35+
RUNTIME_CHECK_INIT(); \
36+
RUNTIME_CHECK_PE(pe); \
37+
RUNTIME_CHECK_ADDR(target); \
38+
\
39+
size = sizeof(out_value); \
40+
rc = MCA_ATOMIC_CALL(fadd( \
41+
(void*)target, \
42+
(void*)&out_value, \
43+
(const void*)&value, \
44+
size, \
45+
pe, \
46+
op)); \
47+
RUNTIME_CHECK_RC(rc); \
48+
\
49+
return out_value; \
50+
}
51+
52+
#if OSHMEM_PROFILING
53+
#include "oshmem/include/pshmem.h"
54+
#pragma weak shmem_int_fetch = pshmem_int_fetch
55+
#pragma weak shmem_long_fetch = pshmem_long_fetch
56+
#pragma weak shmem_longlong_fetch = pshmem_longlong_fetch
57+
#pragma weak shmem_double_fetch = pshmem_double_fetch
58+
#pragma weak shmem_float_fetch = pshmem_float_fetch
59+
#pragma weak shmemx_int32_fetch = pshmemx_int32_fetch
60+
#pragma weak shmemx_int64_fetch = pshmemx_int64_fetch
61+
#include "oshmem/shmem/c/profile/defines.h"
62+
#endif
63+
64+
SHMEM_TYPE_FETCH(_int, int, shmem)
65+
SHMEM_TYPE_FETCH(_long, long, shmem)
66+
SHMEM_TYPE_FETCH(_longlong, long long, shmem)
67+
SHMEM_TYPE_FETCH(_double, double, shmem)
68+
SHMEM_TYPE_FETCH(_float, float, shmem)
69+
SHMEM_TYPE_FETCH(_int32, int32_t, shmemx)
70+
SHMEM_TYPE_FETCH(_int64, int64_t, shmemx)
71+

oshmem/shmem/c/shmem_set.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright (c) 2016 Mellanox Technologies, Inc.
3+
* All rights reserved.
4+
* $COPYRIGHT$
5+
*
6+
* Additional copyrights may follow
7+
*
8+
* $HEADER$
9+
*/
10+
#include "oshmem_config.h"
11+
12+
#include "oshmem/constants.h"
13+
#include "oshmem/include/shmem.h"
14+
15+
#include "oshmem/runtime/runtime.h"
16+
17+
#include "oshmem/mca/atomic/atomic.h"
18+
19+
/*
20+
* shmem_set performs an atomic set operation.
21+
* The atomic set routines write value to address target on PE pe.
22+
* The operation must be completed without the possibility of another
23+
* process updating the target during the set.
24+
*/
25+
#define SHMEM_TYPE_SET(type_name, type, prefix) \
26+
void prefix##type_name##_set(type *target, type value, int pe) \
27+
{ \
28+
int rc = OSHMEM_SUCCESS; \
29+
size_t size = 0; \
30+
type out_value; \
31+
\
32+
RUNTIME_CHECK_INIT(); \
33+
RUNTIME_CHECK_PE(pe); \
34+
RUNTIME_CHECK_ADDR(target); \
35+
\
36+
size = sizeof(out_value); \
37+
rc = MCA_ATOMIC_CALL(cswap( \
38+
(void*)target, \
39+
(void*)&out_value, \
40+
NULL, \
41+
(const void*)&value, \
42+
size, \
43+
pe)); \
44+
RUNTIME_CHECK_RC(rc); \
45+
}
46+
47+
#if OSHMEM_PROFILING
48+
#include "oshmem/include/pshmem.h"
49+
#pragma weak shmem_int_set = pshmem_int_set
50+
#pragma weak shmem_long_set = pshmem_long_set
51+
#pragma weak shmem_longlong_set = pshmem_longlong_set
52+
#pragma weak shmem_float_set = pshmem_float_set
53+
#pragma weak shmem_double_set = pshmem_double_set
54+
#pragma weak shmemx_int32_set = pshmemx_int32_set
55+
#pragma weak shmemx_int64_set = pshmemx_int64_set
56+
#include "oshmem/shmem/c/profile/defines.h"
57+
#endif
58+
59+
SHMEM_TYPE_SET(_int, int, shmem)
60+
SHMEM_TYPE_SET(_long, long, shmem)
61+
SHMEM_TYPE_SET(_longlong, long long, shmem)
62+
SHMEM_TYPE_SET(_float, float, shmem)
63+
SHMEM_TYPE_SET(_double, double, shmem)
64+
SHMEM_TYPE_SET(_int32, int32_t, shmemx)
65+
SHMEM_TYPE_SET(_int64, int64_t, shmemx)
66+

oshmem/shmem/fortran/Makefile.am

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,18 @@ liboshmem_fortran_la_SOURCES += \
9898
shmem_int8_swap_f.c \
9999
shmem_real4_swap_f.c \
100100
shmem_real8_swap_f.c \
101+
shmem_int4_set_f.c \
102+
shmem_int8_set_f.c \
103+
shmem_real4_set_f.c \
104+
shmem_real8_set_f.c \
101105
shmem_int4_cswap_f.c \
102106
shmem_int8_cswap_f.c \
103107
shmem_int4_fadd_f.c \
104108
shmem_int8_fadd_f.c \
109+
shmem_int4_fetch_f.c \
110+
shmem_int8_fetch_f.c \
111+
shmem_real4_fetch_f.c \
112+
shmem_real8_fetch_f.c \
105113
shmem_int4_finc_f.c \
106114
shmem_int8_finc_f.c \
107115
shmem_int4_add_f.c \

oshmem/shmem/fortran/profile/Makefile.am

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,18 @@ nodist_liboshmem_fortran_pshmem_la_SOURCES = \
9090
pshmem_int8_swap_f.c \
9191
pshmem_real4_swap_f.c \
9292
pshmem_real8_swap_f.c \
93+
pshmem_int4_set_f.c \
94+
pshmem_int8_set_f.c \
95+
pshmem_real4_set_f.c \
96+
pshmem_real8_set_f.c \
9397
pshmem_int4_cswap_f.c \
9498
pshmem_int8_cswap_f.c \
9599
pshmem_int4_fadd_f.c \
96100
pshmem_int8_fadd_f.c \
101+
pshmem_int4_fetch_f.c \
102+
pshmem_int8_fetch_f.c \
103+
pshmem_real4_fetch_f.c \
104+
pshmem_real8_fetch_f.c \
97105
pshmem_int4_finc_f.c \
98106
pshmem_int8_finc_f.c \
99107
pshmem_int4_add_f.c \

0 commit comments

Comments
 (0)