Skip to content

Commit c429900

Browse files
committed
OMPI/OSHMEM: add new functionality of OpenSHMEM v1.4.
Signed-off-by: Xin Zhao <xinz@mellanox.com>
1 parent 9d0b3a4 commit c429900

File tree

140 files changed

+3090
-481
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+3090
-481
lines changed

oshmem/include/oshmem/constants.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ enum {
105105
#define SHMEM_UNDEFINED -32766 /* undefined stuff */
106106

107107

108+
#define SHMEM_CTX_PRIVATE (1<<0)
109+
#define SHMEM_CTX_SERIALIZED (1<<1)
110+
#define SHMEM_CTX_NOSTORE (1<<2)
111+
112+
108113
#ifndef UNREFERENCED_PARAMETER
109114
#define UNREFERENCED_PARAMETER(P) ((void)P)
110115
#endif

oshmem/include/pshmem.h

Lines changed: 513 additions & 4 deletions
Large diffs are not rendered by default.

oshmem/include/shmem.h.in

Lines changed: 515 additions & 2 deletions
Large diffs are not rendered by default.

oshmem/mca/atomic/atomic.h

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ BEGIN_C_DECLS
3535

3636
#define OSHMEM_ATOMIC_PTR_2_INT(ptr, size) ((size) == 8 ? *(uint64_t*)(ptr) : *(uint32_t*)(ptr))
3737

38-
#define OSHMEM_TYPE_OP(type_name, type, prefix, op) \
39-
void prefix##_##type_name##_atomic_##op(type *target, type value, int pe) \
40-
{ \
38+
#define DO_SHMEM_TYPE_OP(ctx, type_name, type, op, target, value, pe) do { \
4139
int rc = OSHMEM_SUCCESS; \
4240
size_t size = 0; \
4341
\
@@ -47,18 +45,31 @@ BEGIN_C_DECLS
4745
\
4846
size = sizeof(value); \
4947
rc = MCA_ATOMIC_CALL(op( \
48+
ctx, \
5049
(void*)target, \
5150
value, \
5251
size, \
5352
pe)); \
5453
RUNTIME_CHECK_RC(rc); \
5554
\
5655
return; \
56+
} while (0)
57+
58+
#define OSHMEM_TYPE_OP(type_name, type, prefix, op) \
59+
void prefix##_##type_name##_atomic_##op(type *target, type value, int pe) \
60+
{ \
61+
DO_SHMEM_TYPE_OP(oshmem_ctx_default, type_name, type, op, \
62+
target, value, pe); \
5763
}
5864

59-
#define OSHMEM_TYPE_FOP(type_name, type, prefix, op) \
60-
type prefix##_##type_name##_atomic_fetch_##op(type *target, type value, int pe) \
61-
{ \
65+
#define OSHMEM_CTX_TYPE_OP(type_name, type, prefix, op) \
66+
void prefix##_ctx_##type_name##_atomic_##op(shmem_ctx_t ctx, type *target, type value, int pe) \
67+
{ \
68+
DO_SHMEM_TYPE_OP(ctx, type_name, type, op, \
69+
target, value, pe); \
70+
}
71+
72+
#define DO_OSHMEM_TYPE_FOP(ctx, type_name, type, op, target, value, pe) do { \
6273
int rc = OSHMEM_SUCCESS; \
6374
size_t size = 0; \
6475
type out_value; \
@@ -69,6 +80,7 @@ BEGIN_C_DECLS
6980
\
7081
size = sizeof(out_value); \
7182
rc = MCA_ATOMIC_CALL(f##op( \
83+
ctx, \
7284
(void*)target, \
7385
(void*)&out_value, \
7486
value, \
@@ -77,7 +89,22 @@ BEGIN_C_DECLS
7789
RUNTIME_CHECK_RC(rc); \
7890
\
7991
return out_value; \
92+
} while (0)
93+
94+
#define OSHMEM_TYPE_FOP(type_name, type, prefix, op) \
95+
type prefix##_##type_name##_atomic_fetch_##op(type *target, type value, int pe) \
96+
{ \
97+
DO_OSHMEM_TYPE_FOP(oshmem_ctx_default, type_name, type, op, \
98+
target, value, pe); \
8099
}
100+
101+
#define OSHMEM_CTX_TYPE_FOP(type_name, type, prefix, op) \
102+
type prefix##_ctx_##type_name##_atomic_fetch_##op(shmem_ctx_t ctx, type *target, type value, int pe) \
103+
{ \
104+
DO_OSHMEM_TYPE_FOP(ctx, type_name, type, op, \
105+
target, value, pe); \
106+
}
107+
81108
/* ******************************************************************** */
82109

83110
struct oshmem_op_t;
@@ -131,48 +158,58 @@ struct mca_atomic_base_module_1_0_0_t {
131158
opal_object_t super;
132159

133160
/* Collective function pointers */
134-
int (*atomic_add)(void *target,
161+
int (*atomic_add)(shmem_ctx_t ctx,
162+
void *target,
135163
uint64_t value,
136164
size_t size,
137165
int pe);
138-
int (*atomic_and)(void *target,
166+
int (*atomic_and)(shmem_ctx_t ctx,
167+
void *target,
139168
uint64_t value,
140169
size_t size,
141170
int pe);
142-
int (*atomic_or)(void *target,
171+
int (*atomic_or)(shmem_ctx_t ctx,
172+
void *target,
143173
uint64_t value,
144174
size_t size,
145175
int pe);
146-
int (*atomic_xor)(void *target,
176+
int (*atomic_xor)(shmem_ctx_t ctx,
177+
void *target,
147178
uint64_t value,
148179
size_t size,
149180
int pe);
150-
int (*atomic_fadd)(void *target,
181+
int (*atomic_fadd)(shmem_ctx_t ctx,
182+
void *target,
151183
void *prev,
152184
uint64_t value,
153185
size_t size,
154186
int pe);
155-
int (*atomic_fand)(void *target,
187+
int (*atomic_fand)(shmem_ctx_t ctx,
188+
void *target,
156189
void *prev,
157190
uint64_t value,
158191
size_t size,
159192
int pe);
160-
int (*atomic_for)(void *target,
193+
int (*atomic_for)(shmem_ctx_t ctx,
194+
void *target,
161195
void *prev,
162196
uint64_t value,
163197
size_t size,
164198
int pe);
165-
int (*atomic_fxor)(void *target,
199+
int (*atomic_fxor)(shmem_ctx_t ctx,
200+
void *target,
166201
void *prev,
167202
uint64_t value,
168203
size_t size,
169204
int pe);
170-
int (*atomic_swap)(void *target,
205+
int (*atomic_swap)(shmem_ctx_t ctx,
206+
void *target,
171207
void *prev,
172208
uint64_t value,
173209
size_t size,
174210
int pe);
175-
int (*atomic_cswap)(void *target,
211+
int (*atomic_cswap)(shmem_ctx_t ctx,
212+
void *target,
176213
uint64_t *prev, /* prev is used internally by wrapper, we may
177214
always use 64-bit value */
178215
uint64_t cond,

oshmem/mca/atomic/basic/atomic_basic.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ BEGIN_C_DECLS
2626
OSHMEM_MODULE_DECLSPEC extern mca_atomic_base_component_1_0_0_t
2727
mca_atomic_basic_component;
2828

29-
OSHMEM_DECLSPEC void atomic_basic_lock(int pe);
30-
OSHMEM_DECLSPEC void atomic_basic_unlock(int pe);
29+
OSHMEM_DECLSPEC void atomic_basic_lock(shmem_ctx_t ctx, int pe);
30+
OSHMEM_DECLSPEC void atomic_basic_unlock(shmem_ctx_t ctx, int pe);
3131

3232
/* API functions */
3333

@@ -36,7 +36,8 @@ int mca_atomic_basic_finalize(void);
3636
mca_atomic_base_module_t*
3737
mca_atomic_basic_query(int *priority);
3838

39-
int mca_atomic_basic_cswap(void *target,
39+
int mca_atomic_basic_cswap(shmem_ctx_t ctx,
40+
void *target,
4041
uint64_t *prev,
4142
uint64_t cond,
4243
uint64_t value,

oshmem/mca/atomic/basic/atomic_basic_cswap.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
#include "oshmem/mca/atomic/base/base.h"
1919
#include "atomic_basic.h"
2020

21-
int mca_atomic_basic_cswap(void *target,
21+
int mca_atomic_basic_cswap(shmem_ctx_t ctx,
22+
void *target,
2223
uint64_t *prev,
2324
uint64_t cond,
2425
uint64_t value,
@@ -32,16 +33,16 @@ int mca_atomic_basic_cswap(void *target,
3233
}
3334

3435
if (rc == OSHMEM_SUCCESS) {
35-
atomic_basic_lock(pe);
36+
atomic_basic_lock(ctx, pe);
3637

37-
rc = MCA_SPML_CALL(get(target, nlong, prev, pe));
38+
rc = MCA_SPML_CALL(get(ctx, target, nlong, prev, pe));
3839

3940
if ((rc == OSHMEM_SUCCESS) && (!cond || !memcmp(prev, &cond, nlong))) {
40-
rc = MCA_SPML_CALL(put(target, nlong, (void*)&value, pe));
41+
rc = MCA_SPML_CALL(put(ctx, target, nlong, (void*)&value, pe));
4142
shmem_quiet();
4243
}
4344

44-
atomic_basic_unlock(pe);
45+
atomic_basic_unlock(ctx, pe);
4546
}
4647

4748
return rc;

0 commit comments

Comments
 (0)