Skip to content
This repository has been archived by the owner on Sep 30, 2022. It is now read-only.

v2.x: oshmem: Align OSHMEM API with spec v1.3 (alltoall) #1042

Merged
merged 5 commits into from
Sep 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions oshmem/include/pshmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ OSHMEM_DECLSPEC void pshmem_collect32(void *target, const void *source, size_t n
OSHMEM_DECLSPEC void pshmem_collect64(void *target, const void *source, size_t nlong, int PE_start, int logPE_stride, int PE_size, long *pSync);
OSHMEM_DECLSPEC void pshmem_fcollect32(void *target, const void *source, size_t nlong, int PE_start, int logPE_stride, int PE_size, long *pSync);
OSHMEM_DECLSPEC void pshmem_fcollect64(void *target, const void *source, size_t nlong, int PE_start, int logPE_stride, int PE_size, long *pSync);
OSHMEM_DECLSPEC void pshmem_alltoall32(void *target, const void *source, size_t nelems, int PE_start, int logPE_stride, int PE_size, long *pSync);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i did not see that in master, so i committed it in open-mpi/ompi@cb84f58

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ggouaillardet you are right. I noticed it too yesterday but forgot to push. Thank you.

OSHMEM_DECLSPEC void pshmem_alltoall64(void *target, const void *source, size_t nelems, int PE_start, int logPE_stride, int PE_size, long *pSync);
OSHMEM_DECLSPEC void pshmem_alltoalls32(void *target, const void *source, ptrdiff_t dst, ptrdiff_t sst, size_t nelems, int PE_start, int logPE_stride, int PE_size, long *pSync);
OSHMEM_DECLSPEC void pshmem_alltoalls64(void *target, const void *source, ptrdiff_t dst, ptrdiff_t sst, size_t nelems, int PE_start, int logPE_stride, int PE_size, long *pSync);

/*
* Reduction routines
Expand Down
7 changes: 7 additions & 0 deletions oshmem/include/shmem.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,15 @@ enum shmem_wait_ops {
#define _SHMEM_BCAST_SYNC_SIZE (1 + _SHMEM_BARRIER_SYNC_SIZE)
#define _SHMEM_COLLECT_SYNC_SIZE (1 + _SHMEM_BCAST_SYNC_SIZE)
#define _SHMEM_REDUCE_SYNC_SIZE (1 + _SHMEM_BCAST_SYNC_SIZE)
#define _SHMEM_ALLTOALL_SYNC_SIZE (1)
#define _SHMEM_REDUCE_MIN_WRKDATA_SIZE (1)
#define _SHMEM_SYNC_VALUE (-1)

#define SHMEM_BARRIER_SYNC_SIZE _SHMEM_BARRIER_SYNC_SIZE
#define SHMEM_BCAST_SYNC_SIZE _SHMEM_BCAST_SYNC_SIZE
#define SHMEM_COLLECT_SYNC_SIZE _SHMEM_COLLECT_SYNC_SIZE
#define SHMEM_REDUCE_SYNC_SIZE _SHMEM_REDUCE_SYNC_SIZE
#define SHMEM_ALLTOALL_SYNC_SIZE _SHMEM_ALLTOALL_SYNC_SIZE
#define SHMEM_REDUCE_MIN_WRKDATA_SIZE _SHMEM_REDUCE_MIN_WRKDATA_SIZE
#define SHMEM_SYNC_VALUE _SHMEM_SYNC_VALUE

Expand Down Expand Up @@ -308,6 +310,11 @@ OSHMEM_DECLSPEC void shmem_collect32(void *target, const void *source, size_t nl
OSHMEM_DECLSPEC void shmem_collect64(void *target, const void *source, size_t nlong, int PE_start, int logPE_stride, int PE_size, long *pSync);
OSHMEM_DECLSPEC void shmem_fcollect32(void *target, const void *source, size_t nlong, int PE_start, int logPE_stride, int PE_size, long *pSync);
OSHMEM_DECLSPEC void shmem_fcollect64(void *target, const void *source, size_t nlong, int PE_start, int logPE_stride, int PE_size, long *pSync);
OSHMEM_DECLSPEC void shmem_alltoall32(void *target, const void *source, size_t nelems, int PE_start, int logPE_stride, int PE_size, long *pSync);
OSHMEM_DECLSPEC void shmem_alltoall64(void *target, const void *source, size_t nelems, int PE_start, int logPE_stride, int PE_size, long *pSync);
OSHMEM_DECLSPEC void shmem_alltoalls32(void *target, const void *source, ptrdiff_t dst, ptrdiff_t sst, size_t nelems, int PE_start, int logPE_stride, int PE_size, long *pSync);
OSHMEM_DECLSPEC void shmem_alltoalls64(void *target, const void *source, ptrdiff_t dst, ptrdiff_t sst, size_t nelems, int PE_start, int logPE_stride, int PE_size, long *pSync);


/*
* Reduction routines
Expand Down
1 change: 1 addition & 0 deletions oshmem/mca/scoll/base/scoll_base_frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ static void scoll_base_module_construct(mca_scoll_base_module_t *m)
m->scoll_broadcast = NULL;
m->scoll_collect = NULL;
m->scoll_reduce = NULL;
m->scoll_alltoall = NULL;
m->scoll_module_enable = NULL;
}

Expand Down
28 changes: 24 additions & 4 deletions oshmem/mca/scoll/base/scoll_base_select.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,22 @@ static int scoll_null_reduce(struct oshmem_group_t *group,
return OSHMEM_SUCCESS;
}

static int scoll_null_alltoall(struct oshmem_group_t *group,
void *target,
const void *source,
ptrdiff_t dst, ptrdiff_t sst,
size_t nlong,
long *pSync,
int alg)
{
if (oshmem_proc_group_is_member(group)) {
SCOLL_ERROR("internal error");
oshmem_shmem_abort(-1);
return OSHMEM_ERROR;
}
return OSHMEM_SUCCESS;
}

/*
* Stuff for the OBJ interface
*/
Expand Down Expand Up @@ -160,6 +176,7 @@ int mca_scoll_base_group_unselect(struct oshmem_group_t * group)
CLOSE(group, broadcast);
CLOSE(group, collect);
CLOSE(group, reduce);
CLOSE(group, alltoall);

/* All done */
return OSHMEM_SUCCESS;
Expand All @@ -184,6 +201,7 @@ int mca_scoll_base_select(struct oshmem_group_t *group)
group->g_scoll.scoll_broadcast = scoll_null_broadcast;
group->g_scoll.scoll_collect = scoll_null_collect;
group->g_scoll.scoll_reduce = scoll_null_reduce;
group->g_scoll.scoll_alltoall = scoll_null_alltoall;
return OSHMEM_SUCCESS;
}
SCOLL_VERBOSE(10,
Expand All @@ -206,10 +224,11 @@ int mca_scoll_base_select(struct oshmem_group_t *group)
if (OSHMEM_SUCCESS != ret) {
mca_scoll_base_group_unselect(group);
} else {
COPY(avail->ac_module, group, barrier);
COPY(avail->ac_module, group, broadcast);
COPY(avail->ac_module, group, collect);
COPY(avail->ac_module, group, reduce);
COPY(avail->ac_module, group, barrier);
COPY(avail->ac_module, group, alltoall);
}
OBJ_RELEASE(avail->ac_module);
OBJ_RELEASE(avail);
Expand All @@ -220,16 +239,17 @@ int mca_scoll_base_select(struct oshmem_group_t *group)
if ((NULL == group->g_scoll.scoll_barrier)
|| (NULL == group->g_scoll.scoll_broadcast)
|| (NULL == group->g_scoll.scoll_collect)
|| (NULL == group->g_scoll.scoll_reduce)) {
|| (NULL == group->g_scoll.scoll_reduce)
|| (NULL == group->g_scoll.scoll_alltoall)) {
mca_scoll_base_group_unselect(group);
return OSHMEM_ERR_NOT_FOUND;
}

return OSHMEM_SUCCESS;
}

static int avail_coll_compare (opal_list_item_t **a,
opal_list_item_t **b)
static int avail_coll_compare(opal_list_item_t **a,
opal_list_item_t **b)
{
avail_com_t *acom = (avail_com_t *) *a;
avail_com_t *bcom = (avail_com_t *) *b;
Expand Down
5 changes: 3 additions & 2 deletions oshmem/mca/scoll/basic/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013 Mellanox Technologies, Inc.
# Copyright (c) 2013-2016 Mellanox Technologies, Inc.
# All rights reserved.
# $COPYRIGHT$
#
Expand All @@ -15,7 +15,8 @@ sources = \
scoll_basic_barrier.c \
scoll_basic_broadcast.c \
scoll_basic_collect.c \
scoll_basic_reduce.c
scoll_basic_reduce.c \
scoll_basic_alltoall.c


# Make the output library in this directory, and name it either
Expand Down
10 changes: 9 additions & 1 deletion oshmem/mca/scoll/basic/scoll_basic.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013 Mellanox Technologies, Inc.
* Copyright (c) 2013-2016 Mellanox Technologies, Inc.
* All rights reserved.
* $COPYRIGHT$
*
Expand Down Expand Up @@ -77,6 +77,14 @@ int mca_scoll_basic_reduce(struct oshmem_group_t *group,
long *pSync,
void *pWrk,
int alg);
int mca_scoll_basic_alltoall(struct oshmem_group_t *group,
void *target,
const void *source,
ptrdiff_t dst, ptrdiff_t sst,
size_t nelems,
size_t element_size,
long *pSync,
int alg);

static inline unsigned int scoll_log2(unsigned long val)
{
Expand Down
118 changes: 118 additions & 0 deletions oshmem/mca/scoll/basic/scoll_basic_alltoall.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
* Copyright (c) 2016 Mellanox Technologies, Inc.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/

#include "oshmem_config.h"
#include <stdio.h>
#include <stdlib.h>

#include "oshmem/constants.h"
#include "oshmem/op/op.h"
#include "oshmem/mca/spml/spml.h"
#include "oshmem/mca/scoll/scoll.h"
#include "oshmem/mca/scoll/base/base.h"
#include "scoll_basic.h"

static int _algorithm_simple(struct oshmem_group_t *group,
void *target,
const void *source,
ptrdiff_t dst, ptrdiff_t sst,
size_t nelems,
size_t element_size,
long *pSync);

int mca_scoll_basic_alltoall(struct oshmem_group_t *group,
void *target,
const void *source,
ptrdiff_t dst, ptrdiff_t sst,
size_t nelems,
size_t element_size,
long *pSync,
int alg)
{
int rc = OSHMEM_SUCCESS;

/* Arguments validation */
if (!group) {
SCOLL_ERROR("Active set (group) of PE is not defined");
rc = OSHMEM_ERR_BAD_PARAM;
}

/* Check if this PE is part of the group */
if ((rc == OSHMEM_SUCCESS) && oshmem_proc_group_is_member(group)) {
int i = 0;

if (pSync) {
rc = _algorithm_simple(group,
target,
source,
dst,
sst,
nelems,
element_size,
pSync);
} else {
SCOLL_ERROR("Incorrect argument pSync");
rc = OSHMEM_ERR_BAD_PARAM;
}

/* Restore initial values */
SCOLL_VERBOSE(12,
"PE#%d Restore special synchronization array",
group->my_pe);
for (i = 0; pSync && (i < _SHMEM_ALLTOALL_SYNC_SIZE); i++) {
pSync[i] = _SHMEM_SYNC_VALUE;
}
}

return rc;
}

static int _algorithm_simple(struct oshmem_group_t *group,
void *target,
const void *source,
ptrdiff_t tst, ptrdiff_t sst,
size_t nelems,
size_t element_size,
long *pSync)
{
int rc = OSHMEM_SUCCESS;
int pe_cur;
int i;
int j;
int k;

SCOLL_VERBOSE(14,
"[#%d] send data to all PE in the group",
group->my_pe);
j = oshmem_proc_group_find_id(group, group->my_pe);
for (i = 0; i < group->proc_count; i++) {
/* index permutation for better distribution of traffic */
k = (((j)+(i))%(group->proc_count));
pe_cur = oshmem_proc_pe(group->proc_array[k]);
rc = MCA_SPML_CALL(put(
(void *)((char *)target + j * tst * nelems * element_size),
nelems * element_size,
(void *)((char *)source + i * sst * nelems * element_size),
pe_cur));
if (OSHMEM_SUCCESS != rc) {
break;
}
}

/* Wait for operation completion */
if (rc == OSHMEM_SUCCESS) {
SCOLL_VERBOSE(14, "[#%d] Wait for operation completion", group->my_pe);
rc = BARRIER_FUNC(group,
(pSync + 1),
SCOLL_DEFAULT_ALG);
}

return rc;
}
5 changes: 3 additions & 2 deletions oshmem/mca/scoll/basic/scoll_basic_module.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013 Mellanox Technologies, Inc.
* Copyright (c) 2013-2016 Mellanox Technologies, Inc.
* All rights reserved.
* $COPYRIGHT$
*
Expand Down Expand Up @@ -52,9 +52,10 @@ mca_scoll_basic_query(struct oshmem_group_t *group, int *priority)
module->super.scoll_broadcast = mca_scoll_basic_broadcast;
module->super.scoll_collect = mca_scoll_basic_collect;
module->super.scoll_reduce = mca_scoll_basic_reduce;
module->super.scoll_alltoall = mca_scoll_basic_alltoall;
module->super.scoll_module_enable = mca_scoll_basic_enable;
return &(module->super);
}

return NULL ;
return NULL;
}
2 changes: 2 additions & 0 deletions oshmem/mca/scoll/fca/scoll_fca.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ struct mca_scoll_fca_module_t {
mca_scoll_base_module_t *previous_collect_module;
mca_scoll_base_module_reduce_fn_t previous_reduce;
mca_scoll_base_module_t *previous_reduce_module;
mca_scoll_base_module_alltoall_fn_t previous_alltoall;
mca_scoll_base_module_t *previous_alltoall_module;
};
typedef struct mca_scoll_fca_module_t mca_scoll_fca_module_t;
OBJ_CLASS_DECLARATION(mca_scoll_fca_module_t);
Expand Down
4 changes: 4 additions & 0 deletions oshmem/mca/scoll/fca/scoll_fca_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ static int _save_coll_handlers(mca_scoll_fca_module_t *fca_module)
FCA_SAVE_PREV_SCOLL_API(broadcast);
FCA_SAVE_PREV_SCOLL_API(collect);
FCA_SAVE_PREV_SCOLL_API(reduce);
FCA_SAVE_PREV_SCOLL_API(alltoall);

return OSHMEM_SUCCESS;
}
Expand Down Expand Up @@ -444,6 +445,7 @@ static void mca_scoll_fca_module_clear(mca_scoll_fca_module_t *fca_module)
fca_module->previous_broadcast = NULL;
fca_module->previous_collect = NULL;
fca_module->previous_reduce = NULL;
fca_module->previous_alltoall = NULL;
}

static void mca_scoll_fca_module_construct(mca_scoll_fca_module_t *fca_module)
Expand All @@ -459,6 +461,7 @@ static void mca_scoll_fca_module_destruct(mca_scoll_fca_module_t *fca_module)
OBJ_RELEASE(fca_module->previous_broadcast_module);
OBJ_RELEASE(fca_module->previous_collect_module);
OBJ_RELEASE(fca_module->previous_reduce_module);
OBJ_RELEASE(fca_module->previous_alltoall_module);
if (fca_module->fca_comm)
_destroy_fca_comm(fca_module);
free(fca_module->local_ranks);
Expand Down Expand Up @@ -535,6 +538,7 @@ mca_scoll_fca_comm_query(struct oshmem_group_t *comm, int *priority)
fca_module->super.scoll_broadcast =
mca_scoll_fca_component.fca_enable_bcast ? mca_scoll_fca_broadcast :
NULL;
fca_module->super.scoll_alltoall = NULL;

*priority = mca_scoll_fca_component.fca_priority;
module = &fca_module->super;
Expand Down
2 changes: 2 additions & 0 deletions oshmem/mca/scoll/mpi/scoll_mpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ struct mca_scoll_mpi_module_t {
mca_scoll_base_module_t *previous_barrier_module;
mca_scoll_base_module_collect_fn_t previous_collect;
mca_scoll_base_module_t *previous_collect_module;
mca_scoll_base_module_alltoall_fn_t previous_alltoall;
mca_scoll_base_module_t *previous_alltoall_module;
};
typedef struct mca_scoll_mpi_module_t mca_scoll_mpi_module_t;

Expand Down
4 changes: 4 additions & 0 deletions oshmem/mca/scoll/mpi/scoll_mpi_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ static void mca_scoll_mpi_module_clear(mca_scoll_mpi_module_t *mpi_module)
mpi_module->previous_broadcast = NULL;
mpi_module->previous_reduce = NULL;
mpi_module->previous_collect = NULL;
mpi_module->previous_alltoall = NULL;
}

static void mca_scoll_mpi_module_construct(mca_scoll_mpi_module_t *mpi_module)
Expand All @@ -41,6 +42,7 @@ static void mca_scoll_mpi_module_destruct(mca_scoll_mpi_module_t *mpi_module)
OBJ_RELEASE(mpi_module->previous_broadcast_module);
OBJ_RELEASE(mpi_module->previous_reduce_module);
OBJ_RELEASE(mpi_module->previous_collect_module);
OBJ_RELEASE(mpi_module->previous_alltoall_module);

mca_scoll_mpi_module_clear(mpi_module);
/* Free ompi_comm */
Expand All @@ -66,6 +68,7 @@ static int mca_scoll_mpi_save_coll_handlers(mca_scoll_base_module_t *module, osh
MPI_SAVE_PREV_SCOLL_API(broadcast);
MPI_SAVE_PREV_SCOLL_API(reduce);
MPI_SAVE_PREV_SCOLL_API(collect);
MPI_SAVE_PREV_SCOLL_API(alltoall);
return OSHMEM_SUCCESS;
}

Expand Down Expand Up @@ -165,6 +168,7 @@ mca_scoll_mpi_comm_query(oshmem_group_t *osh_group, int *priority)
mpi_module->super.scoll_broadcast = mca_scoll_mpi_broadcast;
mpi_module->super.scoll_reduce = mca_scoll_mpi_reduce;
mpi_module->super.scoll_collect = mca_scoll_mpi_collect;
mpi_module->super.scoll_alltoall = NULL;

*priority = cm->mpi_priority;
module = &mpi_module->super;
Expand Down
Loading