Skip to content

Commit bd6eaac

Browse files
committed
oshmem: Align OSHMEM API with spec v1.3 (Add alltoall C function)
1 parent 50906b3 commit bd6eaac

File tree

4 files changed

+149
-2
lines changed

4 files changed

+149
-2
lines changed

oshmem/shmem/c/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ OSHMEM_API_SOURCES = \
3131
shmem_get.c \
3232
shmem_broadcast.c \
3333
shmem_collect.c \
34+
shmem_alltoall.c \
3435
shmem_ptr.c \
3536
shmem_pe_accessible.c \
3637
shmem_addr_accessible.c \

oshmem/shmem/c/profile/Makefile.am

Lines changed: 2 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$
@@ -41,6 +41,7 @@ OSHMEM_API_SOURCES = \
4141
pshmem_put.c \
4242
pshmem_g.c \
4343
pshmem_get.c \
44+
pshmem_alltoall.c \
4445
pshmem_broadcast.c \
4546
pshmem_collect.c \
4647
pshmem_ptr.c \

oshmem/shmem/c/profile/defines.h

Lines changed: 9 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
*
@@ -324,6 +324,14 @@
324324
#define shmemx_int32_prod_to_all pshmemx_int32_prod_to_all
325325
#define shmemx_int64_prod_to_all pshmemx_int64_prod_to_all
326326

327+
/*
328+
* Alltoall routines
329+
*/
330+
#define shmem_alltoall32 pshmem_alltoall32
331+
#define shmem_alltoall64 pshmem_alltoall64
332+
#define shmem_alltoalls32 pshmem_alltoalls32
333+
#define shmem_alltoalls64 pshmem_alltoalls64
334+
327335
/*
328336
* Platform specific cache management routines
329337
*/

oshmem/shmem/c/shmem_alltoall.c

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
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 "orte/mca/grpcomm/grpcomm.h"
16+
17+
#include "oshmem/runtime/runtime.h"
18+
19+
#include "oshmem/mca/scoll/scoll.h"
20+
21+
#include "oshmem/proc/proc.h"
22+
#include "oshmem/proc/proc_group_cache.h"
23+
24+
static void _shmem_alltoall(void *target,
25+
const void *source,
26+
ptrdiff_t dst, ptrdiff_t sst,
27+
size_t nelems,
28+
size_t element_size,
29+
int PE_start,
30+
int logPE_stride,
31+
int PE_size,
32+
long *pSync);
33+
34+
#define SHMEM_TYPE_ALLTOALL(name, element_size) \
35+
void shmem##name(void *target, \
36+
const void *source, \
37+
size_t nelems, \
38+
int PE_start, \
39+
int logPE_stride, \
40+
int PE_size, \
41+
long *pSync) \
42+
{ \
43+
RUNTIME_CHECK_INIT(); \
44+
RUNTIME_CHECK_ADDR(target); \
45+
RUNTIME_CHECK_ADDR(source); \
46+
\
47+
_shmem_alltoall(target, source, 1, 1, nelems * element_size, \
48+
PE_start, logPE_stride, PE_size, \
49+
pSync); \
50+
}
51+
52+
#define SHMEM_TYPE_ALLTOALLS(name, element_size) \
53+
void shmem##name(void *target, \
54+
const void *source, \
55+
ptrdiff_t dst, ptrdiff_t sst, \
56+
size_t nelems, \
57+
int PE_start, \
58+
int logPE_stride, \
59+
int PE_size, \
60+
long *pSync) \
61+
{ \
62+
RUNTIME_CHECK_INIT(); \
63+
RUNTIME_CHECK_ADDR(target); \
64+
RUNTIME_CHECK_ADDR(source); \
65+
\
66+
_shmem_alltoall(target, source, dst, sst, nelems * element_size, \
67+
PE_start, logPE_stride, PE_size, \
68+
pSync); \
69+
}
70+
71+
static void _shmem_alltoall(void *target,
72+
const void *source,
73+
ptrdiff_t dst, ptrdiff_t sst,
74+
size_t nelems,
75+
size_t element_size,
76+
int PE_start,
77+
int logPE_stride,
78+
int PE_size,
79+
long *pSync)
80+
{
81+
int rc = OSHMEM_SUCCESS;
82+
oshmem_group_t* group = NULL;
83+
84+
if ((0 <= PE_start) && (0 <= logPE_stride)) {
85+
/* Create group basing PE_start, logPE_stride and PE_size */
86+
#if OSHMEM_GROUP_CACHE_ENABLED == 0
87+
group = oshmem_proc_group_create(PE_start, (1 << logPE_stride), PE_size);
88+
if (!group)
89+
rc = OSHMEM_ERROR;
90+
#else
91+
group = find_group_in_cache(PE_start, logPE_stride, PE_size);
92+
if (!group) {
93+
group = oshmem_proc_group_create(PE_start,
94+
(1 << logPE_stride),
95+
PE_size);
96+
if (!group) {
97+
rc = OSHMEM_ERROR;
98+
} else {
99+
cache_group(group, PE_start, logPE_stride, PE_size);
100+
}
101+
}
102+
#endif /* OSHMEM_GROUP_CACHE_ENABLED */
103+
104+
/* Collective operation call */
105+
if (rc == OSHMEM_SUCCESS) {
106+
/* Call collective alltoall operation */
107+
rc = group->g_scoll.scoll_alltoall(group,
108+
target,
109+
source,
110+
dst,
111+
sst,
112+
nelems,
113+
element_size,
114+
pSync,
115+
SCOLL_DEFAULT_ALG);
116+
}
117+
#if OSHMEM_GROUP_CACHE_ENABLED == 0
118+
if ( rc == OSHMEM_SUCCESS ) {
119+
oshmem_proc_group_destroy(group);
120+
}
121+
#endif /* OSHMEM_GROUP_CACHE_ENABLED */
122+
}
123+
}
124+
125+
#if OSHMEM_PROFILING
126+
#include "oshmem/include/pshmem.h"
127+
#pragma weak shmem_alltoall32 = pshmem_alltoall32
128+
#pragma weak shmem_alltoall64 = pshmem_alltoall64
129+
#pragma weak shmem_alltoalls32 = pshmem_alltoalls32
130+
#pragma weak shmem_alltoalls64 = pshmem_alltoalls64
131+
#include "oshmem/shmem/c/profile/defines.h"
132+
#endif
133+
134+
SHMEM_TYPE_ALLTOALL(_alltoall32, sizeof(uint32_t))
135+
SHMEM_TYPE_ALLTOALL(_alltoall64, sizeof(uint64_t))
136+
SHMEM_TYPE_ALLTOALLS(_alltoalls32, sizeof(uint32_t))
137+
SHMEM_TYPE_ALLTOALLS(_alltoalls64, sizeof(uint64_t))

0 commit comments

Comments
 (0)