2013-09-10 19:34:09 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013 Mellanox Technologies, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
2015-06-24 06:59:57 +03:00
|
|
|
*
|
2013-09-10 19:34:09 +04:00
|
|
|
* Additional copyrights may follow
|
2015-06-24 06:59:57 +03:00
|
|
|
*
|
2013-09-10 19:34:09 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
#include "oshmem_config.h"
|
|
|
|
|
|
|
|
#include "oshmem/constants.h"
|
|
|
|
#include "oshmem/include/shmem.h"
|
|
|
|
|
|
|
|
#include "oshmem/runtime/runtime.h"
|
|
|
|
|
|
|
|
#include "oshmem/mca/scoll/scoll.h"
|
|
|
|
#include "oshmem/mca/scoll/base/base.h"
|
|
|
|
|
|
|
|
#include "oshmem/proc/proc.h"
|
|
|
|
#include "oshmem/proc/proc_group_cache.h"
|
|
|
|
|
2014-04-08 02:55:21 +04:00
|
|
|
|
|
|
|
#if OSHMEM_PROFILING
|
2014-04-15 00:51:06 +04:00
|
|
|
#include "oshmem/include/pshmem.h"
|
2014-04-08 02:55:21 +04:00
|
|
|
#pragma weak shmem_barrier = pshmem_barrier
|
2014-04-19 09:09:07 +04:00
|
|
|
#pragma weak shmem_barrier_all = pshmem_barrier_all
|
2014-04-08 02:55:21 +04:00
|
|
|
#include "oshmem/shmem/c/profile/defines.h"
|
|
|
|
#endif
|
|
|
|
|
2013-09-10 19:34:09 +04:00
|
|
|
void shmem_barrier(int PE_start, int logPE_stride, int PE_size, long *pSync)
|
|
|
|
{
|
|
|
|
int rc = OSHMEM_SUCCESS;
|
|
|
|
oshmem_group_t* group = NULL;
|
|
|
|
|
|
|
|
RUNTIME_CHECK_INIT();
|
|
|
|
|
|
|
|
#if OSHMEM_SPEC_COMPAT == 1
|
|
|
|
/* all outstanding puts must be completed */
|
|
|
|
shmem_fence();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if ((0 <= PE_start) && (0 <= logPE_stride)) {
|
|
|
|
/* Create group basing PE_start, logPE_stride and PE_size */
|
|
|
|
#if OSHMEM_GROUP_CACHE_ENABLED == 0
|
|
|
|
group = oshmem_proc_group_create(PE_start, (1 << logPE_stride), PE_size);
|
|
|
|
if (!group)
|
|
|
|
rc = OSHMEM_ERROR;
|
|
|
|
#else
|
|
|
|
group = find_group_in_cache(PE_start, logPE_stride, PE_size);
|
|
|
|
if (!group) {
|
|
|
|
group = oshmem_proc_group_create(PE_start,
|
|
|
|
(1 << logPE_stride),
|
|
|
|
PE_size);
|
|
|
|
if (!group) {
|
|
|
|
rc = OSHMEM_ERROR;
|
|
|
|
} else {
|
|
|
|
cache_group(group, PE_start, logPE_stride, PE_size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* OSHMEM_GROUP_CACHE_ENABLED */
|
|
|
|
/* Collective operation call */
|
|
|
|
if (rc == OSHMEM_SUCCESS) {
|
|
|
|
/* Call barrier operation */
|
|
|
|
rc = group->g_scoll.scoll_barrier(group, pSync, SCOLL_DEFAULT_ALG);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if OSHMEM_GROUP_CACHE_ENABLED == 0
|
|
|
|
if ( rc == OSHMEM_SUCCESS )
|
|
|
|
{
|
|
|
|
oshmem_proc_group_destroy(group);
|
|
|
|
}
|
|
|
|
#endif /* OSHMEM_GROUP_CACHE_ENABLED */
|
|
|
|
}
|
|
|
|
RUNTIME_CHECK_RC(rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void shmem_barrier_all(void)
|
|
|
|
{
|
|
|
|
int rc = OSHMEM_SUCCESS;
|
|
|
|
|
|
|
|
#if OSHMEM_SPEC_COMPAT == 1
|
|
|
|
/* all outstanding puts must be completed */
|
|
|
|
shmem_fence();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (mca_scoll_sync_array) {
|
|
|
|
rc = oshmem_group_all->g_scoll.scoll_barrier(oshmem_group_all,
|
|
|
|
mca_scoll_sync_array,
|
|
|
|
SCOLL_DEFAULT_ALG);
|
|
|
|
}
|
|
|
|
RUNTIME_CHECK_RC(rc);
|
|
|
|
}
|