Skip to content

Commit abe7ba5

Browse files
committed
oshmem: Align OSHMEM API with spec v1.3 (Add nonblocking put/get C functions)
1 parent 8464b61 commit abe7ba5

File tree

5 files changed

+250
-3
lines changed

5 files changed

+250
-3
lines changed

oshmem/shmem/c/Makefile.am

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2013-2015 Mellanox Technologies, Inc.
2+
# Copyright (c) 2013-2016 Mellanox Technologies, Inc.
33
# All rights reserved
44
# Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
55
# $COPYRIGHT$
@@ -40,6 +40,8 @@ OSHMEM_API_SOURCES = \
4040
shmem_wait.c \
4141
shmem_iget.c \
4242
shmem_iput.c \
43+
shmem_get_nb.c \
44+
shmem_put_nb.c \
4345
shmem_udcflush.c \
4446
shmem_udcflush_line.c \
4547
shmem_set_cache_inv.c \

oshmem/shmem/c/profile/Makefile.am

Lines changed: 3 additions & 1 deletion
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 (c) 2014 Cisco Systems, Inc. All rights reserved.
55
# $COPYRIGHT$
@@ -52,6 +52,8 @@ OSHMEM_API_SOURCES = \
5252
pshmem_wait.c \
5353
pshmem_iget.c \
5454
pshmem_iput.c \
55+
pshmem_get_nb.c \
56+
pshmem_put_nb.c \
5557
pshmem_udcflush.c \
5658
pshmem_udcflush_line.c \
5759
pshmem_set_cache_inv.c \

oshmem/shmem/c/profile/defines.h

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013-2015 Mellanox Technologies, Inc.
2+
* Copyright (c) 2013-2016 Mellanox Technologies, Inc.
33
* All rights reserved.
44
* $COPYRIGHT$
55
*
@@ -107,6 +107,24 @@
107107
#define shmem_iput64 pshmem_iput64
108108
#define shmem_iput128 pshmem_iput128
109109

110+
/*
111+
* Non-block data put routines
112+
*/
113+
#define shmem_char_put_nbi pshmem_char_put_nbi
114+
#define shmem_short_put_nbi pshmem_short_put_nbi
115+
#define shmem_int_put_nbi pshmem_int_put_nbi
116+
#define shmem_long_put_nbi pshmem_long_put_nbi
117+
#define shmem_float_put_nbi pshmem_float_put_nbi
118+
#define shmem_double_put_nbi pshmem_double_put_nbi
119+
#define shmem_longlong_put_nbi pshmem_longlong_put_nbi
120+
#define shmem_longdouble_put_nbi pshmem_longdouble_put_nbi
121+
#define shmem_put8_nbi pshmem_put8_nbi
122+
#define shmem_put16_nbi pshmem_put16_nbi
123+
#define shmem_put32_nbi pshmem_put32_nbi
124+
#define shmem_put64_nbi pshmem_put64_nbi
125+
#define shmem_put128_nbi pshmem_put128_nbi
126+
#define shmem_putmem_nbi pshmem_putmem_nbi
127+
110128
/*
111129
* Elemental get routines
112130
*/
@@ -154,6 +172,24 @@
154172
#define shmem_iget64 pshmem_iget64
155173
#define shmem_iget128 pshmem_iget128
156174

175+
/*
176+
* Non-block data get routines
177+
*/
178+
#define shmem_char_get_nbi pshmem_char_get_nbi
179+
#define shmem_short_get_nbi pshmem_short_get_nbi
180+
#define shmem_int_get_nbi pshmem_int_get_nbi
181+
#define shmem_long_get_nbi pshmem_long_get_nbi
182+
#define shmem_float_get_nbi pshmem_float_get_nbi
183+
#define shmem_double_get_nbi pshmem_double_get_nbi
184+
#define shmem_longlong_get_nbi pshmem_longlong_get_nbi
185+
#define shmem_longdouble_get_nbi pshmem_longdouble_get_nbi
186+
#define shmem_get8_nbi pshmem_get8_nbi
187+
#define shmem_get16_nbi pshmem_get16_nbi
188+
#define shmem_get32_nbi pshmem_get32_nbi
189+
#define shmem_get64_nbi pshmem_get64_nbi
190+
#define shmem_get128_nbi pshmem_get128_nbi
191+
#define shmem_getmem_nbi pshmem_getmem_nbi
192+
157193
/*
158194
* Atomic operations
159195
*/

oshmem/shmem/c/shmem_get_nb.c

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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/spml/spml.h"
18+
19+
/*
20+
* These routines retrieve data from a contiguous data object on a remote PE.
21+
* The shmem_get() routines transfer nelems elements of the data object at address source
22+
* on the remote PE (pe), to the data object at address target on the local PE. These routines
23+
* return after the data has been copied to address target on the local pe.
24+
*/
25+
#define SHMEM_TYPE_GET_NB(type_name, type) \
26+
void shmem##type_name##_get_nbi(type *target, const type *source, size_t nelems, int pe) \
27+
{ \
28+
int rc = OSHMEM_SUCCESS; \
29+
size_t size = 0; \
30+
\
31+
RUNTIME_CHECK_INIT(); \
32+
RUNTIME_CHECK_PE(pe); \
33+
RUNTIME_CHECK_ADDR(source); \
34+
\
35+
size = nelems * sizeof(type); \
36+
rc = MCA_SPML_CALL(get_nb( \
37+
(void *)source, \
38+
size, \
39+
(void *)target, \
40+
pe, NULL)); \
41+
RUNTIME_CHECK_RC(rc); \
42+
\
43+
return ; \
44+
}
45+
46+
#if OSHMEM_PROFILING
47+
#include "oshmem/include/pshmem.h"
48+
#pragma weak shmem_char_get_nbi = pshmem_char_get_nbi
49+
#pragma weak shmem_short_get_nbi = pshmem_short_get_nbi
50+
#pragma weak shmem_int_get_nbi = pshmem_int_get_nbi
51+
#pragma weak shmem_long_get_nbi = pshmem_long_get_nbi
52+
#pragma weak shmem_longlong_get_nbi = pshmem_longlong_get_nbi
53+
#pragma weak shmem_float_get_nbi = pshmem_float_get_nbi
54+
#pragma weak shmem_double_get_nbi = pshmem_double_get_nbi
55+
#pragma weak shmem_longdouble_get_nbi = pshmem_longdouble_get_nbi
56+
#pragma weak shmem_get8_nbi = pshmem_get8_nbi
57+
#pragma weak shmem_get16_nbi = pshmem_get16_nbi
58+
#pragma weak shmem_get32_nbi = pshmem_get32_nbi
59+
#pragma weak shmem_get64_nbi = pshmem_get64_nbi
60+
#pragma weak shmem_get128_nbi = pshmem_get128_nbi
61+
#pragma weak shmem_getmem_nbi = pshmem_getmem_nbi
62+
#include "oshmem/shmem/c/profile/defines.h"
63+
#endif
64+
65+
SHMEM_TYPE_GET_NB(_char, char)
66+
SHMEM_TYPE_GET_NB(_short, short)
67+
SHMEM_TYPE_GET_NB(_int, int)
68+
SHMEM_TYPE_GET_NB(_long, long)
69+
SHMEM_TYPE_GET_NB(_longlong, long long)
70+
SHMEM_TYPE_GET_NB(_float, float)
71+
SHMEM_TYPE_GET_NB(_double, double)
72+
SHMEM_TYPE_GET_NB(_longdouble, long double)
73+
74+
#define SHMEM_TYPE_GETMEM_NB(name, element_size, prefix) \
75+
void prefix##name##_nbi(void *target, const void *source, size_t nelems, int pe) \
76+
{ \
77+
int rc = OSHMEM_SUCCESS; \
78+
size_t size = 0; \
79+
\
80+
RUNTIME_CHECK_INIT(); \
81+
RUNTIME_CHECK_PE(pe); \
82+
RUNTIME_CHECK_ADDR(source); \
83+
\
84+
size = nelems * element_size; \
85+
rc = MCA_SPML_CALL(get_nb( \
86+
(void *)source, \
87+
size, \
88+
(void *)target, \
89+
pe, NULL)); \
90+
RUNTIME_CHECK_RC(rc); \
91+
\
92+
return ; \
93+
}
94+
95+
SHMEM_TYPE_GETMEM_NB(_get8, 1, shmem)
96+
SHMEM_TYPE_GETMEM_NB(_get16, 2, shmem)
97+
SHMEM_TYPE_GETMEM_NB(_get32, 4, shmem)
98+
SHMEM_TYPE_GETMEM_NB(_get64, 8, shmem)
99+
SHMEM_TYPE_GETMEM_NB(_get128, 16, shmem)
100+
SHMEM_TYPE_GETMEM_NB(_getmem, 1, shmem)

oshmem/shmem/c/shmem_put_nb.c

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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/spml/spml.h"
18+
19+
/*
20+
* The nonblocking put routines provide a method for copying data from a contiguous local data
21+
* object to a data object on a specified PE.
22+
* These routines transfer nelems elements of the data object at address source on the calling
23+
* PE, to the data object at address target on the remote PE pe. These routines start the
24+
* remote transfer and may return before the data is delivered to the remote PE. The delivery
25+
* of data into the data object on the destination PE from different put calls may occur in any
26+
* order. Because of this, two successive put operations may deliver data out of order unless a
27+
* call to shmem_fence() is introduced between the two calls.
28+
* The routines return after posting the operation. The operation is considered complete after a
29+
* subsequent call to shmem_quiet. At the completion of shmem_quiet, the data has been copied
30+
* into the dest array on the destination PE.
31+
*/
32+
#define SHMEM_TYPE_PUT_NB(type_name, type) \
33+
void shmem##type_name##_put_nbi(type *target, const type *source, size_t len, int pe) \
34+
{ \
35+
int rc = OSHMEM_SUCCESS; \
36+
size_t size = 0; \
37+
\
38+
RUNTIME_CHECK_INIT(); \
39+
RUNTIME_CHECK_PE(pe); \
40+
RUNTIME_CHECK_ADDR(target); \
41+
\
42+
size = len * sizeof(type); \
43+
rc = MCA_SPML_CALL(put_nb( \
44+
(void *)target, \
45+
size, \
46+
(void *)source, \
47+
pe, NULL)); \
48+
RUNTIME_CHECK_RC(rc); \
49+
\
50+
return ; \
51+
}
52+
53+
#if OSHMEM_PROFILING
54+
#include "oshmem/include/pshmem.h"
55+
#pragma weak shmem_char_put_nbi = pshmem_char_put_nbi
56+
#pragma weak shmem_short_put_nbi = pshmem_short_put_nbi
57+
#pragma weak shmem_int_put_nbi = pshmem_int_put_nbi
58+
#pragma weak shmem_long_put_nbi = pshmem_long_put_nbi
59+
#pragma weak shmem_longlong_put_nbi = pshmem_longlong_put_nbi
60+
#pragma weak shmem_float_put_nbi = pshmem_float_put_nbi
61+
#pragma weak shmem_double_put_nbi = pshmem_double_put_nbi
62+
#pragma weak shmem_longdouble_put_nbi = pshmem_longdouble_put_nbi
63+
#pragma weak shmem_put8_nbi = pshmem_put8_nbi
64+
#pragma weak shmem_put16_nbi = pshmem_put16_nbi
65+
#pragma weak shmem_put32_nbi = pshmem_put32_nbi
66+
#pragma weak shmem_put64_nbi = pshmem_put64_nbi
67+
#pragma weak shmem_put128_nbi = pshmem_put128_nbi
68+
#pragma weak shmem_putmem_nbi = pshmem_putmem_nbi
69+
#include "oshmem/shmem/c/profile/defines.h"
70+
#endif
71+
72+
SHMEM_TYPE_PUT_NB(_char, char)
73+
SHMEM_TYPE_PUT_NB(_short, short)
74+
SHMEM_TYPE_PUT_NB(_int, int)
75+
SHMEM_TYPE_PUT_NB(_long, long)
76+
SHMEM_TYPE_PUT_NB(_longlong, long long)
77+
SHMEM_TYPE_PUT_NB(_float, float)
78+
SHMEM_TYPE_PUT_NB(_double, double)
79+
SHMEM_TYPE_PUT_NB(_longdouble, long double)
80+
81+
#define SHMEM_TYPE_PUTMEM_NB(name, element_size, prefix) \
82+
void prefix##name##_nbi(void *target, const void *source, size_t nelems, int pe) \
83+
{ \
84+
int rc = OSHMEM_SUCCESS; \
85+
size_t size = 0; \
86+
\
87+
RUNTIME_CHECK_INIT(); \
88+
RUNTIME_CHECK_PE(pe); \
89+
RUNTIME_CHECK_ADDR(target); \
90+
\
91+
size = nelems * element_size; \
92+
rc = MCA_SPML_CALL(put_nb( \
93+
(void *)target, \
94+
size, \
95+
(void *)source, \
96+
pe, NULL)); \
97+
RUNTIME_CHECK_RC(rc); \
98+
\
99+
return ; \
100+
}
101+
102+
SHMEM_TYPE_PUTMEM_NB(_put8, 1, shmem)
103+
SHMEM_TYPE_PUTMEM_NB(_put16, 2, shmem)
104+
SHMEM_TYPE_PUTMEM_NB(_put32, 4, shmem)
105+
SHMEM_TYPE_PUTMEM_NB(_put64, 8, shmem)
106+
SHMEM_TYPE_PUTMEM_NB(_put128, 16, shmem)
107+
SHMEM_TYPE_PUTMEM_NB(_putmem, 1, shmem)

0 commit comments

Comments
 (0)