Skip to content

Commit 157f81b

Browse files
committed
oshmem: Align OSHMEM API with spec v1.3 (Added const to every read-only pointer argument)
Annex G: Version 1.3 Added const to every read-only pointer argument
1 parent c02d0b7 commit 157f81b

16 files changed

+295
-210
lines changed

oshmem/include/pshmem.h

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

oshmem/include/shmem.h.in

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

oshmem/shmem/c/shmem_addr_accessible.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013 Mellanox Technologies, Inc.
2+
* Copyright (c) 2013-2016 Mellanox Technologies, Inc.
33
* All rights reserved.
44
* $COPYRIGHT$
55
*
@@ -22,14 +22,14 @@
2222
#include "oshmem/shmem/c/profile/defines.h"
2323
#endif
2424

25-
int shmem_addr_accessible(void *addr, int pe)
25+
int shmem_addr_accessible(const void *addr, int pe)
2626
{
2727
void* rva;
2828
sshmem_mkey_t *mkey;
2929

3030
RUNTIME_CHECK_INIT();
3131

32-
mkey = mca_memheap_base_get_cached_mkey(pe, addr, oshmem_get_transport_id(pe), &rva);
32+
mkey = mca_memheap_base_get_cached_mkey(pe, (void *)addr, oshmem_get_transport_id(pe), &rva);
3333

3434
return mkey ? 1 : 0;
3535
}

oshmem/shmem/c/shmem_g.c

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013 Mellanox Technologies, Inc.
2+
* Copyright (c) 2013-2016 Mellanox Technologies, Inc.
33
* All rights reserved.
44
* $COPYRIGHT$
55
*
@@ -22,6 +22,28 @@
2222
* Retrieves the value at the symmetric address addr of the remote PE pe.
2323
*/
2424
#define SHMEM_TYPE_G(type_name, type, prefix) \
25+
type prefix##type_name##_g(const type *addr, int pe) \
26+
{ \
27+
int rc = OSHMEM_SUCCESS; \
28+
size_t size = 0; \
29+
type out_value; \
30+
\
31+
RUNTIME_CHECK_INIT(); \
32+
RUNTIME_CHECK_PE(pe); \
33+
RUNTIME_CHECK_ADDR(addr); \
34+
\
35+
size = sizeof(out_value); \
36+
rc = MCA_SPML_CALL(get( \
37+
(void*)addr, \
38+
size, \
39+
(void*)&out_value, \
40+
pe)); \
41+
RUNTIME_CHECK_RC(rc); \
42+
\
43+
return out_value; \
44+
}
45+
46+
#define SHMEM_TYPE_GX(type_name, type, prefix) \
2547
type prefix##type_name##_g(type *addr, int pe) \
2648
{ \
2749
int rc = OSHMEM_SUCCESS; \
@@ -67,6 +89,6 @@ SHMEM_TYPE_G(_longlong, long long, shmem)
6789
SHMEM_TYPE_G(_float, float, shmem)
6890
SHMEM_TYPE_G(_double, double, shmem)
6991
SHMEM_TYPE_G(_longdouble, long double, shmem)
70-
SHMEM_TYPE_G(_int16, int16_t, shmemx)
71-
SHMEM_TYPE_G(_int32, int32_t, shmemx)
72-
SHMEM_TYPE_G(_int64, int64_t, shmemx)
92+
SHMEM_TYPE_GX(_int16, int16_t, shmemx)
93+
SHMEM_TYPE_GX(_int32, int32_t, shmemx)
94+
SHMEM_TYPE_GX(_int64, int64_t, shmemx)

oshmem/shmem/c/shmem_ptr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "oshmem/shmem/c/profile/defines.h"
2727
#endif
2828

29-
void *shmem_ptr(void *ptr, int pe)
29+
void *shmem_ptr(const void *ptr, int pe)
3030
{
3131
SHMEM_API_VERBOSE(10,
3232
"*************** WARNING!!! NOT SUPPORTED FUNCTION **********************\n"

oshmem/shmem/c/shmem_reduce.c

Lines changed: 84 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,69 @@ static bool __group_cache_enabled = true;
3333
* logPE_stride and PE_size.
3434
*/
3535
#define SHMEM_TYPE_REDUCE_OP(name, type_name, type, prefix) \
36+
void prefix##type_name##_##name##_to_all( type *target, \
37+
const type *source, \
38+
int nreduce, \
39+
int PE_start, \
40+
int logPE_stride, \
41+
int PE_size, \
42+
type *pWrk, \
43+
long *pSync ) \
44+
{ \
45+
int rc = OSHMEM_SUCCESS; \
46+
oshmem_group_t* group = NULL; \
47+
\
48+
RUNTIME_CHECK_INIT(); \
49+
RUNTIME_CHECK_ADDR(target); \
50+
RUNTIME_CHECK_ADDR(source); \
51+
\
52+
{ \
53+
/* Create group basing PE_start, logPE_stride and PE_size */ \
54+
if (!__group_cache_enabled) \
55+
{ \
56+
group = oshmem_proc_group_create(PE_start, (1 << logPE_stride), PE_size); \
57+
if (!group) \
58+
rc = OSHMEM_ERROR; \
59+
} \
60+
else \
61+
{ \
62+
group = find_group_in_cache(PE_start,logPE_stride,PE_size); \
63+
if (!group) \
64+
{ \
65+
group = oshmem_proc_group_create(PE_start, (1 << logPE_stride), PE_size); \
66+
if (!group) \
67+
rc = OSHMEM_ERROR; \
68+
cache_group(group,PE_start,logPE_stride,PE_size); \
69+
} \
70+
} \
71+
\
72+
/* Collective operation call */ \
73+
if ( rc == OSHMEM_SUCCESS ) \
74+
{ \
75+
oshmem_op_t* op = oshmem_op_##name##type_name; \
76+
size_t size = nreduce * op->dt_size; \
77+
\
78+
/* Call collective reduce operation */ \
79+
rc = group->g_scoll.scoll_reduce( \
80+
group, \
81+
op, \
82+
(void*)target, \
83+
(const void*)source, \
84+
size, \
85+
pSync, \
86+
(void*)pWrk, \
87+
SCOLL_DEFAULT_ALG ); \
88+
} \
89+
\
90+
if ( !__group_cache_enabled && (rc == OSHMEM_SUCCESS ) ) \
91+
{ \
92+
oshmem_proc_group_destroy(group); \
93+
} \
94+
} \
95+
RUNTIME_CHECK_RC(rc); \
96+
}
97+
98+
#define SHMEM_TYPE_REDUCE_OPX(name, type_name, type, prefix) \
3699
void prefix##type_name##_##name##_to_all( type *target, \
37100
type *source, \
38101
int nreduce, \
@@ -175,25 +238,25 @@ SHMEM_TYPE_REDUCE_OP(and, _short, short, shmem)
175238
SHMEM_TYPE_REDUCE_OP(and, _int, int, shmem)
176239
SHMEM_TYPE_REDUCE_OP(and, _long, long, shmem)
177240
SHMEM_TYPE_REDUCE_OP(and, _longlong, long long, shmem)
178-
SHMEM_TYPE_REDUCE_OP(and, _int16, int16_t, shmemx)
179-
SHMEM_TYPE_REDUCE_OP(and, _int32, int32_t, shmemx)
180-
SHMEM_TYPE_REDUCE_OP(and, _int64, int64_t, shmemx)
241+
SHMEM_TYPE_REDUCE_OPX(and, _int16, int16_t, shmemx)
242+
SHMEM_TYPE_REDUCE_OPX(and, _int32, int32_t, shmemx)
243+
SHMEM_TYPE_REDUCE_OPX(and, _int64, int64_t, shmemx)
181244

182245
SHMEM_TYPE_REDUCE_OP(or, _short, short, shmem)
183246
SHMEM_TYPE_REDUCE_OP(or, _int, int, shmem)
184247
SHMEM_TYPE_REDUCE_OP(or, _long, long, shmem)
185248
SHMEM_TYPE_REDUCE_OP(or, _longlong, long long, shmem)
186-
SHMEM_TYPE_REDUCE_OP(or, _int16, int16_t, shmemx)
187-
SHMEM_TYPE_REDUCE_OP(or, _int32, int32_t, shmemx)
188-
SHMEM_TYPE_REDUCE_OP(or, _int64, int64_t, shmemx)
249+
SHMEM_TYPE_REDUCE_OPX(or, _int16, int16_t, shmemx)
250+
SHMEM_TYPE_REDUCE_OPX(or, _int32, int32_t, shmemx)
251+
SHMEM_TYPE_REDUCE_OPX(or, _int64, int64_t, shmemx)
189252

190253
SHMEM_TYPE_REDUCE_OP(xor, _short, short, shmem)
191254
SHMEM_TYPE_REDUCE_OP(xor, _int, int, shmem)
192255
SHMEM_TYPE_REDUCE_OP(xor, _long, long, shmem)
193256
SHMEM_TYPE_REDUCE_OP(xor, _longlong, long long, shmem)
194-
SHMEM_TYPE_REDUCE_OP(xor, _int16, int16_t, shmemx)
195-
SHMEM_TYPE_REDUCE_OP(xor, _int32, int32_t, shmemx)
196-
SHMEM_TYPE_REDUCE_OP(xor, _int64, int64_t, shmemx)
257+
SHMEM_TYPE_REDUCE_OPX(xor, _int16, int16_t, shmemx)
258+
SHMEM_TYPE_REDUCE_OPX(xor, _int32, int32_t, shmemx)
259+
SHMEM_TYPE_REDUCE_OPX(xor, _int64, int64_t, shmemx)
197260

198261
SHMEM_TYPE_REDUCE_OP(max, _short, short, shmem)
199262
SHMEM_TYPE_REDUCE_OP(max, _int, int, shmem)
@@ -202,9 +265,9 @@ SHMEM_TYPE_REDUCE_OP(max, _longlong, long long, shmem)
202265
SHMEM_TYPE_REDUCE_OP(max, _float, float, shmem)
203266
SHMEM_TYPE_REDUCE_OP(max, _double, double, shmem)
204267
SHMEM_TYPE_REDUCE_OP(max, _longdouble, long double, shmem)
205-
SHMEM_TYPE_REDUCE_OP(max, _int16, int16_t, shmemx)
206-
SHMEM_TYPE_REDUCE_OP(max, _int32, int32_t, shmemx)
207-
SHMEM_TYPE_REDUCE_OP(max, _int64, int64_t, shmemx)
268+
SHMEM_TYPE_REDUCE_OPX(max, _int16, int16_t, shmemx)
269+
SHMEM_TYPE_REDUCE_OPX(max, _int32, int32_t, shmemx)
270+
SHMEM_TYPE_REDUCE_OPX(max, _int64, int64_t, shmemx)
208271

209272
SHMEM_TYPE_REDUCE_OP(min, _short, short, shmem)
210273
SHMEM_TYPE_REDUCE_OP(min, _int, int, shmem)
@@ -213,9 +276,9 @@ SHMEM_TYPE_REDUCE_OP(min, _longlong, long long, shmem)
213276
SHMEM_TYPE_REDUCE_OP(min, _float, float, shmem)
214277
SHMEM_TYPE_REDUCE_OP(min, _double, double, shmem)
215278
SHMEM_TYPE_REDUCE_OP(min, _longdouble, long double, shmem)
216-
SHMEM_TYPE_REDUCE_OP(min, _int16, int16_t, shmemx)
217-
SHMEM_TYPE_REDUCE_OP(min, _int32, int32_t, shmemx)
218-
SHMEM_TYPE_REDUCE_OP(min, _int64, int64_t, shmemx)
279+
SHMEM_TYPE_REDUCE_OPX(min, _int16, int16_t, shmemx)
280+
SHMEM_TYPE_REDUCE_OPX(min, _int32, int32_t, shmemx)
281+
SHMEM_TYPE_REDUCE_OPX(min, _int64, int64_t, shmemx)
219282

220283
SHMEM_TYPE_REDUCE_OP(sum, _short, short, shmem)
221284
SHMEM_TYPE_REDUCE_OP(sum, _int, int, shmem)
@@ -226,9 +289,9 @@ SHMEM_TYPE_REDUCE_OP(sum, _double, double, shmem)
226289
SHMEM_TYPE_REDUCE_OP(sum, _longdouble, long double, shmem)
227290
SHMEM_TYPE_REDUCE_OP(sum, _complexf, float complex, shmem)
228291
SHMEM_TYPE_REDUCE_OP(sum, _complexd, double complex, shmem)
229-
SHMEM_TYPE_REDUCE_OP(sum, _int16, int16_t, shmemx)
230-
SHMEM_TYPE_REDUCE_OP(sum, _int32, int32_t, shmemx)
231-
SHMEM_TYPE_REDUCE_OP(sum, _int64, int64_t, shmemx)
292+
SHMEM_TYPE_REDUCE_OPX(sum, _int16, int16_t, shmemx)
293+
SHMEM_TYPE_REDUCE_OPX(sum, _int32, int32_t, shmemx)
294+
SHMEM_TYPE_REDUCE_OPX(sum, _int64, int64_t, shmemx)
232295

233296
SHMEM_TYPE_REDUCE_OP(prod, _short, short, shmem)
234297
SHMEM_TYPE_REDUCE_OP(prod, _int, int, shmem)
@@ -239,6 +302,6 @@ SHMEM_TYPE_REDUCE_OP(prod, _double, double, shmem)
239302
SHMEM_TYPE_REDUCE_OP(prod, _longdouble, long double, shmem)
240303
SHMEM_TYPE_REDUCE_OP(prod, _complexf, float complex, shmem)
241304
SHMEM_TYPE_REDUCE_OP(prod, _complexd, double complex, shmem)
242-
SHMEM_TYPE_REDUCE_OP(prod, _int16, int16_t, shmemx)
243-
SHMEM_TYPE_REDUCE_OP(prod, _int32, int32_t, shmemx)
244-
SHMEM_TYPE_REDUCE_OP(prod, _int64, int64_t, shmemx)
305+
SHMEM_TYPE_REDUCE_OPX(prod, _int16, int16_t, shmemx)
306+
SHMEM_TYPE_REDUCE_OPX(prod, _int32, int32_t, shmemx)
307+
SHMEM_TYPE_REDUCE_OPX(prod, _int64, int64_t, shmemx)

oshmem/shmem/man/man3/shmem_addr_accessible.3in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ C or C++:
2222
.Vb
2323
#include <mpp/shmem.h>
2424

25-
int shmem_addr_accessible(void *addr, int pe);
25+
int shmem_addr_accessible(const void *addr, int pe);
2626
.Ve
2727
Fortran:
2828
.Vb

oshmem/shmem/man/man3/shmem_char_g.3in

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@ C or C++:
2929
#include <mpp/shmem.h>
3030

3131

32-
char shmem_char_g(char *addr, int pe);
32+
char shmem_char_g(const char *addr, int pe);
3333

34-
short shmem_short_g(short *addr, int pe);
34+
short shmem_short_g(const short *addr, int pe);
3535

36-
int shmem_int_g(int *addr, int pe);
36+
int shmem_int_g(const int *addr, int pe);
3737

38-
long shmem_long_g(long *addr, int pe);
38+
long shmem_long_g(const long *addr, int pe);
3939

40-
long shmem_longlong_g(long long *addr, int pe);
40+
long shmem_longlong_g(const long long *addr, int pe);
4141

42-
float shmem_float_g(float *addr, int pe);
42+
float shmem_float_g(const float *addr, int pe);
4343

44-
double shmem_double_g(double *addr, int pe);
44+
double shmem_double_g(const double *addr, int pe);
4545

46-
long shmem_longdouble_g(long double *addr, int pe);
46+
long shmem_longdouble_g(const long double *addr, int pe);
4747

4848
.Ve
4949
.SH DESCRIPTION

oshmem/shmem/man/man3/shmem_ptr.3in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ C or C++:
2323
.Vb
2424
#include <mpp/shmem.h>
2525

26-
void *shmem_ptr(void *target, int pe);
26+
void *shmem_ptr(const void *target, int pe);
2727
.Ve
2828
Fortran:
2929
.Vb

oshmem/shmem/man/man3/shmem_short_and_to_all.3in

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" -*- nroff -*-
22
.\" Copyright (c) 2015 University of Houston. All rights reserved.
3-
.\" Copyright (c) 2015 Mellanox Technologies, Inc.
3+
.\" Copyright (c) 2014-2016 Mellanox Technologies, Inc.
44
.\" $COPYRIGHT$
55
.de Vb
66
.ft CW
@@ -28,19 +28,19 @@ C or C++:
2828
.Vb
2929
#include <mpp/shmem.h>
3030

31-
void shmem_int_and_to_all(int *target, int *source,
31+
void shmem_int_and_to_all(int *target, const int *source,
3232
int nreduce, int PE_start, int logPE_stride, int PE_size,
3333
int *pWrk, long *pSync);
3434

35-
void shmem_long_and_to_all(long *target, long *source,
35+
void shmem_long_and_to_all(long *target, const long *source,
3636
int nreduce, int PE_start, int logPE_stride, int PE_size,
3737
long *pWrk, long *pSync);
3838

3939
void shmem_longlong_and_to_all(long long *target,
40-
long long *source, int nreduce, int PE_start, int logPE_stride,
40+
const long long *source, int nreduce, int PE_start, int logPE_stride,
4141
int PE_size, long long *pWrk, long *pSync);
4242

43-
void shmem_short_and_to_all(short *target, short *source,
43+
void shmem_short_and_to_all(short *target, const short *source,
4444
int nreduce, int PE_start, int logPE_stride, int PE_size,
4545
short *pWrk, long *pSync);
4646

0 commit comments

Comments
 (0)