diff --git a/oshmem/include/pshmem.h b/oshmem/include/pshmem.h index 3abf8176bd2..3645ce268b3 100644 --- a/oshmem/include/pshmem.h +++ b/oshmem/include/pshmem.h @@ -40,6 +40,12 @@ # endif #endif +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) +#define OSHMEMP_HAVE_C11 1 +#else +#define OSHMEMP_HAVE_C11 0 +#endif + #include #if defined(c_plusplus) || defined(__cplusplus) @@ -98,10 +104,23 @@ OSHMEM_DECLSPEC void pshmem_float_p(float* addr, float value, int pe); OSHMEM_DECLSPEC void pshmem_double_p(double* addr, double value, int pe); OSHMEM_DECLSPEC void pshmem_longlong_p(long long* addr, long long value, int pe); OSHMEM_DECLSPEC void pshmem_longdouble_p(long double* addr, long double value, int pe); +#if OSHMEMP_HAVE_C11 +#define pshmem_p(dst, val, pe) \ + _Generic(&*(dst), \ + char*: pshmem_char_p, \ + short*: pshmem_short_p, \ + int*: pshmem_int_p, \ + long*: pshmem_long_p, \ + long long*: pshmem_longlong_p, \ + float*: pshmem_float_p, \ + double*: pshmem_double_p, \ + long double*: pshmem_longdouble_p)(dst, val, pe) +#endif /* * Block data put routines */ +OSHMEM_DECLSPEC void pshmem_char_put(char *target, const char *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_short_put(short *target, const short *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_int_put(int* target, const int* source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_long_put(long *target, const long *source, size_t len, int pe); @@ -109,6 +128,21 @@ OSHMEM_DECLSPEC void pshmem_float_put(float *target, const float *source, size_ OSHMEM_DECLSPEC void pshmem_double_put(double *target, const double *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_longlong_put(long long *target, const long long *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_longdouble_put(long double *target, const long double *source, size_t len, int pe); +#if OSHMEMP_HAVE_C11 +#define pshmem_put(dst, src, len, pe) \ + _Generic(&*(dst), \ + char*: pshmem_char_put, \ + short*: pshmem_short_put, \ + int*: pshmem_int_put, \ + long*: pshmem_long_put, \ + long long*: pshmem_longlong_put, \ + float*: pshmem_float_put, \ + double*: pshmem_double_put, \ + long double*: pshmem_longdouble_put)(dst, src, len, pe) +#endif + +OSHMEM_DECLSPEC void pshmem_put8(void *target, const void *source, size_t len, int pe); +OSHMEM_DECLSPEC void pshmem_put16(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_put32(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_put64(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_put128(void *target, const void *source, size_t len, int pe); @@ -117,13 +151,29 @@ OSHMEM_DECLSPEC void pshmem_putmem(void *target, const void *source, size_t len /* * Strided put routines */ +OSHMEM_DECLSPEC void pshmem_char_iput(char* target, const char* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void pshmem_short_iput(short* target, const short* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void pshmem_int_iput(int* target, const int* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); +OSHMEM_DECLSPEC void pshmem_long_iput(long* target, const long* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void pshmem_float_iput(float* target, const float* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void pshmem_double_iput(double* target, const double* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void pshmem_longlong_iput(long long* target, const long long* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void pshmem_longdouble_iput(long double* target, const long double* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); -OSHMEM_DECLSPEC void pshmem_long_iput(long* target, const long* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); +#if OSHMEMP_HAVE_C11 +#define pshmem_iput(dst, src, tst, sst, len, pe) \ + _Generic(&*(dst), \ + char*: pshmem_char_iput, \ + short*: pshmem_short_iput, \ + int*: pshmem_int_iput, \ + long*: pshmem_long_iput, \ + long long*: pshmem_longlong_iput, \ + float*: pshmem_float_iput, \ + double*: pshmem_double_iput, \ + long double*: pshmem_longdouble_iput)(dst, src, tst, sst, len, pe) +#endif + +OSHMEM_DECLSPEC void pshmem_iput8(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); +OSHMEM_DECLSPEC void pshmem_iput16(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void pshmem_iput32(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void pshmem_iput64(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void pshmem_iput128(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); @@ -131,7 +181,6 @@ OSHMEM_DECLSPEC void pshmem_iput128(void* target, const void* source, ptrdiff_t /* * Nonblocking put routines */ -OSHMEM_DECLSPEC void pshmem_putmem_nbi(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_char_put_nbi(char *target, const char *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_short_put_nbi(short *target, const short *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_int_put_nbi(int* target, const int* source, size_t len, int pe); @@ -140,11 +189,25 @@ OSHMEM_DECLSPEC void pshmem_longlong_put_nbi(long long *target, const long long OSHMEM_DECLSPEC void pshmem_float_put_nbi(float *target, const float *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_double_put_nbi(double *target, const double *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_longdouble_put_nbi(long double *target, const long double *source, size_t len, int pe); +#if OSHMEMP_HAVE_C11 +#define pshmem_put_nbi(dst, src, len, pe) \ + _Generic(&*(dst), \ + char*: pshmem_char_put_nbi, \ + short*: pshmem_short_put_nbi, \ + int*: pshmem_int_put_nbi, \ + long*: pshmem_long_put_nbi, \ + long long*: pshmem_longlong_put_nbi, \ + float*: pshmem_float_put_nbi, \ + double*: pshmem_double_put_nbi, \ + long double*: pshmem_longdouble_put_nbi)(dst, src, len, pe) +#endif + OSHMEM_DECLSPEC void pshmem_put8_nbi(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_put16_nbi(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_put32_nbi(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_put64_nbi(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_put128_nbi(void *target, const void *source, size_t len, int pe); +OSHMEM_DECLSPEC void pshmem_putmem_nbi(void *target, const void *source, size_t len, int pe); /* * Elemental get routines @@ -157,10 +220,23 @@ OSHMEM_DECLSPEC float pshmem_float_g(const float* addr, int pe); OSHMEM_DECLSPEC double pshmem_double_g(const double* addr, int pe); OSHMEM_DECLSPEC long long pshmem_longlong_g(const long long* addr, int pe); OSHMEM_DECLSPEC long double pshmem_longdouble_g(const long double* addr, int pe); +#if OSHMEMP_HAVE_C11 +#define pshmem_g(addr, pe) \ + _Generic(&*(dst), \ + char*: pshmem_char_g, \ + short*: pshmem_short_g, \ + int*: pshmem_int_g, \ + long*: pshmem_long_g, \ + long long*: pshmem_longlong_g, \ + float*: pshmem_float_g, \ + double*: pshmem_double_g, \ + long double*: pshmem_longdouble_g)(addr, pe) +#endif /* * Block data get routines */ +OSHMEM_DECLSPEC void pshmem_char_get(char *target, const char *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_short_get(short *target, const short *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_int_get(int *target, const int *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_long_get(long *target, const long *source, size_t len, int pe); @@ -168,6 +244,21 @@ OSHMEM_DECLSPEC void pshmem_float_get(float *target, const float *source, size_ OSHMEM_DECLSPEC void pshmem_double_get(double *target, const double *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_longlong_get(long long *target, const long long *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_longdouble_get(long double *target, const long double *source, size_t len, int pe); +#if OSHMEMP_HAVE_C11 +#define pshmem_get(dst, src, len, pe) \ + _Generic(&*(dst), \ + char*: pshmem_char_get, \ + short*: pshmem_short_get, \ + int*: pshmem_int_get, \ + long*: pshmem_long_get, \ + long long*: pshmem_longlong_get, \ + float*: pshmem_float_get, \ + double*: pshmem_double_get, \ + long double*: pshmem_longdouble_get)(dst, src, len, pe) +#endif + +OSHMEM_DECLSPEC void pshmem_get8(void *target, const void *source, size_t len, int pe); +OSHMEM_DECLSPEC void pshmem_get16(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_get32(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_get64(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_get128(void *target, const void *source, size_t len, int pe); @@ -176,13 +267,29 @@ OSHMEM_DECLSPEC void pshmem_getmem(void *target, const void *source, size_t len /* * Strided get routines */ -OSHMEM_DECLSPEC void pshmem_int_iget(int* target, const int* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); +OSHMEM_DECLSPEC void pshmem_char_iget(char* target, const char* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void pshmem_short_iget(short* target, const short* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); +OSHMEM_DECLSPEC void pshmem_int_iget(int* target, const int* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void pshmem_float_iget(float* target, const float* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void pshmem_double_iget(double* target, const double* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void pshmem_longlong_iget(long long* target, const long long* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void pshmem_longdouble_iget(long double* target, const long double* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void pshmem_long_iget(long* target, const long* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); +#if OSHMEMP_HAVE_C11 +#define pshmem_iget(dst, src, tst, sst, len, pe) \ + _Generic(&*(dst), \ + char*: pshmem_char_iget, \ + short*: pshmem_short_iget, \ + int*: pshmem_int_iget, \ + long*: pshmem_long_iget, \ + long long*: pshmem_longlong_iget, \ + float*: pshmem_float_iget, \ + double*: pshmem_double_iget, \ + long double*: pshmem_longdouble_iget)(dst, src, tst, sst, len, pe) +#endif + +OSHMEM_DECLSPEC void pshmem_iget8(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); +OSHMEM_DECLSPEC void pshmem_iget16(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void pshmem_iget32(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void pshmem_iget64(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void pshmem_iget128(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); @@ -190,7 +297,6 @@ OSHMEM_DECLSPEC void pshmem_iget128(void* target, const void* source, ptrdiff_t /* * Nonblocking data get routines */ -OSHMEM_DECLSPEC void pshmem_getmem_nbi(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_char_get_nbi(char *target, const char *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_short_get_nbi(short *target, const short *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_int_get_nbi(int *target, const int *source, size_t len, int pe); @@ -199,48 +305,136 @@ OSHMEM_DECLSPEC void pshmem_longlong_get_nbi(long long *target, const long long OSHMEM_DECLSPEC void pshmem_float_get_nbi(float *target, const float *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_double_get_nbi(double *target, const double *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_longdouble_get_nbi(long double *target, const long double *source, size_t len, int pe); +#if OSHMEMP_HAVE_C11 +#define pshmem_get_nbi(dst, src, len, pe) \ + _Generic(&*(dst), \ + char*: pshmem_char_get_nbi, \ + short*: pshmem_short_get_nbi, \ + int*: pshmem_int_get_nbi, \ + long*: pshmem_long_get_nbi, \ + long long*: pshmem_longlong_get_nbi, \ + float*: pshmem_float_get_nbi, \ + double*: pshmem_double_get_nbi, \ + long double*: pshmem_longdouble_get_nbi)(dst, src, len, pe) +#endif + OSHMEM_DECLSPEC void pshmem_get8_nbi(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_get16_nbi(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_get32_nbi(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_get64_nbi(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void pshmem_get128_nbi(void *target, const void *source, size_t len, int pe); +OSHMEM_DECLSPEC void pshmem_getmem_nbi(void *target, const void *source, size_t len, int pe); /* * Atomic operations */ /* Atomic swap */ -OSHMEM_DECLSPEC long pshmem_swap(long *target, long value, int pe); -OSHMEM_DECLSPEC double pshmem_double_swap(double *target, double value, int pe); -OSHMEM_DECLSPEC float pshmem_float_swap(float *target, float value, int pe); 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); +OSHMEM_DECLSPEC float pshmem_float_swap(float *target, float value, int pe); +OSHMEM_DECLSPEC double pshmem_double_swap(double *target, double value, int pe); +#if OSHMEMP_HAVE_C11 +#define pshmem_swap(dst, val, pe) \ + _Generic(&*(dst), \ + int*: pshmem_int_swap, \ + long*: pshmem_long_swap, \ + long long*: pshmem_longlong_swap, \ + float*: pshmem_float_swap, \ + double*: pshmem_double_swap)(dst, val, pe) +#endif + +/* 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); +#if OSHMEMP_HAVE_C11 +#define pshmem_set(dst, val, pe) \ + _Generic(&*(dst), \ + int*: pshmem_int_set, \ + long*: pshmem_long_set, \ + long long*: pshmem_longlong_set, \ + float*: pshmem_float_set, \ + double*: pshmem_double_set)(dst, val, pe) +#endif /* 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); OSHMEM_DECLSPEC long long pshmem_longlong_cswap(long long *target, long long cond, long long value, int pe); +#if OSHMEMP_HAVE_C11 +#define pshmem_cswap(dst, cond, val, pe) \ + _Generic(&*(dst), \ + int*: pshmem_int_cswap, \ + long*: pshmem_long_cswap, \ + long long*: pshmem_longlong_cswap)(dst, cond, val, pe) +#endif /* Atomic Fetch&Add */ 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); +#if OSHMEMP_HAVE_C11 +#define pshmem_fadd(dst, val, pe) \ + _Generic(&*(dst), \ + int*: pshmem_int_fadd, \ + long*: pshmem_long_fadd, \ + long long*: pshmem_longlong_fadd)(dst, val, pe) +#endif + +/* 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); +OSHMEM_DECLSPEC double pshmem_double_fetch(const double *target, int pe); +#if OSHMEM_HAVE_C11 +#define pshmem_fetch(dst, pe) \ + _Generic(&*(dst), \ + int*: pshmem_int_fetch, \ + long*: pshmem_long_fetch, \ + long long*: pshmem_longlong_fetch, \ + float*: pshmem_float_fetch, \ + double*: pshmem_double_fetch)(dst, pe) +#endif /* Atomic Fetch&Inc */ OSHMEM_DECLSPEC int pshmem_int_finc(int *target, int pe); OSHMEM_DECLSPEC long pshmem_long_finc(long *target, int pe); OSHMEM_DECLSPEC long long pshmem_longlong_finc(long long *target, int pe); +#if OSHMEMP_HAVE_C11 +#define pshmem_finc(dst, val, pe) \ + _Generic(&*(dst), \ + int*: pshmem_int_finc, \ + long*: pshmem_long_finc, \ + long long*: pshmem_longlong_finc)(dst, val, pe) +#endif /* Atomic Add*/ OSHMEM_DECLSPEC void pshmem_int_add(int *target, int value, int pe); OSHMEM_DECLSPEC void pshmem_long_add(long *target, long value, int pe); OSHMEM_DECLSPEC void pshmem_longlong_add(long long *target, long long value, int pe); +#if OSHMEMP_HAVE_C11 +#define pshmem_add(dst, val, pe) \ + _Generic(&*(dst), \ + int*: pshmem_int_add, \ + long*: pshmem_long_add, \ + long long*: pshmem_longlong_add)(dst, val, pe) +#endif /* Atomic Inc */ OSHMEM_DECLSPEC void pshmem_int_inc(int *target, int pe); OSHMEM_DECLSPEC void pshmem_long_inc(long *target, int pe); OSHMEM_DECLSPEC void pshmem_longlong_inc(long long *target, int pe); - +#if OSHMEMP_HAVE_C11 +#define pshmem_inc(dst, pe) \ + _Generic(&*(dst), \ + int*: pshmem_int_inc, \ + long*: pshmem_long_inc, \ + long long*: pshmem_longlong_inc)(dst, pe) +#endif /* * Lock functions */ diff --git a/oshmem/include/pshmemx.h b/oshmem/include/pshmemx.h index 28644b58358..81e929cd55d 100644 --- a/oshmem/include/pshmemx.h +++ b/oshmem/include/pshmemx.h @@ -50,12 +50,10 @@ OSHMEM_DECLSPEC void pshmemx_int64_p(int64_t* addr, int64_t value, int pe); /* * Block data put routines */ -OSHMEM_DECLSPEC void pshmemx_put16(void *target, const void *source, size_t len, int pe); /* * Strided put routines */ -OSHMEM_DECLSPEC void pshmemx_iput16(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); /* * Elemental get routines @@ -67,12 +65,10 @@ OSHMEM_DECLSPEC int64_t pshmemx_int64_g(const int64_t* addr, int pe); /* * Block data get routines */ -OSHMEM_DECLSPEC void pshmemx_get16(void *target, const void *source, size_t len, int pe); /* * Strided get routines */ -OSHMEM_DECLSPEC void pshmemx_iget16(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); /* * Atomic operations @@ -81,6 +77,10 @@ OSHMEM_DECLSPEC void pshmemx_iget16(void* target, const void* source, ptrdiff_t OSHMEM_DECLSPEC int32_t pshmemx_int32_swap(int32_t *target, int32_t value, int pe); OSHMEM_DECLSPEC int64_t pshmemx_int64_swap(int64_t *target, int64_t value, int pe); +/*Atomic set */ +OSHMEM_DECLSPEC void pshmemx_int32_set(int32_t *target, int32_t value, int pe); +OSHMEM_DECLSPEC void pshmemx_int64_set(int64_t *target, int64_t value, int pe); + /* Atomic conditional swap */ OSHMEM_DECLSPEC int32_t pshmemx_int32_cswap(int32_t *target, int32_t cond, int32_t value, int pe); OSHMEM_DECLSPEC int64_t pshmemx_int64_cswap(int64_t *target, int64_t cond, int64_t value, int pe); @@ -89,6 +89,10 @@ OSHMEM_DECLSPEC int64_t pshmemx_int64_cswap(int64_t *target, int64_t cond, int64 OSHMEM_DECLSPEC int32_t pshmemx_int32_fadd(int32_t *target, int32_t value, int pe); OSHMEM_DECLSPEC int64_t pshmemx_int64_fadd(int64_t *target, int64_t value, int pe); +/* Atomic Fetch */ +OSHMEM_DECLSPEC int32_t pshmemx_int32_fetch(const int32_t *target, int pe); +OSHMEM_DECLSPEC int64_t pshmemx_int64_fetch(const int64_t *target, int pe); + /* Atomic Fetch&Inc */ OSHMEM_DECLSPEC int32_t pshmemx_int32_finc(int32_t *target, int pe); OSHMEM_DECLSPEC int64_t pshmemx_int64_finc(int64_t *target, int pe); @@ -148,27 +152,31 @@ OSHMEM_DECLSPEC void pshmemx_int64_prod_to_all(int64_t *target, const int64_t *s #define pshmem_int32_p pshmemx_int32_p #define pshmem_int64_p pshmemx_int64_p -#define pshmem_put16 pshmemx_put16 -#define pshmem_iput16 pshmemx_iput16 - #define pshmem_int16_g pshmemx_int16_g #define pshmem_int32_g pshmemx_int32_g #define pshmem_int64_g pshmemx_int64_g -#define pshmem_get16 pshmemx_get16 -#define pshmem_iget16 pshmemx_iget16 - #define pshmem_int32_swap pshmemx_int32_swap #define pshmem_int64_swap pshmemx_int64_swap + +#define pshmem_int32_set pshmemx_int32_set +#define pshmem_int64_set pshmemx_int64_set + #define pshmem_int32_cswap pshmemx_int32_cswap #define pshmem_int64_cswap pshmemx_int64_cswap #define pshmem_int32_fadd pshmemx_int32_fadd #define pshmem_int64_fadd pshmemx_int64_fadd + +#define pshmem_int32_fetch pshmemx_int32_fetch +#define pshmem_int64_fetch pshmemx_int64_fetch + #define pshmem_int32_finc pshmemx_int32_finc #define pshmem_int64_finc pshmemx_int64_finc + #define pshmem_int32_add pshmemx_int32_add #define pshmem_int64_add pshmemx_int64_add + #define pshmem_int32_inc pshmemx_int32_inc #define pshmem_int64_inc pshmemx_int64_inc diff --git a/oshmem/include/shmem.h.in b/oshmem/include/shmem.h.in index a0e959e005e..492fa386363 100644 --- a/oshmem/include/shmem.h.in +++ b/oshmem/include/shmem.h.in @@ -23,7 +23,6 @@ # define OSHMEM_COMPLEX_TYPE(type) type complex #endif - /* * SHMEM version */ @@ -48,6 +47,12 @@ # endif #endif +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) +#define OSHMEM_HAVE_C11 1 +#else +#define OSHMEM_HAVE_C11 0 +#endif + #include #include @@ -163,10 +168,23 @@ OSHMEM_DECLSPEC void shmem_float_p(float* addr, float value, int pe); OSHMEM_DECLSPEC void shmem_double_p(double* addr, double value, int pe); OSHMEM_DECLSPEC void shmem_longlong_p(long long* addr, long long value, int pe); OSHMEM_DECLSPEC void shmem_longdouble_p(long double* addr, long double value, int pe); +#if OSHMEM_HAVE_C11 +#define shmem_p(dst, val, pe) \ + _Generic(&*(dst), \ + char*: shmem_char_p, \ + short*: shmem_short_p, \ + int*: shmem_int_p, \ + long*: shmem_long_p, \ + long long*: shmem_longlong_p, \ + float*: shmem_float_p, \ + double*: shmem_double_p, \ + long double*: shmem_longdouble_p)(dst, val, pe) +#endif /* * Block data put routines */ +OSHMEM_DECLSPEC void shmem_char_put(char *target, const char *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_short_put(short *target, const short *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_int_put(int* target, const int* source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_long_put(long *target, const long *source, size_t len, int pe); @@ -174,21 +192,53 @@ OSHMEM_DECLSPEC void shmem_float_put(float *target, const float *source, size_t OSHMEM_DECLSPEC void shmem_double_put(double *target, const double *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_longlong_put(long long *target, const long long *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_longdouble_put(long double *target, const long double *source, size_t len, int pe); +#if OSHMEM_HAVE_C11 +#define shmem_put(dst, src, len, pe) \ + _Generic(&*(dst), \ + char*: shmem_char_put, \ + short*: shmem_short_put, \ + int*: shmem_int_put, \ + long*: shmem_long_put, \ + long long*: shmem_longlong_put, \ + float*: shmem_float_put, \ + double*: shmem_double_put, \ + long double*: shmem_longdouble_put)(dst, src, len, pe) +#endif + +OSHMEM_DECLSPEC void shmem_put8(void *target, const void *source, size_t len, int pe); +OSHMEM_DECLSPEC void shmem_put16(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_put32(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_put64(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_put128(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_putmem(void *target, const void *source, size_t len, int pe); + /* * Strided put routines */ +OSHMEM_DECLSPEC void shmem_char_iput(char* target, const char* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void shmem_short_iput(short* target, const short* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void shmem_int_iput(int* target, const int* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); +OSHMEM_DECLSPEC void shmem_long_iput(long* target, const long* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void shmem_float_iput(float* target, const float* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void shmem_double_iput(double* target, const double* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void shmem_longlong_iput(long long* target, const long long* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void shmem_longdouble_iput(long double* target, const long double* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); -OSHMEM_DECLSPEC void shmem_long_iput(long* target, const long* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); +#if OSHMEM_HAVE_C11 +#define shmem_iput(dst, src, tst, sst, len, pe) \ + _Generic(&*(dst), \ + char*: shmem_char_iput, \ + short*: shmem_short_iput, \ + int*: shmem_int_iput, \ + long*: shmem_long_iput, \ + long long*: shmem_longlong_iput, \ + float*: shmem_float_iput, \ + double*: shmem_double_iput, \ + long double*: shmem_longdouble_iput)(dst, src, tst, sst, len, pe) +#endif + +OSHMEM_DECLSPEC void shmem_iput8(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); +OSHMEM_DECLSPEC void shmem_iput16(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void shmem_iput32(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void shmem_iput64(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void shmem_iput128(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); @@ -196,7 +246,6 @@ OSHMEM_DECLSPEC void shmem_iput128(void* target, const void* source, ptrdiff_t t /* * Nonblocking put routines */ -OSHMEM_DECLSPEC void shmem_putmem_nbi(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_char_put_nbi(char *target, const char *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_short_put_nbi(short *target, const short *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_int_put_nbi(int* target, const int* source, size_t len, int pe); @@ -205,11 +254,25 @@ OSHMEM_DECLSPEC void shmem_longlong_put_nbi(long long *target, const long long OSHMEM_DECLSPEC void shmem_float_put_nbi(float *target, const float *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_double_put_nbi(double *target, const double *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_longdouble_put_nbi(long double *target, const long double *source, size_t len, int pe); +#if OSHMEM_HAVE_C11 +#define shmem_put_nbi(dst, src, len, pe) \ + _Generic(&*(dst), \ + char*: shmem_char_put_nbi, \ + short*: shmem_short_put_nbi, \ + int*: shmem_int_put_nbi, \ + long*: shmem_long_put_nbi, \ + long long*: shmem_longlong_put_nbi, \ + float*: shmem_float_put_nbi, \ + double*: shmem_double_put_nbi, \ + long double*: shmem_longdouble_put_nbi)(dst, src, len, pe) +#endif + OSHMEM_DECLSPEC void shmem_put8_nbi(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_put16_nbi(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_put32_nbi(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_put64_nbi(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_put128_nbi(void *target, const void *source, size_t len, int pe); +OSHMEM_DECLSPEC void shmem_putmem_nbi(void *target, const void *source, size_t len, int pe); /* * Elemental get routines @@ -222,10 +285,23 @@ OSHMEM_DECLSPEC float shmem_float_g(const float* addr, int pe); OSHMEM_DECLSPEC double shmem_double_g(const double* addr, int pe); OSHMEM_DECLSPEC long long shmem_longlong_g(const long long* addr, int pe); OSHMEM_DECLSPEC long double shmem_longdouble_g(const long double* addr, int pe); +#if OSHMEM_HAVE_C11 +#define shmem_g(addr, pe) \ + _Generic(&*(dst), \ + char*: shmem_char_g, \ + short*: shmem_short_g, \ + int*: shmem_int_g, \ + long*: shmem_long_g, \ + long long*: shmem_longlong_g, \ + float*: shmem_float_g, \ + double*: shmem_double_g, \ + long double*: shmem_longdouble_g)(addr, pe) +#endif /* * Block data get routines */ +OSHMEM_DECLSPEC void shmem_char_get(char *target, const char *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_short_get(short *target, const short *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_int_get(int *target, const int *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_long_get(long *target, const long *source, size_t len, int pe); @@ -233,6 +309,21 @@ OSHMEM_DECLSPEC void shmem_float_get(float *target, const float *source, size_t OSHMEM_DECLSPEC void shmem_double_get(double *target, const double *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_longlong_get(long long *target, const long long *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_longdouble_get(long double *target, const long double *source, size_t len, int pe); +#if OSHMEM_HAVE_C11 +#define shmem_get(dst, src, len, pe) \ + _Generic(&*(dst), \ + char*: shmem_char_get, \ + short*: shmem_short_get, \ + int*: shmem_int_get, \ + long*: shmem_long_get, \ + long long*: shmem_longlong_get, \ + float*: shmem_float_get, \ + double*: shmem_double_get, \ + long double*: shmem_longdouble_get)(dst, src, len, pe) +#endif + +OSHMEM_DECLSPEC void shmem_get8(void *target, const void *source, size_t len, int pe); +OSHMEM_DECLSPEC void shmem_get16(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_get32(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_get64(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_get128(void *target, const void *source, size_t len, int pe); @@ -241,6 +332,7 @@ OSHMEM_DECLSPEC void shmem_getmem(void *target, const void *source, size_t len, /* * Strided get routines */ +OSHMEM_DECLSPEC void shmem_char_iget(char* target, const char* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void shmem_short_iget(short* target, const short* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void shmem_int_iget(int* target, const int* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void shmem_float_iget(float* target, const float* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); @@ -248,6 +340,21 @@ OSHMEM_DECLSPEC void shmem_double_iget(double* target, const double* source, ptr OSHMEM_DECLSPEC void shmem_longlong_iget(long long* target, const long long* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void shmem_longdouble_iget(long double* target, const long double* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void shmem_long_iget(long* target, const long* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); +#if OSHMEM_HAVE_C11 +#define shmem_iget(dst, src, tst, sst, len, pe) \ + _Generic(&*(dst), \ + char*: shmem_char_iget, \ + short*: shmem_short_iget, \ + int*: shmem_int_iget, \ + long*: shmem_long_iget, \ + long long*: shmem_longlong_iget, \ + float*: shmem_float_iget, \ + double*: shmem_double_iget, \ + long double*: shmem_longdouble_iget)(dst, src, tst, sst, len, pe) +#endif + +OSHMEM_DECLSPEC void shmem_iget8(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); +OSHMEM_DECLSPEC void shmem_iget16(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void shmem_iget32(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void shmem_iget64(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); OSHMEM_DECLSPEC void shmem_iget128(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); @@ -255,7 +362,6 @@ OSHMEM_DECLSPEC void shmem_iget128(void* target, const void* source, ptrdiff_t t /* * Nonblocking data get routines */ -OSHMEM_DECLSPEC void shmem_getmem_nbi(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_char_get_nbi(char *target, const char *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_short_get_nbi(short *target, const short *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_int_get_nbi(int *target, const int *source, size_t len, int pe); @@ -264,47 +370,138 @@ OSHMEM_DECLSPEC void shmem_longlong_get_nbi(long long *target, const long long OSHMEM_DECLSPEC void shmem_float_get_nbi(float *target, const float *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_double_get_nbi(double *target, const double *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_longdouble_get_nbi(long double *target, const long double *source, size_t len, int pe); +#if OSHMEM_HAVE_C11 +#define shmem_get_nbi(dst, src, len, pe) \ + _Generic(&*(dst), \ + char*: shmem_char_get_nbi, \ + short*: shmem_short_get_nbi, \ + int*: shmem_int_get_nbi, \ + long*: shmem_long_get_nbi, \ + long long*: shmem_longlong_get_nbi, \ + float*: shmem_float_get_nbi, \ + double*: shmem_double_get_nbi, \ + long double*: shmem_longdouble_get_nbi)(dst, src, len, pe) +#endif + OSHMEM_DECLSPEC void shmem_get8_nbi(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_get16_nbi(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_get32_nbi(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_get64_nbi(void *target, const void *source, size_t len, int pe); OSHMEM_DECLSPEC void shmem_get128_nbi(void *target, const void *source, size_t len, int pe); +OSHMEM_DECLSPEC void shmem_getmem_nbi(void *target, const void *source, size_t len, int pe); /* * Atomic operations */ /* Atomic swap */ -OSHMEM_DECLSPEC long shmem_swap(long *target, long value, int pe); -OSHMEM_DECLSPEC double shmem_double_swap(double *target, double value, int pe); -OSHMEM_DECLSPEC float shmem_float_swap(float *target, float value, int pe); 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); +OSHMEM_DECLSPEC float shmem_float_swap(float *target, float value, int pe); +OSHMEM_DECLSPEC double shmem_double_swap(double *target, double value, int pe); +#if OSHMEM_HAVE_C11 +#define shmem_swap(dst, val, pe) \ + _Generic(&*(dst), \ + int*: shmem_int_swap, \ + long*: shmem_long_swap, \ + long long*: shmem_longlong_swap, \ + float*: shmem_float_swap, \ + double*: shmem_double_swap)(dst, val, pe) +#endif + +/* 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); +OSHMEM_DECLSPEC void shmem_float_set(float *target, float value, int pe); +OSHMEM_DECLSPEC void shmem_double_set(double *target, double value, int pe); +#if OSHMEM_HAVE_C11 +#define shmem_set(dst, val, pe) \ + _Generic(&*(dst), \ + int*: shmem_int_set, \ + long*: shmem_long_set, \ + long long*: shmem_longlong_set, \ + float*: shmem_float_set, \ + double*: shmem_double_set)(dst, val, pe) +#endif /* 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); OSHMEM_DECLSPEC long long shmem_longlong_cswap(long long *target, long long cond, long long value, int pe); +#if OSHMEM_HAVE_C11 +#define shmem_cswap(dst, cond, val, pe) \ + _Generic(&*(dst), \ + int*: shmem_int_cswap, \ + long*: shmem_long_cswap, \ + long long*: shmem_longlong_cswap)(dst, cond, val, pe) +#endif + /* Atomic Fetch&Add */ 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); +#if OSHMEM_HAVE_C11 +#define shmem_fadd(dst, val, pe) \ + _Generic(&*(dst), \ + int*: shmem_int_fadd, \ + long*: shmem_long_fadd, \ + long long*: shmem_longlong_fadd)(dst, val, pe) +#endif + +/* 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); +#if OSHMEM_HAVE_C11 +#define shmem_fetch(dst, pe) \ + _Generic(&*(dst), \ + int*: shmem_int_fetch, \ + long*: shmem_long_fetch, \ + long long*: shmem_longlong_fetch, \ + float*: shmem_float_fetch, \ + double*: shmem_double_fetch)(dst, pe) +#endif /* Atomic Fetch&Inc */ OSHMEM_DECLSPEC int shmem_int_finc(int *target, int pe); OSHMEM_DECLSPEC long shmem_long_finc(long *target, int pe); OSHMEM_DECLSPEC long long shmem_longlong_finc(long long *target, int pe); +#if OSHMEM_HAVE_C11 +#define shmem_finc(dst, pe) \ + _Generic(&*(dst), \ + int*: shmem_int_finc, \ + long*: shmem_long_finc, \ + long long*: shmem_longlong_finc)(dst, pe) +#endif /* Atomic Add*/ OSHMEM_DECLSPEC void shmem_int_add(int *target, int value, int pe); OSHMEM_DECLSPEC void shmem_long_add(long *target, long value, int pe); OSHMEM_DECLSPEC void shmem_longlong_add(long long *target, long long value, int pe); +#if OSHMEM_HAVE_C11 +#define shmem_add(dst, val, pe) \ + _Generic(&*(dst), \ + int*: shmem_int_add, \ + long*: shmem_long_add, \ + long long*: shmem_longlong_add)(dst, val, pe) +#endif /* Atomic Inc */ OSHMEM_DECLSPEC void shmem_int_inc(int *target, int pe); OSHMEM_DECLSPEC void shmem_long_inc(long *target, int pe); OSHMEM_DECLSPEC void shmem_longlong_inc(long long *target, int pe); +#if OSHMEM_HAVE_C11 +#define shmem_inc(dst, pe) \ + _Generic(&*(dst), \ + int*: shmem_int_inc, \ + long*: shmem_long_inc, \ + long long*: shmem_longlong_inc)(dst, pe) +#endif + /* * Lock functions diff --git a/oshmem/include/shmemx.h b/oshmem/include/shmemx.h index 7f4352db7a3..da1fb7f1d55 100644 --- a/oshmem/include/shmemx.h +++ b/oshmem/include/shmemx.h @@ -35,12 +35,10 @@ OSHMEM_DECLSPEC void shmemx_int64_p(int64_t* addr, int64_t value, int pe); /* * Block data put routines */ -OSHMEM_DECLSPEC void shmemx_put16(void *target, const void *source, size_t len, int pe); /* * Strided put routines */ -OSHMEM_DECLSPEC void shmemx_iput16(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); /* * Elemental get routines @@ -52,12 +50,10 @@ OSHMEM_DECLSPEC int64_t shmemx_int64_g(const int64_t* addr, int pe); /* * Block data get routines */ -OSHMEM_DECLSPEC void shmemx_get16(void *target, const void *source, size_t len, int pe); /* * Strided get routines */ -OSHMEM_DECLSPEC void shmemx_iget16(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe); /* * Atomic operations @@ -66,6 +62,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); + /* 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 +74,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); + /* 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); @@ -133,25 +137,28 @@ OSHMEM_DECLSPEC void shmemx_int64_prod_to_all(int64_t *target, const int64_t *so #define shmem_int32_p shmemx_int32_p #define shmem_int64_p shmemx_int64_p -#define shmem_put16 shmemx_put16 -#define shmem_iput16 shmemx_iput16 - #define shmem_int16_g shmemx_int16_g #define shmem_int32_g shmemx_int32_g #define shmem_int64_g shmemx_int64_g -#define shmem_get16 shmemx_get16 -#define shmem_iget16 shmemx_iget16 - #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 diff --git a/oshmem/shmem/c/Makefile.am b/oshmem/shmem/c/Makefile.am index 1a8820fd3f4..c60ba29bcc4 100644 --- a/oshmem/shmem/c/Makefile.am +++ b/oshmem/shmem/c/Makefile.am @@ -51,8 +51,10 @@ OSHMEM_API_SOURCES = \ shmem_clear_cache_line_inv.c \ shmem_reduce.c \ shmem_swap.c \ + shmem_set.c \ shmem_cswap.c \ shmem_fadd.c \ + shmem_fetch.c \ shmem_finc.c \ shmem_add.c \ shmem_inc.c \ diff --git a/oshmem/shmem/c/profile/Makefile.am b/oshmem/shmem/c/profile/Makefile.am index fe0af74b529..d7fdb187f07 100644 --- a/oshmem/shmem/c/profile/Makefile.am +++ b/oshmem/shmem/c/profile/Makefile.am @@ -63,8 +63,10 @@ OSHMEM_API_SOURCES = \ pshmem_clear_cache_line_inv.c \ pshmem_reduce.c \ pshmem_swap.c \ + pshmem_set.c \ pshmem_cswap.c \ pshmem_fadd.c \ + pshmem_fetch.c \ pshmem_finc.c \ pshmem_add.c \ pshmem_inc.c \ diff --git a/oshmem/shmem/c/profile/defines.h b/oshmem/shmem/c/profile/defines.h index d0f0bb34320..9a376a941ff 100644 --- a/oshmem/shmem/c/profile/defines.h +++ b/oshmem/shmem/c/profile/defines.h @@ -86,7 +86,9 @@ #define shmem_double_put pshmem_double_put #define shmem_longlong_put pshmem_longlong_put #define shmem_longdouble_put pshmem_longdouble_put -#define shmemx_put16 pshmemx_put16 + +#define shmem_put8 pshmem_put8 +#define shmem_put16 pshmem_put16 #define shmem_put32 pshmem_put32 #define shmem_put64 pshmem_put64 #define shmem_put128 pshmem_put128 @@ -95,14 +97,17 @@ /* * Strided put routines */ -#define shmem_int_iput pshmem_int_iput +#define shmem_char_iput pshmem_char_iput #define shmem_short_iput pshmem_short_iput +#define shmem_int_iput pshmem_int_iput #define shmem_float_iput pshmem_float_iput #define shmem_double_iput pshmem_double_iput #define shmem_longlong_iput pshmem_longlong_iput #define shmem_longdouble_iput pshmem_longdouble_iput #define shmem_long_iput pshmem_long_iput -#define shmemx_iput16 pshmemx_iput16 + +#define shmem_iput8 pshmem_iput8 +#define shmem_iput16 pshmem_iput16 #define shmem_iput32 pshmem_iput32 #define shmem_iput64 pshmem_iput64 #define shmem_iput128 pshmem_iput128 @@ -151,7 +156,9 @@ #define shmem_double_get pshmem_double_get #define shmem_longlong_get pshmem_longlong_get #define shmem_longdouble_get pshmem_longdouble_get -#define shmemx_get16 pshmemx_get16 + +#define shmem_get8 pshmem_get8 +#define shmem_get16 pshmem_get16 #define shmem_get32 pshmem_get32 #define shmem_get64 pshmem_get64 #define shmem_get128 pshmem_get128 @@ -160,14 +167,17 @@ /* * Strided get routines */ -#define shmem_int_iget pshmem_int_iget +#define shmem_char_iget pshmem_char_iget #define shmem_short_iget pshmem_short_iget +#define shmem_int_iget pshmem_int_iget #define shmem_float_iget pshmem_float_iget #define shmem_double_iget pshmem_double_iget #define shmem_longlong_iget pshmem_longlong_iget #define shmem_longdouble_iget pshmem_longdouble_iget #define shmem_long_iget pshmem_long_iget -#define shmemx_iget16 pshmemx_iget16 + +#define shmem_iget8 pshmem_iget8 +#define shmem_iget16 pshmem_iget16 #define shmem_iget32 pshmem_iget32 #define shmem_iget64 pshmem_iget64 #define shmem_iget128 pshmem_iget128 @@ -194,7 +204,6 @@ * Atomic operations */ /* Atomic swap */ -#define shmem_swap pshmem_swap #define shmem_double_swap pshmem_double_swap #define shmem_float_swap pshmem_float_swap #define shmem_int_swap pshmem_int_swap @@ -203,6 +212,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 /* Atomic conditional swap */ #define shmem_int_cswap pshmem_int_cswap @@ -219,6 +236,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 + /* Atomic Fetch&Inc */ #define shmem_int_finc pshmem_int_finc #define shmem_long_finc pshmem_long_finc diff --git a/oshmem/shmem/c/shmem_fetch.c b/oshmem/shmem/c/shmem_fetch.c new file mode 100644 index 00000000000..264b31143fb --- /dev/null +++ b/oshmem/shmem/c/shmem_fetch.c @@ -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 + * 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, \ + 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 +#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) + diff --git a/oshmem/shmem/c/shmem_get.c b/oshmem/shmem/c/shmem_get.c index cfea3217579..8ad81890453 100644 --- a/oshmem/shmem/c/shmem_get.c +++ b/oshmem/shmem/c/shmem_get.c @@ -54,7 +54,8 @@ #pragma weak shmem_double_get = pshmem_double_get #pragma weak shmem_longdouble_get = pshmem_longdouble_get #pragma weak shmem_getmem = pshmem_getmem -#pragma weak shmemx_get16 = pshmemx_get16 +#pragma weak shmem_get8 = pshmem_get8 +#pragma weak shmem_get16 = pshmem_get16 #pragma weak shmem_get32 = pshmem_get32 #pragma weak shmem_get64 = pshmem_get64 #pragma weak shmem_get128 = pshmem_get128 @@ -92,9 +93,9 @@ SHMEM_TYPE_GET(_longdouble, long double) } SHMEM_TYPE_GETMEM(_getmem, 1, shmem) -SHMEM_TYPE_GETMEM(_get16, 2, shmemx) +SHMEM_TYPE_GETMEM(_get8, 1, shmem) +SHMEM_TYPE_GETMEM(_get16, 2, shmem) SHMEM_TYPE_GETMEM(_get32, 4, shmem) SHMEM_TYPE_GETMEM(_get64, 8, shmem) SHMEM_TYPE_GETMEM(_get128, 16, shmem) -SHMEM_TYPE_GETMEM(_get, sizeof(long), shmem) diff --git a/oshmem/shmem/c/shmem_iget.c b/oshmem/shmem/c/shmem_iget.c index f396d874be4..4e8e7154f6a 100644 --- a/oshmem/shmem/c/shmem_iget.c +++ b/oshmem/shmem/c/shmem_iget.c @@ -50,6 +50,7 @@ #if OSHMEM_PROFILING #include "oshmem/include/pshmem.h" +#pragma weak shmem_char_iget = pshmem_char_iget #pragma weak shmem_short_iget = pshmem_short_iget #pragma weak shmem_int_iget = pshmem_int_iget #pragma weak shmem_long_iget = pshmem_long_iget @@ -57,13 +58,15 @@ #pragma weak shmem_float_iget = pshmem_float_iget #pragma weak shmem_double_iget = pshmem_double_iget #pragma weak shmem_longdouble_iget = pshmem_longdouble_iget -#pragma weak shmemx_iget16 = pshmemx_iget16 +#pragma weak shmem_iget8 = pshmem_iget8 +#pragma weak shmem_iget16 = pshmem_iget16 #pragma weak shmem_iget32 = pshmem_iget32 #pragma weak shmem_iget64 = pshmem_iget64 #pragma weak shmem_iget128 = pshmem_iget128 #include "oshmem/shmem/c/profile/defines.h" #endif +SHMEM_TYPE_IGET(_char, char) SHMEM_TYPE_IGET(_short, short) SHMEM_TYPE_IGET(_int, int) SHMEM_TYPE_IGET(_long, long) @@ -95,7 +98,9 @@ SHMEM_TYPE_IGET(_longdouble, long double) return ; \ } -SHMEM_TYPE_IGETMEM(_iget16, 2, shmemx) +SHMEM_TYPE_IGETMEM(_iget8, 1, shmem) +SHMEM_TYPE_IGETMEM(_iget16, 2, shmem) SHMEM_TYPE_IGETMEM(_iget32, 4, shmem) SHMEM_TYPE_IGETMEM(_iget64, 8, shmem) SHMEM_TYPE_IGETMEM(_iget128, 16, shmem) + diff --git a/oshmem/shmem/c/shmem_iput.c b/oshmem/shmem/c/shmem_iput.c index 29d893d8a23..9067963a6fe 100644 --- a/oshmem/shmem/c/shmem_iput.c +++ b/oshmem/shmem/c/shmem_iput.c @@ -50,6 +50,7 @@ #if OSHMEM_PROFILING #include "oshmem/include/pshmem.h" +#pragma weak shmem_char_iput = pshmem_char_iput #pragma weak shmem_short_iput = pshmem_short_iput #pragma weak shmem_int_iput = pshmem_int_iput #pragma weak shmem_long_iput = pshmem_long_iput @@ -57,13 +58,15 @@ #pragma weak shmem_float_iput = pshmem_float_iput #pragma weak shmem_double_iput = pshmem_double_iput #pragma weak shmem_longdouble_iput = pshmem_longdouble_iput -#pragma weak shmemx_iput16 = pshmemx_iput16 +#pragma weak shmemx_iput8 = pshmem_iput8 +#pragma weak shmemx_iput16 = pshmem_iput16 #pragma weak shmem_iput32 = pshmem_iput32 #pragma weak shmem_iput64 = pshmem_iput64 #pragma weak shmem_iput128 = pshmem_iput128 #include "oshmem/shmem/c/profile/defines.h" #endif +SHMEM_TYPE_IPUT(_char, char) SHMEM_TYPE_IPUT(_short, short) SHMEM_TYPE_IPUT(_int, int) SHMEM_TYPE_IPUT(_long, long) @@ -95,7 +98,8 @@ SHMEM_TYPE_IPUT(_longdouble, long double) return ; \ } -SHMEM_TYPE_IPUTMEM(_iput16, 2, shmemx) +SHMEM_TYPE_IPUTMEM(_iput8, 1, shmem) +SHMEM_TYPE_IPUTMEM(_iput16, 2, shmem) SHMEM_TYPE_IPUTMEM(_iput32, 4, shmem) SHMEM_TYPE_IPUTMEM(_iput64, 8, shmem) SHMEM_TYPE_IPUTMEM(_iput128, 16, shmem) diff --git a/oshmem/shmem/c/shmem_lock.c b/oshmem/shmem/c/shmem_lock.c index 338e2882979..3d167b61d57 100644 --- a/oshmem/shmem/c/shmem_lock.c +++ b/oshmem/shmem/c/shmem_lock.c @@ -251,11 +251,11 @@ static int extract_second_word(void *lock, int lock_size, int *two) return extract_2_words(lock, lock_size, &one, two); } -static uint64_t shmem_cswap(void *target, - int target_size, - uint64_t cond, - uint64_t value, - int pe) +static uint64_t shmem_lock_cswap(void *target, + int target_size, + uint64_t cond, + uint64_t value, + int pe) { uint64_t prev_value = 0; @@ -274,10 +274,10 @@ static uint64_t shmem_cswap(void *target, return prev_value; } -static uint64_t shmem_fadd(void *target, - int target_size, - uint64_t value, - int pe) +static uint64_t shmem_lock_fadd(void *target, + int target_size, + uint64_t value, + int pe) { uint64_t prev_value = 0; @@ -316,11 +316,11 @@ static int pack_first_word(void *lock, extract_second_word(&lock_value, lock_size, &two); pack_2_words(&new_long_value, lock_size, one, &two); while (lock_value - != (temp = shmem_cswap(lock, - lock_size, - lock_value, - new_long_value, - my_pe))) { + != (temp = shmem_lock_cswap(lock, + lock_size, + lock_value, + new_long_value, + my_pe))) { lock_value = temp; extract_second_word(&lock_value, lock_size, &two); pack_2_words(&new_long_value, lock_size, one, &two); @@ -367,11 +367,11 @@ static int pack_second_word(void *lock, extract_first_word(&lock_value, lock_size, &one); pack_2_words(&new_long_value, lock_size, &one, two); while (lock_value - != (temp = shmem_cswap(lock, - lock_size, - lock_value, - new_long_value, - my_pe))) { + != (temp = shmem_lock_cswap(lock, + lock_size, + lock_value, + new_long_value, + my_pe))) { lock_value = temp; extract_first_word(&lock_value, lock_size, &one); pack_2_words(&new_long_value, lock_size, &one, two); @@ -691,11 +691,11 @@ static int shmem_lock_wait_for_ticket(void *lock, new_server_lock = server_lock = temp; lock_pack_pe_last(&new_server_lock, lock_size, &my_pe, 0); } while (server_lock - != (temp = shmem_cswap(lock, - lock_size, - server_lock, - new_server_lock, - server_pe))); + != (temp = shmem_lock_cswap(lock, + lock_size, + server_lock, + new_server_lock, + server_pe))); lock_extract_pe_last(&server_lock, lock_size, pe_last); if (*pe_last == -1) { /* we are first in queue for the lock */ @@ -724,7 +724,7 @@ static int shmem_lock_subscribe_for_informing(void *lock, int remote_prev_pe_next = 0; uint64_t prev_remote_value = 1; - prev_remote_value = shmem_fadd(lock, lock_size, my_pe + 1, pe_last); + prev_remote_value = shmem_lock_fadd(lock, lock_size, my_pe + 1, pe_last); if (my_pe == server_pe) { lock_save_prev_pe(lock, pe_last); } @@ -751,11 +751,11 @@ static int shmem_lock_subscribe_for_informing(void *lock, prev_remote_value += my_pe + 1; while (prev_remote_value - != (temp_value = shmem_cswap(lock, - lock_size, - prev_remote_value, - new_remote_value, - pe_last))) { + != (temp_value = shmem_lock_cswap(lock, + lock_size, + prev_remote_value, + new_remote_value, + pe_last))) { prev_remote_value = temp_value; lock_extract_counter(&prev_remote_value, lock_size, @@ -849,11 +849,11 @@ static int shmem_lock_inform_next(void *lock, int lock_size, int pe_next) | (((uint64_t) 1) << (lock_bitwise_size - 1)); while (remote_value - != (temp_value = shmem_cswap(lock, - lock_size, - remote_value, - new_remote_value, - pe_next))) { + != (temp_value = shmem_lock_cswap(lock, + lock_size, + remote_value, + new_remote_value, + pe_next))) { remote_value = temp_value; new_remote_value = remote_value | (((uint64_t) 1) << (lock_bitwise_size - 1)); @@ -938,7 +938,7 @@ static int shmem_lock_try_inform_server(void *lock, int lock_size) &incorrect_pe, &my_pe); return !(remote_value - == shmem_cswap(lock, lock_size, remote_value, zero, server_pe)); + == shmem_lock_cswap(lock, lock_size, remote_value, zero, server_pe)); } /***************************************************************************/ @@ -987,11 +987,11 @@ int _shmem_test_lock(void *lock, int lock_size) goto FreeMemory; } - prev_lock_value = shmem_cswap(lock, - lock_size, - 0, - new_lock_value, - server_pe); + prev_lock_value = shmem_lock_cswap(lock, + lock_size, + 0, + new_lock_value, + server_pe); } if (0 == prev_lock_value || my_lock) { diff --git a/oshmem/shmem/c/shmem_put.c b/oshmem/shmem/c/shmem_put.c index 7d78e8d76c7..73322562450 100644 --- a/oshmem/shmem/c/shmem_put.c +++ b/oshmem/shmem/c/shmem_put.c @@ -57,7 +57,8 @@ #pragma weak shmem_double_put = pshmem_double_put #pragma weak shmem_longdouble_put = pshmem_longdouble_put #pragma weak shmem_putmem = pshmem_putmem -#pragma weak shmemx_put16 = pshmemx_put16 +#pragma weak shmem_put8 = pshmem_put8 +#pragma weak shmem_put16 = pshmem_put16 #pragma weak shmem_put32 = pshmem_put32 #pragma weak shmem_put64 = pshmem_put64 #pragma weak shmem_put128 = pshmem_put128 @@ -95,9 +96,9 @@ SHMEM_TYPE_PUT(_longdouble, long double) } SHMEM_TYPE_PUTMEM(_putmem, 1, shmem) -SHMEM_TYPE_PUTMEM(_put16, 2, shmemx) +SHMEM_TYPE_PUTMEM(_put8, 1, shmem) +SHMEM_TYPE_PUTMEM(_put16, 2, shmem) SHMEM_TYPE_PUTMEM(_put32, 4, shmem) SHMEM_TYPE_PUTMEM(_put64, 8, shmem) SHMEM_TYPE_PUTMEM(_put128, 16, shmem) -SHMEM_TYPE_PUTMEM(_put, sizeof(long), shmem) diff --git a/oshmem/shmem/c/shmem_set.c b/oshmem/shmem/c/shmem_set.c new file mode 100644 index 00000000000..ce7193affa0 --- /dev/null +++ b/oshmem/shmem/c/shmem_set.c @@ -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) + diff --git a/oshmem/shmem/c/shmem_swap.c b/oshmem/shmem/c/shmem_swap.c index 0a757af9a96..5f6fe462316 100644 --- a/oshmem/shmem/c/shmem_swap.c +++ b/oshmem/shmem/c/shmem_swap.c @@ -48,7 +48,6 @@ #if OSHMEM_PROFILING #include "oshmem/include/pshmem.h" -#pragma weak shmem_swap = pshmem_swap #pragma weak shmem_int_swap = pshmem_int_swap #pragma weak shmem_long_swap = pshmem_long_swap #pragma weak shmem_longlong_swap = pshmem_longlong_swap @@ -59,7 +58,6 @@ #include "oshmem/shmem/c/profile/defines.h" #endif -SHMEM_TYPE_SWAP(, long, shmem) SHMEM_TYPE_SWAP(_int, int, shmem) SHMEM_TYPE_SWAP(_long, long, shmem) SHMEM_TYPE_SWAP(_longlong, long long, shmem) diff --git a/oshmem/shmem/fortran/Makefile.am b/oshmem/shmem/fortran/Makefile.am index f9fb6918f48..25610758f9f 100644 --- a/oshmem/shmem/fortran/Makefile.am +++ b/oshmem/shmem/fortran/Makefile.am @@ -46,7 +46,6 @@ liboshmem_fortran_la_SOURCES += \ shmem_ptr_f.c \ shmem_pe_accessible_f.c \ shmem_addr_accessible_f.c \ - shmem_put_f.c \ shmem_character_put_f.c \ shmem_double_put_f.c \ shmem_complex_put_f.c \ @@ -98,10 +97,18 @@ liboshmem_fortran_la_SOURCES += \ shmem_int8_swap_f.c \ shmem_real4_swap_f.c \ shmem_real8_swap_f.c \ + shmem_int4_set_f.c \ + shmem_int8_set_f.c \ + shmem_real4_set_f.c \ + shmem_real8_set_f.c \ shmem_int4_cswap_f.c \ shmem_int8_cswap_f.c \ shmem_int4_fadd_f.c \ shmem_int8_fadd_f.c \ + shmem_int4_fetch_f.c \ + shmem_int8_fetch_f.c \ + shmem_real4_fetch_f.c \ + shmem_real8_fetch_f.c \ shmem_int4_finc_f.c \ shmem_int8_finc_f.c \ shmem_int4_add_f.c \ diff --git a/oshmem/shmem/fortran/profile/Makefile.am b/oshmem/shmem/fortran/profile/Makefile.am index 8faaec12f05..546d56eac65 100644 --- a/oshmem/shmem/fortran/profile/Makefile.am +++ b/oshmem/shmem/fortran/profile/Makefile.am @@ -38,7 +38,6 @@ nodist_liboshmem_fortran_pshmem_la_SOURCES = \ pshmem_ptr_f.c \ pshmem_pe_accessible_f.c \ pshmem_addr_accessible_f.c \ - pshmem_put_f.c \ pshmem_character_put_f.c \ pshmem_double_put_f.c \ pshmem_complex_put_f.c \ @@ -90,10 +89,18 @@ nodist_liboshmem_fortran_pshmem_la_SOURCES = \ pshmem_int8_swap_f.c \ pshmem_real4_swap_f.c \ pshmem_real8_swap_f.c \ + pshmem_int4_set_f.c \ + pshmem_int8_set_f.c \ + pshmem_real4_set_f.c \ + pshmem_real8_set_f.c \ pshmem_int4_cswap_f.c \ pshmem_int8_cswap_f.c \ pshmem_int4_fadd_f.c \ pshmem_int8_fadd_f.c \ + pshmem_int4_fetch_f.c \ + pshmem_int8_fetch_f.c \ + pshmem_real4_fetch_f.c \ + pshmem_real8_fetch_f.c \ pshmem_int4_finc_f.c \ pshmem_int8_finc_f.c \ pshmem_int4_add_f.c \ diff --git a/oshmem/shmem/fortran/profile/defines.h b/oshmem/shmem/fortran/profile/defines.h index c926d3d6b24..64b866902c6 100644 --- a/oshmem/shmem/fortran/profile/defines.h +++ b/oshmem/shmem/fortran/profile/defines.h @@ -366,6 +366,10 @@ #define shmem_int4_fadd_ pshmem_int4_fadd_ #define shmem_int4_fadd__ pshmem_int4_fadd__ +#define SHMEM_INT4_FETCH PSHMEM_INT4_FETCH +#define shmem_int4_fetch_ pshmem_int4_fetch_ +#define shmem_int4_fetch__ pshmem_int4_fetch__ + #define SHMEM_INT4_FINC PSHMEM_INT4_FINC #define shmem_int4_finc_ pshmem_int4_finc_ #define shmem_int4_finc__ pshmem_int4_finc__ @@ -378,6 +382,10 @@ #define shmem_int4_swap_ pshmem_int4_swap_ #define shmem_int4_swap__ pshmem_int4_swap__ +#define SHMEM_INT4_SET PSHMEM_INT4_SET +#define shmem_int4_set_ pshmem_int4_set_ +#define shmem_int4_set__ pshmem_int4_set__ + #define SHMEM_INT4_WAIT PSHMEM_INT4_WAIT #define shmem_int4_wait_ pshmem_int4_wait_ #define shmem_int4_wait__ pshmem_int4_wait__ @@ -398,6 +406,10 @@ #define shmem_int8_fadd_ pshmem_int8_fadd_ #define shmem_int8_fadd__ pshmem_int8_fadd__ +#define SHMEM_INT8_FETCH PSHMEM_INT8_FETCH +#define shmem_int8_fetch_ pshmem_int8_fetch_ +#define shmem_int8_fetch__ pshmem_int8_fetch__ + #define SHMEM_INT8_FINC PSHMEM_INT8_FINC #define shmem_int8_finc_ pshmem_int8_finc_ #define shmem_int8_finc__ pshmem_int8_finc__ @@ -410,6 +422,10 @@ #define shmem_int8_swap_ pshmem_int8_swap_ #define shmem_int8_swap__ pshmem_int8_swap__ +#define SHMEM_INT8_SET PSHMEM_INT8_SET +#define shmem_int8_set_ pshmem_int8_set_ +#define shmem_int8_set__ pshmem_int8_set__ + #define SHMEM_INT8_WAIT PSHMEM_INT8_WAIT #define shmem_int8_wait_ pshmem_int8_wait_ #define shmem_int8_wait__ pshmem_int8_wait__ @@ -622,6 +638,22 @@ #define shmem_real8_swap_ pshmem_real8_swap_ #define shmem_real8_swap__ pshmem_real8_swap__ +#define SHMEM_REAL4_SET PSHMEM_REAL4_SET +#define shmem_real4_set_ pshmem_real4_set_ +#define shmem_real4_set__ pshmem_real4_set__ + +#define SHMEM_REAL8_SET PSHMEM_REAL8_SET +#define shmem_real8_set_ pshmem_real8_set_ +#define shmem_real8_set__ pshmem_real8_set__ + +#define SHMEM_REAL4_FETCH PSHMEM_REAL4_FETCH +#define shmem_real4_fetch_ pshmem_real4_fetch_ +#define shmem_real4_fetch__ pshmem_real4_fetch__ + +#define SHMEM_REAL8_FETCH PSHMEM_REAL8_FETCH +#define shmem_real8_fetch_ pshmem_real8_fetch_ +#define shmem_real8_fetch__ pshmem_real8_fetch__ + #define SHMEM_REAL_GET PSHMEM_REAL_GET #define shmem_real_get_ pshmem_real_get_ #define shmem_real_get__ pshmem_real_get__ diff --git a/oshmem/shmem/fortran/profile/prototypes_pshmem.h b/oshmem/shmem/fortran/profile/prototypes_pshmem.h index 30634de1428..61a350a8b8f 100644 --- a/oshmem/shmem/fortran/profile/prototypes_pshmem.h +++ b/oshmem/shmem/fortran/profile/prototypes_pshmem.h @@ -37,7 +37,6 @@ PN (FORTRAN_POINTER_T*, pshmem_ptr, PSHMEM_PTR, (FORTRAN_POINTER_T target, MPI_F PN (ompi_fortran_logical_t, pshmem_pe_accessible, PSHMEM_PE_ACCESSIBLE, (MPI_Fint *pe)); PN (MPI_Fint, pshmem_addr_accessible, PSHMEM_ADDR_ACCESSIBLE, (FORTRAN_POINTER_T addr, MPI_Fint *pe)); -PN (void, pshmem_put, PSHMEM_PUT, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T source, MPI_Fint *length, MPI_Fint *pe)); PN (void, pshmem_character_put, PSHMEM_CHARACTER_PUT, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T source, MPI_Fint *length, MPI_Fint *pe)); PN (void, pshmem_complex_put, PSHMEM_COMPLEX_PUT, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T source, MPI_Fint *length, MPI_Fint *pe)); PN (void, pshmem_double_put, PSHMEM_DOUBLE_PUT, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T source, MPI_Fint *length, MPI_Fint *pe)); @@ -117,10 +116,24 @@ PN (ompi_fortran_integer4_t, pshmem_int4_swap, PSHMEM_INT4_SWAP, (FORTRAN_POINTE PN (ompi_fortran_integer8_t, pshmem_int8_swap, PSHMEM_INT8_SWAP, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe)); PN (ompi_fortran_real4_t, pshmem_real4_swap, PSHMEM_REAL4_SWAP, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe)); PN (ompi_fortran_real8_t, pshmem_real8_swap, PSHMEM_REAL8_SWAP, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe)); + +PN (void, pshmem_int4_set, PSHMEM_INT4_SET, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe)); +PN (void, pshmem_int8_set, PSHMEM_INT8_SET, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe)); +PN (void, pshmem_real4_set, PSHMEM_REAL4_SET, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe)); +PN (void, pshmem_real8_set, PSHMEM_REAL8_SET, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe)); + + PN (ompi_fortran_integer4_t, pshmem_int4_cswap, PSHMEM_INT4_CSWAP, (FORTRAN_POINTER_T target, MPI_Fint *cond, FORTRAN_POINTER_T value, MPI_Fint *pe)); PN (ompi_fortran_integer8_t, pshmem_int8_cswap, PSHMEM_INT8_CSWAP, (FORTRAN_POINTER_T target, MPI_Fint *cond, FORTRAN_POINTER_T value, MPI_Fint *pe)); + PN (ompi_fortran_integer4_t, pshmem_int4_fadd, PSHMEM_INT4_FADD, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe)); PN (ompi_fortran_integer8_t, pshmem_int8_fadd, PSHMEM_INT8_FADD, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe)); + +PN (ompi_fortran_integer4_t, pshmem_int4_fetch, PSHMEM_INT4_FETCH, (FORTRAN_POINTER_T target, MPI_Fint *pe)); +PN (ompi_fortran_integer8_t, pshmem_int8_fetch, PSHMEM_INT8_FETCH, (FORTRAN_POINTER_T target, MPI_Fint *pe)); +PN (ompi_fortran_real4_t, pshmem_real4_fetch, PSHMEM_REAL4_FETCH, (FORTRAN_POINTER_T target, MPI_Fint *pe)); +PN (ompi_fortran_real8_t, pshmem_real8_fetch, PSHMEM_REAL8_FETCH, (FORTRAN_POINTER_T target, MPI_Fint *pe)); + PN (void, pshmem_int4_inc, PSHMEM_INT4_INC, (FORTRAN_POINTER_T target, MPI_Fint *pe)); PN (void, pshmem_int8_inc, PSHMEM_INT8_INC, (FORTRAN_POINTER_T target, MPI_Fint *pe)); PN (ompi_fortran_integer4_t, pshmem_int4_finc, PSHMEM_INT4_FINC, (FORTRAN_POINTER_T target, MPI_Fint *pe)); diff --git a/oshmem/shmem/fortran/prototypes_shmem.h b/oshmem/shmem/fortran/prototypes_shmem.h index 6d4c2f4a686..237521b49b8 100644 --- a/oshmem/shmem/fortran/prototypes_shmem.h +++ b/oshmem/shmem/fortran/prototypes_shmem.h @@ -40,7 +40,6 @@ PN (FORTRAN_POINTER_T*, shmem_ptr, SHMEM_PTR, (FORTRAN_POINTER_T target, MPI_Fin PN (ompi_fortran_logical_t, shmem_pe_accessible, SHMEM_PE_ACCESSIBLE, (MPI_Fint *pe)); PN (MPI_Fint, shmem_addr_accessible, SHMEM_ADDR_ACCESSIBLE, (FORTRAN_POINTER_T addr, MPI_Fint *pe)); -PN (void, shmem_put, SHMEM_PUT, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T source, MPI_Fint *length, MPI_Fint *pe)); PN (void, shmem_character_put, SHMEM_CHARACTER_PUT, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T source, MPI_Fint *length, MPI_Fint *pe)); PN (void, shmem_complex_put, SHMEM_COMPLEX_PUT, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T source, MPI_Fint *length, MPI_Fint *pe)); PN (void, shmem_double_put, SHMEM_DOUBLE_PUT, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T source, MPI_Fint *length, MPI_Fint *pe)); @@ -121,10 +120,23 @@ PN (ompi_fortran_integer4_t, shmem_int4_swap, SHMEM_INT4_SWAP, (FORTRAN_POINTER_ PN (ompi_fortran_integer8_t, shmem_int8_swap, SHMEM_INT8_SWAP, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe)); PN (ompi_fortran_real4_t, shmem_real4_swap, SHMEM_REAL4_SWAP, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe)); PN (ompi_fortran_real8_t, shmem_real8_swap, SHMEM_REAL8_SWAP, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe)); + +PN (void, shmem_int4_set, SHMEM_INT4_SET, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe)); +PN (void, shmem_int8_set, SHMEM_INT8_SET, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe)); +PN (void, shmem_real4_set, SHMEM_REAL4_SET, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe)); +PN (void, shmem_real8_set, SHMEM_REAL8_SET, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe)); + PN (ompi_fortran_integer4_t, shmem_int4_cswap, SHMEM_INT4_CSWAP, (FORTRAN_POINTER_T target, MPI_Fint *cond, FORTRAN_POINTER_T value, MPI_Fint *pe)); PN (ompi_fortran_integer8_t, shmem_int8_cswap, SHMEM_INT8_CSWAP, (FORTRAN_POINTER_T target, MPI_Fint *cond, FORTRAN_POINTER_T value, MPI_Fint *pe)); + PN (ompi_fortran_integer4_t, shmem_int4_fadd, SHMEM_INT4_FADD, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe)); PN (ompi_fortran_integer8_t, shmem_int8_fadd, SHMEM_INT8_FADD, (FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe)); + +PN (ompi_fortran_integer4_t, shmem_int4_fetch, SHMEM_INT4_FETCH, (FORTRAN_POINTER_T target, MPI_Fint *pe)); +PN (ompi_fortran_integer8_t, shmem_int8_fetch, SHMEM_INT8_FETCH, (FORTRAN_POINTER_T target, MPI_Fint *pe)); +PN (ompi_fortran_real4_t, shmem_real4_fetch, SHMEM_REAL4_FETCH, (FORTRAN_POINTER_T target, MPI_Fint *pe)); +PN (ompi_fortran_real8_t, shmem_real8_fetch, SHMEM_REAL8_FETCH, (FORTRAN_POINTER_T target, MPI_Fint *pe)); + PN (void, shmem_int4_inc, SHMEM_INT4_INC, (FORTRAN_POINTER_T target, MPI_Fint *pe)); PN (void, shmem_int8_inc, SHMEM_INT8_INC, (FORTRAN_POINTER_T target, MPI_Fint *pe)); PN (ompi_fortran_integer4_t, shmem_int4_finc, SHMEM_INT4_FINC, (FORTRAN_POINTER_T target, MPI_Fint *pe)); diff --git a/oshmem/shmem/fortran/shmem_int4_fetch_f.c b/oshmem/shmem/fortran/shmem_int4_fetch_f.c new file mode 100644 index 00000000000..46dd4f26c5b --- /dev/null +++ b/oshmem/shmem/fortran/shmem_int4_fetch_f.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2016 Mellanox Technologies, Inc. + * All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "oshmem_config.h" +#include "oshmem/shmem/fortran/bindings.h" +#include "oshmem/include/shmem.h" +#include "oshmem/shmem/shmem_api_logger.h" +#include "oshmem/runtime/runtime.h" +#include "oshmem/mca/atomic/atomic.h" +#include "ompi/datatype/ompi_datatype.h" +#include "oshmem/op/op.h" +#include "stdio.h" + +#if OSHMEM_PROFILING +#include "oshmem/shmem/fortran/profile/pbindings.h" +SHMEM_GENERATE_WEAK_BINDINGS(SHMEM_INT4_FETCH, shmem_int4_fetch) +#include "oshmem/shmem/fortran/profile/defines.h" +#endif + +SHMEM_GENERATE_FORTRAN_BINDINGS_FUNCTION (ompi_fortran_integer4_t, + SHMEM_INT4_FETCH, + shmem_int4_fetch_, + shmem_int4_fetch__, + shmem_int4_fetch_f, + (FORTRAN_POINTER_T target, MPI_Fint *pe), + (target,pe) ) + +ompi_fortran_integer4_t shmem_int4_fetch_f(FORTRAN_POINTER_T target, MPI_Fint *pe) +{ + ompi_fortran_integer4_t out_value = 0; + oshmem_op_t* op = oshmem_op_sum_fint4; + int value = 0; + + MCA_ATOMIC_CALL(fadd(FPTR_2_VOID_PTR(target), + (void *)&out_value, + (const void *)&value, + sizeof(out_value), + OMPI_FINT_2_INT(*pe), + op)); + + return out_value; +} + diff --git a/oshmem/shmem/fortran/shmem_int4_set_f.c b/oshmem/shmem/fortran/shmem_int4_set_f.c new file mode 100644 index 00000000000..9da0d2cc2cd --- /dev/null +++ b/oshmem/shmem/fortran/shmem_int4_set_f.c @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2016 Mellanox Technologies, Inc. + * All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "oshmem_config.h" +#include "oshmem/shmem/fortran/bindings.h" +#include "oshmem/include/shmem.h" +#include "oshmem/shmem/shmem_api_logger.h" +#include "oshmem/runtime/runtime.h" +#include "oshmem/mca/atomic/atomic.h" +#include "ompi/datatype/ompi_datatype.h" +#include "stdio.h" + +#if OSHMEM_PROFILING +#include "oshmem/shmem/fortran/profile/pbindings.h" +SHMEM_GENERATE_WEAK_BINDINGS(SHMEM_INT4_SET, shmem_int4_set) +#include "oshmem/shmem/fortran/profile/defines.h" +#endif + +SHMEM_GENERATE_FORTRAN_BINDINGS_SUB (void, + SHMEM_INT4_SET, + shmem_int4_set_, + shmem_int4_set__, + shmem_int4_set_f, + (FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe), + (target,value,pe) ) + +void shmem_int4_set_f(FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe) +{ + ompi_fortran_integer4_t out_value = 0; + + MCA_ATOMIC_CALL(cswap(FPTR_2_VOID_PTR(target), + (void *)&out_value, + NULL, + FPTR_2_VOID_PTR(value), + sizeof(out_value), + OMPI_FINT_2_INT(*pe))); +} + diff --git a/oshmem/shmem/fortran/shmem_int8_fetch_f.c b/oshmem/shmem/fortran/shmem_int8_fetch_f.c new file mode 100644 index 00000000000..d9bb56370b5 --- /dev/null +++ b/oshmem/shmem/fortran/shmem_int8_fetch_f.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2016 Mellanox Technologies, Inc. + * All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "oshmem_config.h" +#include "oshmem/shmem/fortran/bindings.h" +#include "oshmem/include/shmem.h" +#include "oshmem/shmem/shmem_api_logger.h" +#include "oshmem/runtime/runtime.h" +#include "oshmem/mca/atomic/atomic.h" +#include "ompi/datatype/ompi_datatype.h" +#include "oshmem/op/op.h" +#include "stdio.h" + +#if OSHMEM_PROFILING +#include "oshmem/shmem/fortran/profile/pbindings.h" +SHMEM_GENERATE_WEAK_BINDINGS(SHMEM_INT8_FETCH, shmem_int8_fetch) +#include "oshmem/shmem/fortran/profile/defines.h" +#endif + +SHMEM_GENERATE_FORTRAN_BINDINGS_FUNCTION (ompi_fortran_integer8_t, + SHMEM_INT8_FETCH, + shmem_int8_fetch_, + shmem_int8_fetch__, + shmem_int8_fetch_f, + (FORTRAN_POINTER_T target, MPI_Fint *pe), + (target,pe) ) + +ompi_fortran_integer8_t shmem_int8_fetch_f(FORTRAN_POINTER_T target, MPI_Fint *pe) +{ + ompi_fortran_integer8_t out_value = 0; + oshmem_op_t* op = oshmem_op_sum_fint8; + int value = 0; + + MCA_ATOMIC_CALL(fadd(FPTR_2_VOID_PTR(target), + (void *)&out_value, + (const void *)&value, + sizeof(out_value), + OMPI_FINT_2_INT(*pe), + op)); + + return out_value; +} + diff --git a/oshmem/shmem/fortran/shmem_int8_set_f.c b/oshmem/shmem/fortran/shmem_int8_set_f.c new file mode 100644 index 00000000000..8a1f0113a42 --- /dev/null +++ b/oshmem/shmem/fortran/shmem_int8_set_f.c @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2016 Mellanox Technologies, Inc. + * All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "oshmem_config.h" +#include "oshmem/shmem/fortran/bindings.h" +#include "oshmem/include/shmem.h" +#include "oshmem/shmem/shmem_api_logger.h" +#include "oshmem/runtime/runtime.h" +#include "oshmem/mca/atomic/atomic.h" +#include "ompi/datatype/ompi_datatype.h" +#include "stdio.h" + +#if OSHMEM_PROFILING +#include "oshmem/shmem/fortran/profile/pbindings.h" +SHMEM_GENERATE_WEAK_BINDINGS(SHMEM_INT8_SET, shmem_int8_set) +#include "oshmem/shmem/fortran/profile/defines.h" +#endif + +SHMEM_GENERATE_FORTRAN_BINDINGS_SUB (void, + SHMEM_INT8_SET, + shmem_int8_set_, + shmem_int8_set__, + shmem_int8_set_f, + (FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe), + (target,value,pe) ) + +void shmem_int8_set_f(FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe) +{ + ompi_fortran_integer8_t out_value = 0; + + MCA_ATOMIC_CALL(cswap(FPTR_2_VOID_PTR(target), + (void *)&out_value, + NULL, + FPTR_2_VOID_PTR(value), + sizeof(out_value), + OMPI_FINT_2_INT(*pe))); +} + diff --git a/oshmem/shmem/fortran/shmem_put_f.c b/oshmem/shmem/fortran/shmem_put_f.c deleted file mode 100644 index 7681cfaf5e5..00000000000 --- a/oshmem/shmem/fortran/shmem_put_f.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2013 Mellanox Technologies, Inc. - * All rights reserved. - * Copyright (c) 2013 Cisco Systems, Inc. All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -#include "oshmem_config.h" -#include "oshmem/shmem/fortran/bindings.h" -#include "oshmem/include/shmem.h" -#include "oshmem/shmem/shmem_api_logger.h" -#include "oshmem/runtime/runtime.h" -#include "stdio.h" - -#if OSHMEM_PROFILING -#include "oshmem/shmem/fortran/profile/pbindings.h" -SHMEM_GENERATE_WEAK_BINDINGS(SHMEM_PUT, shmem_put) -#include "oshmem/shmem/fortran/profile/defines.h" -#endif - -SHMEM_GENERATE_FORTRAN_BINDINGS_SUB (void, - SHMEM_PUT, - shmem_put_, - shmem_put__, - shmem_put_f, - (FORTRAN_POINTER_T target, FORTRAN_POINTER_T source, MPI_Fint *length, MPI_Fint *pe), - (target,source,length,pe) ) - -void shmem_put_f(FORTRAN_POINTER_T target, FORTRAN_POINTER_T source, MPI_Fint *length, MPI_Fint *pe) -{ - shmem_put(FPTR_2_VOID_PTR(target), - FPTR_2_VOID_PTR(source), - OMPI_FINT_2_INT(*length), - OMPI_FINT_2_INT(*pe)); -} - diff --git a/oshmem/shmem/fortran/shmem_real4_fetch_f.c b/oshmem/shmem/fortran/shmem_real4_fetch_f.c new file mode 100644 index 00000000000..cf74e03a8fb --- /dev/null +++ b/oshmem/shmem/fortran/shmem_real4_fetch_f.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2016 Mellanox Technologies, Inc. + * All rights reserved. + * $COPYRIGHT$ + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "oshmem_config.h" +#include "oshmem/shmem/fortran/bindings.h" +#include "oshmem/include/shmem.h" +#include "oshmem/shmem/shmem_api_logger.h" +#include "oshmem/runtime/runtime.h" +#include "oshmem/mca/atomic/atomic.h" +#include "ompi/datatype/ompi_datatype.h" +#include "oshmem/op/op.h" +#include "stdio.h" + +#if OSHMEM_PROFILING +#include "oshmem/shmem/fortran/profile/pbindings.h" +SHMEM_GENERATE_WEAK_BINDINGS(SHMEM_REAL4_FETCH, shmem_real4_fetch) +#include "oshmem/shmem/fortran/profile/defines.h" +#endif + +SHMEM_GENERATE_FORTRAN_BINDINGS_FUNCTION (ompi_fortran_real4_t, + SHMEM_REAL4_FETCH, + shmem_real4_fetch_, + shmem_real4_fetch__, + shmem_real4_fetch_f, + (FORTRAN_POINTER_T target, MPI_Fint *pe), + (target,pe) ) + +ompi_fortran_real4_t shmem_real4_fetch_f(FORTRAN_POINTER_T target, MPI_Fint *pe) +{ + ompi_fortran_real4_t out_value = 0; + oshmem_op_t* op = oshmem_op_sum_freal4; + int value = 0; + + MCA_ATOMIC_CALL(fadd(FPTR_2_VOID_PTR(target), + (void *)&out_value, + (const void *)&value, + sizeof(out_value), + OMPI_FINT_2_INT(*pe), + op)); + + return out_value; +} + diff --git a/oshmem/shmem/fortran/shmem_real4_set_f.c b/oshmem/shmem/fortran/shmem_real4_set_f.c new file mode 100644 index 00000000000..3a486c6ce56 --- /dev/null +++ b/oshmem/shmem/fortran/shmem_real4_set_f.c @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2016 Mellanox Technologies, Inc. + * All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "oshmem_config.h" +#include "oshmem/shmem/fortran/bindings.h" +#include "oshmem/include/shmem.h" +#include "oshmem/shmem/shmem_api_logger.h" +#include "oshmem/runtime/runtime.h" +#include "oshmem/mca/atomic/atomic.h" +#include "ompi/datatype/ompi_datatype.h" +#include "stdio.h" + +#if OSHMEM_PROFILING +#include "oshmem/shmem/fortran/profile/pbindings.h" +SHMEM_GENERATE_WEAK_BINDINGS(SHMEM_REAL4_SET, shmem_real4_set) +#include "oshmem/shmem/fortran/profile/defines.h" +#endif + +SHMEM_GENERATE_FORTRAN_BINDINGS_SUB (void, + SHMEM_REAL4_SET, + shmem_real4_set_, + shmem_real4_set__, + shmem_real4_set_f, + (FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe), + (target,value,pe) ) + +void shmem_real4_set_f(FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe) +{ + ompi_fortran_real4_t out_value = 0; + + MCA_ATOMIC_CALL(cswap(FPTR_2_VOID_PTR(target), + (void *)&out_value, + NULL, + FPTR_2_VOID_PTR(value), + sizeof(out_value), + OMPI_FINT_2_INT(*pe))); + +} + diff --git a/oshmem/shmem/fortran/shmem_real8_fetch_f.c b/oshmem/shmem/fortran/shmem_real8_fetch_f.c new file mode 100644 index 00000000000..70f0440cba6 --- /dev/null +++ b/oshmem/shmem/fortran/shmem_real8_fetch_f.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2016 Mellanox Technologies, Inc. + * All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "oshmem_config.h" +#include "oshmem/shmem/fortran/bindings.h" +#include "oshmem/include/shmem.h" +#include "oshmem/shmem/shmem_api_logger.h" +#include "oshmem/runtime/runtime.h" +#include "oshmem/mca/atomic/atomic.h" +#include "ompi/datatype/ompi_datatype.h" +#include "oshmem/op/op.h" +#include "stdio.h" + +#if OSHMEM_PROFILING +#include "oshmem/shmem/fortran/profile/pbindings.h" +SHMEM_GENERATE_WEAK_BINDINGS(SHMEM_REAL8_FETCH, shmem_real8_fetch) +#include "oshmem/shmem/fortran/profile/defines.h" +#endif + +SHMEM_GENERATE_FORTRAN_BINDINGS_FUNCTION (ompi_fortran_real8_t, + SHMEM_REAL8_FETCH, + shmem_real8_fetch_, + shmem_real8_fetch__, + shmem_real8_fetch_f, + (FORTRAN_POINTER_T target, MPI_Fint *pe), + (target,pe) ) + +ompi_fortran_real8_t shmem_real8_fetch_f(FORTRAN_POINTER_T target, MPI_Fint *pe) +{ + ompi_fortran_real8_t out_value = 0; + oshmem_op_t* op = oshmem_op_sum_freal8; + int value = 0; + + MCA_ATOMIC_CALL(fadd(FPTR_2_VOID_PTR(target), + (void *)&out_value, + (const void *)&value, + sizeof(out_value), + OMPI_FINT_2_INT(*pe), + op)); + + return out_value; +} + diff --git a/oshmem/shmem/fortran/shmem_real8_set_f.c b/oshmem/shmem/fortran/shmem_real8_set_f.c new file mode 100644 index 00000000000..6ab4d68e5ae --- /dev/null +++ b/oshmem/shmem/fortran/shmem_real8_set_f.c @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2018 Mellanox Technologies, Inc. + * All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "oshmem_config.h" +#include "oshmem/shmem/fortran/bindings.h" +#include "oshmem/include/shmem.h" +#include "oshmem/shmem/shmem_api_logger.h" +#include "oshmem/runtime/runtime.h" +#include "oshmem/mca/atomic/atomic.h" +#include "ompi/datatype/ompi_datatype.h" +#include "stdio.h" + +#if OSHMEM_PROFILING +#include "oshmem/shmem/fortran/profile/pbindings.h" +SHMEM_GENERATE_WEAK_BINDINGS(SHMEM_REAL8_SET, shmem_real8_set) +#include "oshmem/shmem/fortran/profile/defines.h" +#endif + +SHMEM_GENERATE_FORTRAN_BINDINGS_SUB (void, + SHMEM_REAL8_SET, + shmem_real8_set_, + shmem_real8_set__, + shmem_real8_set_f, + (FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe), + (target,value,pe) ) + +void shmem_real8_set_f(FORTRAN_POINTER_T target, FORTRAN_POINTER_T value, MPI_Fint *pe) +{ + ompi_fortran_real8_t out_value = 0; + + MCA_ATOMIC_CALL(cswap(FPTR_2_VOID_PTR(target), + (void *)&out_value, + NULL, + FPTR_2_VOID_PTR(value), + sizeof(out_value), + OMPI_FINT_2_INT(*pe))); +} + diff --git a/oshmem/shmem/man/man3/Makefile.extra b/oshmem/shmem/man/man3/Makefile.extra index 0e0126dec91..c47ba2c2fb7 100644 --- a/oshmem/shmem/man/man3/Makefile.extra +++ b/oshmem/shmem/man/man3/Makefile.extra @@ -98,12 +98,26 @@ shmem_api_man_pages = \ shmem/man/man3/shmem_longlong_swap.3 \ shmem/man/man3/shmem_float_swap.3 \ shmem/man/man3/shmem_double_swap.3 \ +\ + shmem/man/man3/shmem_double_set.3 \ + shmem/man/man3/shmem_float_set.3 \ + shmem/man/man3/shmem_int_set.3 \ + shmem/man/man3/shmem_longlong_set.3 \ + shmem/man/man3/shmem_long_set.3 \ +\ shmem/man/man3/shmem_int_cswap.3 \ shmem/man/man3/shmem_long_cswap.3 \ shmem/man/man3/shmem_longlong_cswap.3 \ shmem/man/man3/shmem_int_fadd.3 \ shmem/man/man3/shmem_long_fadd.3 \ shmem/man/man3/shmem_longlong_fadd.3 \ +\ + shmem/man/man3/shmem_double_fetch.3 \ + shmem/man/man3/shmem_float_fetch.3 \ + shmem/man/man3/shmem_int_fetch.3 \ + shmem/man/man3/shmem_long_fetch.3 \ + shmem/man/man3/shmem_longlong_fetch.3 \ +\ shmem/man/man3/shmem_int_finc.3 \ shmem/man/man3/shmem_long_finc.3 \ shmem/man/man3/shmem_longlong_finc.3 \ diff --git a/oshmem/shmem/man/man3/shmem_double_fetch.3in b/oshmem/shmem/man/man3/shmem_double_fetch.3in new file mode 100644 index 00000000000..7213c75e538 --- /dev/null +++ b/oshmem/shmem/man/man3/shmem_double_fetch.3in @@ -0,0 +1 @@ +.so man3/shmem_int_fetch.3 diff --git a/oshmem/shmem/man/man3/shmem_double_set.3in b/oshmem/shmem/man/man3/shmem_double_set.3in new file mode 100644 index 00000000000..a02bb7ea5ea --- /dev/null +++ b/oshmem/shmem/man/man3/shmem_double_set.3in @@ -0,0 +1 @@ +.so man3/shmem_int_set.3 diff --git a/oshmem/shmem/man/man3/shmem_float_fetch.3in b/oshmem/shmem/man/man3/shmem_float_fetch.3in new file mode 100644 index 00000000000..7213c75e538 --- /dev/null +++ b/oshmem/shmem/man/man3/shmem_float_fetch.3in @@ -0,0 +1 @@ +.so man3/shmem_int_fetch.3 diff --git a/oshmem/shmem/man/man3/shmem_float_set.3in b/oshmem/shmem/man/man3/shmem_float_set.3in new file mode 100644 index 00000000000..a02bb7ea5ea --- /dev/null +++ b/oshmem/shmem/man/man3/shmem_float_set.3in @@ -0,0 +1 @@ +.so man3/shmem_int_set.3 diff --git a/oshmem/shmem/man/man3/shmem_int_fetch.3in b/oshmem/shmem/man/man3/shmem_int_fetch.3in new file mode 100644 index 00000000000..e11e131eb69 --- /dev/null +++ b/oshmem/shmem/man/man3/shmem_int_fetch.3in @@ -0,0 +1,83 @@ +.\" -*- nroff -*- +.\" Copyright (c) 2016 Mellanox Technologies, Inc. +.\" $COPYRIGHT$ +.de Vb +.ft CW +.nf +.. +.de Ve +.ft R + +.fi +.. +.TH "SHMEM\\_FETCH" "3" "Unreleased developer copy" "gitclone" "Open MPI" +.SH NAME + +\fIshmem_int4_fetch\fP(3), +\fIshmem_int8_fetch\fP(3), +\fIshmem_int_fetch\fP(3), +\fIshmem_long_fetch\fP(3), +\fIshmem_longlong_fetch\fP(3) +\fIshmem_double_fetch\fP(3) +\fIshmem_float_fetch\fP(3) +\- Atomically fetches the value of a remote data object +.SH SYNOPSIS + +C or C++: +.Vb +#include + +int shmem_int_fetch(int *target, int pe); + +long shmem_long_fetch(long *target, int pe); + +long long shmem_longlong_fetch(long long *target, int pe); + +double shmem_double_fetch(long long *target, int pe); + +float shmem_float_fetch(float *target, int pe); +.Ve +Fortran: +.Vb +INCLUDE "mpp/shmem.fh" + +INTEGER pe + +INTEGER(KIND=4) SHMEM_INT4_FETCH, ires, target +ires = SHMEM_INT4_FETCH(target, pe) + +INTEGER(KIND=8) SHMEM_INT8_FETCH, ires, target +ires = SHMEM_INT8_FETCH(target, pe) + + +REAL(KIND=4) SHMEM_INT4_FETCH, ires, target +ires = SHMEM_REAL4_FETCH(target, pe) + +REAL(KIND=8) SHMEM_INT8_FETCH, ires, target +ires = SHMEM_REAL8_FETCH(target, pe) + +.Ve +.SH DESCRIPTION + +The shmem_fetch functions perform an atomic fetch operation. They return the contents of the +\fBtarget\fP as an atomic operation. + +.PP +The arguments are as follows: +.TP +target +The remotely accessible data object to be fetched from the remote PE. +.TP +pe +An integer that indicates the PE number from which \fItarget\fP is to be fetched. If you are +using Fortran, it must be a default integer value. +.PP + +.SH RETURN VALUES +The contents at the \fItarget\fP address on the remote PE. +The data type of the return value is the same as the the +type of the remote data object. + +.SH SEE ALSO + +\fIintro_shmem\fP(3) diff --git a/oshmem/shmem/man/man3/shmem_int_set.3in b/oshmem/shmem/man/man3/shmem_int_set.3in new file mode 100644 index 00000000000..7a68b2eee35 --- /dev/null +++ b/oshmem/shmem/man/man3/shmem_int_set.3in @@ -0,0 +1,77 @@ +.\" -*- nroff -*- +.\" Copyright (c) 2016 Mellanox Technologies, Inc. +.\" $COPYRIGHT$ +.de Vb +.ft CW +.nf +.. +.de Ve +.ft R + +.fi +.. +.TH "SHMEM\\_SET" "3" "Unreleased developer copy" "gitclone" "Open MPI" +.SH NAME + +\fIshmem_double_set\fP(3), +\fIshmem_float_set\fP(3), +\fIshmem_int_set\fP(3), +\fIshmem_long_set\fP(3), +\fIshmem_longlong_set\fP(3) +\fIshmem_int4_set\fP(3), +\fIshmem_int8_set\fP(3), +\fIshmem_real4_set\fP(3), +\fIshmem_real8_set\fP(3), +\- Atomically sets the value of a remote data object + +.SH SYNOPSIS + +C or C++: +.Vb +#include + +void shmem_double_set(double *target, double value, int pe); + +void shmem_float_set(float *target, float value, int pe); + +void shmem_int_set(int *target, int value, int pe); + +void shmem_long_set(long *target, long value, int pe); + +void shmem_longlong_set(long long *target, long long value, int pe); +.Ve +Fortran: +.Vb +INCLUDE "mpp/shmem.fh" + +INTEGER pe + +CALL SHMEM_INT4_SET(target, value, pe) +CALL SHMEM_INT8_SET(target, value, pe) +CALL SHMEM_REAL4_SET(target, value, pe) +CALL SHMEM_REAL8_SET(target, value, pe) + +.Ve +.SH DESCRIPTION + +The set routines write the \fBvalue\fP into the address \fBtarget\fP on \fBpe\fP as an atomic operation. +.PP +The arguments are as follows: +.TP +target +The remotely accessible data object to be set on the remote PE. +.TP +value +The value to be atomically written to the remote PE. +.TP +pe +An integer that indicates the PE number upon which target is to be updated. If you +are using Fortran, it must be a default integer value. +.PP +.SH RETURN VALUES +NONE + +.SH SEE ALSO + +\fIintro_shmem\fP(3) + diff --git a/oshmem/shmem/man/man3/shmem_long_fetch.3in b/oshmem/shmem/man/man3/shmem_long_fetch.3in new file mode 100644 index 00000000000..7213c75e538 --- /dev/null +++ b/oshmem/shmem/man/man3/shmem_long_fetch.3in @@ -0,0 +1 @@ +.so man3/shmem_int_fetch.3 diff --git a/oshmem/shmem/man/man3/shmem_long_set.3in b/oshmem/shmem/man/man3/shmem_long_set.3in new file mode 100644 index 00000000000..a02bb7ea5ea --- /dev/null +++ b/oshmem/shmem/man/man3/shmem_long_set.3in @@ -0,0 +1 @@ +.so man3/shmem_int_set.3 diff --git a/oshmem/shmem/man/man3/shmem_longlong_fetch.3in b/oshmem/shmem/man/man3/shmem_longlong_fetch.3in new file mode 100644 index 00000000000..7213c75e538 --- /dev/null +++ b/oshmem/shmem/man/man3/shmem_longlong_fetch.3in @@ -0,0 +1 @@ +.so man3/shmem_int_fetch.3 diff --git a/oshmem/shmem/man/man3/shmem_longlong_set.3in b/oshmem/shmem/man/man3/shmem_longlong_set.3in new file mode 100644 index 00000000000..a02bb7ea5ea --- /dev/null +++ b/oshmem/shmem/man/man3/shmem_longlong_set.3in @@ -0,0 +1 @@ +.so man3/shmem_int_set.3