-
Notifications
You must be signed in to change notification settings - Fork 903
OSHMEM: v1.3: adds shmem_fetch and shmem_set AMOs #2103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,6 +210,13 @@ OSHMEM_DECLSPEC int pshmem_int_swap(int *target, int value, int pe); | |
OSHMEM_DECLSPEC long pshmem_long_swap(long *target, long value, int pe); | ||
OSHMEM_DECLSPEC long long pshmem_longlong_swap(long long*target, long long value, int pe); | ||
|
||
/* Atomic set */ | ||
OSHMEM_DECLSPEC void pshmem_int_set(int *target, int value, int pe); | ||
OSHMEM_DECLSPEC void pshmem_long_set(long *target, long value, int pe); | ||
OSHMEM_DECLSPEC void pshmem_longlong_set(long long*target, long long value, int pe); | ||
OSHMEM_DECLSPEC void pshmem_float_set(float *target, float value, int pe); | ||
OSHMEM_DECLSPEC void pshmem_double_set(double *target, double value, int pe); | ||
|
||
/* Atomic conditional swap */ | ||
OSHMEM_DECLSPEC int pshmem_int_cswap(int *target, int cond, int value, int pe); | ||
OSHMEM_DECLSPEC long pshmem_long_cswap(long *target, long cond, long value, int pe); | ||
|
@@ -220,6 +227,14 @@ OSHMEM_DECLSPEC int pshmem_int_fadd(int *target, int value, int pe); | |
OSHMEM_DECLSPEC long pshmem_long_fadd(long *target, long value, int pe); | ||
OSHMEM_DECLSPEC long long pshmem_longlong_fadd(long long *target, long long value, int pe); | ||
|
||
/* Atomic Fetch */ | ||
OSHMEM_DECLSPEC int pshmem_int_fetch(const int *target, int pe); | ||
OSHMEM_DECLSPEC long pshmem_long_fetch(const long *target, int pe); | ||
OSHMEM_DECLSPEC long long pshmem_longlong_fetch(const long long *target, int pe); | ||
OSHMEM_DECLSPEC float pshmem_float_fetch(const float *target, int pe); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please change float and double order |
||
OSHMEM_DECLSPEC double pshmem_double_fetch(const double *target, int pe); | ||
|
||
|
||
/* Atomic Fetch&Inc */ | ||
OSHMEM_DECLSPEC int pshmem_int_finc(int *target, int pe); | ||
OSHMEM_DECLSPEC long pshmem_long_finc(long *target, int pe); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -275,6 +275,13 @@ OSHMEM_DECLSPEC int shmem_int_swap(int *target, int value, int pe); | |
OSHMEM_DECLSPEC long shmem_long_swap(long *target, long value, int pe); | ||
OSHMEM_DECLSPEC long long shmem_longlong_swap(long long*target, long long value, int pe); | ||
|
||
/* Atomic set */ | ||
OSHMEM_DECLSPEC void shmem_int_set(int *target, int value, int pe); | ||
OSHMEM_DECLSPEC void shmem_long_set(long *target, long value, int pe); | ||
OSHMEM_DECLSPEC void shmem_longlong_set(long long*target, long long value, int pe); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alex-mikheev could you consider following ordering as: |
||
OSHMEM_DECLSPEC void shmem_float_set(float *target, float value, int pe); | ||
OSHMEM_DECLSPEC void shmem_double_set(double *target, double value, int pe); | ||
|
||
/* Atomic conditional swap */ | ||
OSHMEM_DECLSPEC int shmem_int_cswap(int *target, int cond, int value, int pe); | ||
OSHMEM_DECLSPEC long shmem_long_cswap(long *target, long cond, long value, int pe); | ||
|
@@ -285,6 +292,13 @@ OSHMEM_DECLSPEC int shmem_int_fadd(int *target, int value, int pe); | |
OSHMEM_DECLSPEC long shmem_long_fadd(long *target, long value, int pe); | ||
OSHMEM_DECLSPEC long long shmem_longlong_fadd(long long *target, long long value, int pe); | ||
|
||
/* Atomic Fetch */ | ||
OSHMEM_DECLSPEC int shmem_int_fetch(const int *target, int pe); | ||
OSHMEM_DECLSPEC long shmem_long_fetch(const long *target, int pe); | ||
OSHMEM_DECLSPEC long long shmem_longlong_fetch(const long long *target, int pe); | ||
OSHMEM_DECLSPEC float shmem_float_fetch(const float *target, int pe); | ||
OSHMEM_DECLSPEC double shmem_double_fetch(const double *target, int pe); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please change double and float order |
||
/* Atomic Fetch&Inc */ | ||
OSHMEM_DECLSPEC int shmem_int_finc(int *target, int pe); | ||
OSHMEM_DECLSPEC long shmem_long_finc(long *target, int pe); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,10 @@ OSHMEM_DECLSPEC void shmemx_iget16(void* target, const void* source, ptrdiff_t t | |
OSHMEM_DECLSPEC int32_t shmemx_int32_swap(int32_t *target, int32_t value, int pe); | ||
OSHMEM_DECLSPEC int64_t shmemx_int64_swap(int64_t *target, int64_t value, int pe); | ||
|
||
/* Atomic set */ | ||
OSHMEM_DECLSPEC void shmemx_int32_set(int32_t *target, int32_t value, int pe); | ||
OSHMEM_DECLSPEC void shmemx_int64_set(int64_t *target, int64_t value, int pe); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we actually need shemx_? |
||
/* Atomic conditional swap */ | ||
OSHMEM_DECLSPEC int32_t shmemx_int32_cswap(int32_t *target, int32_t cond, int32_t value, int pe); | ||
OSHMEM_DECLSPEC int64_t shmemx_int64_cswap(int64_t *target, int64_t cond, int64_t value, int pe); | ||
|
@@ -74,6 +78,10 @@ OSHMEM_DECLSPEC int64_t shmemx_int64_cswap(int64_t *target, int64_t cond, int64_ | |
OSHMEM_DECLSPEC int32_t shmemx_int32_fadd(int32_t *target, int32_t value, int pe); | ||
OSHMEM_DECLSPEC int64_t shmemx_int64_fadd(int64_t *target, int64_t value, int pe); | ||
|
||
/* Atomic Fetch */ | ||
OSHMEM_DECLSPEC int32_t shmemx_int32_fetch(const int32_t *target, int pe); | ||
OSHMEM_DECLSPEC int64_t shmemx_int64_fetch(const int64_t *target, int pe); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we actually need shmemx_ |
||
/* Atomic Fetch&Inc */ | ||
OSHMEM_DECLSPEC int32_t shmemx_int32_finc(int32_t *target, int pe); | ||
OSHMEM_DECLSPEC int64_t shmemx_int64_finc(int64_t *target, int pe); | ||
|
@@ -145,13 +153,22 @@ OSHMEM_DECLSPEC void shmemx_int64_prod_to_all(int64_t *target, const int64_t *so | |
|
||
#define shmem_int32_swap shmemx_int32_swap | ||
#define shmem_int64_swap shmemx_int64_swap | ||
|
||
#define shmem_int32_set shmemx_int32_set | ||
#define shmem_int64_set shmemx_int64_set | ||
|
||
#define shmem_int32_cswap shmemx_int32_cswap | ||
#define shmem_int64_cswap shmemx_int64_cswap | ||
|
||
#define shmem_int32_fadd shmemx_int32_fadd | ||
#define shmem_int64_fadd shmemx_int64_fadd | ||
|
||
#define shmem_int32_fetch shmemx_int32_fetch | ||
#define shmem_int64_fetch shmemx_int64_fetch | ||
|
||
#define shmem_int32_finc shmemx_int32_finc | ||
#define shmem_int64_finc shmemx_int64_finc | ||
|
||
#define shmem_int32_add shmemx_int32_add | ||
#define shmem_int64_add shmemx_int64_add | ||
#define shmem_int32_inc shmemx_int32_inc | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,6 +203,14 @@ | |
#define shmemx_int32_swap pshmemx_int32_swap | ||
#define shmemx_int64_swap pshmemx_int64_swap | ||
|
||
/* Atomic set */ | ||
#define shmem_double_set pshmem_double_set | ||
#define shmem_float_set pshmem_float_set | ||
#define shmem_int_set pshmem_int_set | ||
#define shmem_long_set pshmem_long_set | ||
#define shmem_longlong_set pshmem_longlong_set | ||
#define shmemx_int32_set pshmemx_int32_set | ||
#define shmemx_int64_set pshmemx_int64_set | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we actually need shmemx_? |
||
|
||
/* Atomic conditional swap */ | ||
#define shmem_int_cswap pshmem_int_cswap | ||
|
@@ -219,6 +227,15 @@ | |
#define shmemx_int32_fadd pshmemx_int32_fadd | ||
#define shmemx_int64_fadd pshmemx_int64_fadd | ||
|
||
/* Atomic Fetch */ | ||
#define shmem_double_fetch pshmem_double_fetch | ||
#define shmem_float_fetch pshmem_float_fetch | ||
#define shmem_int_fetch pshmem_int_fetch | ||
#define shmem_long_fetch pshmem_long_fetch | ||
#define shmem_longlong_fetch pshmem_longlong_fetch | ||
#define shmemx_int32_fetch pshmemx_int32_fetch | ||
#define shmemx_int64_fetch pshmemx_int64_fetch | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alex-mikheev could you consider following ordering as: |
||
|
||
/* Atomic Fetch&Inc */ | ||
#define shmem_int_finc pshmem_int_finc | ||
#define shmem_long_finc pshmem_long_finc | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (c) 2016 Mellanox Technologies, Inc. | ||
* All rights reserved. | ||
* $COPYRIGHT$ | ||
* | ||
* Additional copyrights may follow | ||
* | ||
* $HEADER$ | ||
*/ | ||
#include "oshmem_config.h" | ||
|
||
#include "oshmem/constants.h" | ||
#include "oshmem/include/shmem.h" | ||
|
||
#include "oshmem/runtime/runtime.h" | ||
|
||
#include "oshmem/op/op.h" | ||
#include "oshmem/mca/atomic/atomic.h" | ||
|
||
/* | ||
* These routines perform an atomic fetch operation. | ||
* The fetch routines retrieve the value at address target on PE pe. | ||
* The operation must be completed without the possibility of another process | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. incorrect description |
||
* updating target during the fetch. | ||
*/ | ||
#define SHMEM_TYPE_FETCH(type_name, type, prefix) \ | ||
type prefix##type_name##_fetch(const type *target, int pe) \ | ||
{ \ | ||
int rc = OSHMEM_SUCCESS; \ | ||
size_t size = 0; \ | ||
type out_value; \ | ||
type value = 0; \ | ||
oshmem_op_t* op = oshmem_op_sum##type_name; \ | ||
\ | ||
RUNTIME_CHECK_INIT(); \ | ||
RUNTIME_CHECK_PE(pe); \ | ||
RUNTIME_CHECK_ADDR(target); \ | ||
\ | ||
size = sizeof(out_value); \ | ||
rc = MCA_ATOMIC_CALL(fadd( \ | ||
(void*)target, \ | ||
(void*)&out_value, \ | ||
(const void*)&value, \ | ||
size, \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. zero is added to the target |
||
pe, \ | ||
op)); \ | ||
RUNTIME_CHECK_RC(rc); \ | ||
\ | ||
return out_value; \ | ||
} | ||
|
||
#if OSHMEM_PROFILING | ||
#include "oshmem/include/pshmem.h" | ||
#pragma weak shmem_int_fetch = pshmem_int_fetch | ||
#pragma weak shmem_long_fetch = pshmem_long_fetch | ||
#pragma weak shmem_longlong_fetch = pshmem_longlong_fetch | ||
#pragma weak shmem_double_fetch = pshmem_double_fetch | ||
#pragma weak shmem_float_fetch = pshmem_float_fetch | ||
#pragma weak shmemx_int32_fetch = pshmemx_int32_fetch | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need shmemx_? |
||
#pragma weak shmemx_int64_fetch = pshmemx_int64_fetch | ||
#include "oshmem/shmem/c/profile/defines.h" | ||
#endif | ||
|
||
SHMEM_TYPE_FETCH(_int, int, shmem) | ||
SHMEM_TYPE_FETCH(_long, long, shmem) | ||
SHMEM_TYPE_FETCH(_longlong, long long, shmem) | ||
SHMEM_TYPE_FETCH(_double, double, shmem) | ||
SHMEM_TYPE_FETCH(_float, float, shmem) | ||
SHMEM_TYPE_FETCH(_int32, int32_t, shmemx) | ||
SHMEM_TYPE_FETCH(_int64, int64_t, shmemx) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (c) 2016 Mellanox Technologies, Inc. | ||
* All rights reserved. | ||
* $COPYRIGHT$ | ||
* | ||
* Additional copyrights may follow | ||
* | ||
* $HEADER$ | ||
*/ | ||
#include "oshmem_config.h" | ||
|
||
#include "oshmem/constants.h" | ||
#include "oshmem/include/shmem.h" | ||
|
||
#include "oshmem/runtime/runtime.h" | ||
|
||
#include "oshmem/mca/atomic/atomic.h" | ||
|
||
/* | ||
* shmem_set performs an atomic set operation. | ||
* The atomic set routines write value to address target on PE pe. | ||
* The operation must be completed without the possibility of another | ||
* process updating the target during the set. | ||
*/ | ||
#define SHMEM_TYPE_SET(type_name, type, prefix) \ | ||
void prefix##type_name##_set(type *target, type value, int pe) \ | ||
{ \ | ||
int rc = OSHMEM_SUCCESS; \ | ||
size_t size = 0; \ | ||
type out_value; \ | ||
\ | ||
RUNTIME_CHECK_INIT(); \ | ||
RUNTIME_CHECK_PE(pe); \ | ||
RUNTIME_CHECK_ADDR(target); \ | ||
\ | ||
size = sizeof(out_value); \ | ||
rc = MCA_ATOMIC_CALL(cswap( \ | ||
(void*)target, \ | ||
(void*)&out_value, \ | ||
NULL, \ | ||
(const void*)&value, \ | ||
size, \ | ||
pe)); \ | ||
RUNTIME_CHECK_RC(rc); \ | ||
} | ||
|
||
#if OSHMEM_PROFILING | ||
#include "oshmem/include/pshmem.h" | ||
#pragma weak shmem_int_set = pshmem_int_set | ||
#pragma weak shmem_long_set = pshmem_long_set | ||
#pragma weak shmem_longlong_set = pshmem_longlong_set | ||
#pragma weak shmem_float_set = pshmem_float_set | ||
#pragma weak shmem_double_set = pshmem_double_set | ||
#pragma weak shmemx_int32_set = pshmemx_int32_set | ||
#pragma weak shmemx_int64_set = pshmemx_int64_set | ||
#include "oshmem/shmem/c/profile/defines.h" | ||
#endif | ||
|
||
SHMEM_TYPE_SET(_int, int, shmem) | ||
SHMEM_TYPE_SET(_long, long, shmem) | ||
SHMEM_TYPE_SET(_longlong, long long, shmem) | ||
SHMEM_TYPE_SET(_float, float, shmem) | ||
SHMEM_TYPE_SET(_double, double, shmem) | ||
SHMEM_TYPE_SET(_int32, int32_t, shmemx) | ||
SHMEM_TYPE_SET(_int64, int64_t, shmemx) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alex-mikheev could you consider following ordering as:
char,short,int,long,long long, float, double, long double to improve readability.