Skip to content

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

Merged
merged 1 commit into from
Sep 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions oshmem/include/pshmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Copy link
Member

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.

/* 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);
Expand All @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The 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);
Expand Down
18 changes: 18 additions & 0 deletions oshmem/include/pshmemx.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,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);
Expand All @@ -89,6 +93,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);
Expand Down Expand Up @@ -160,15 +168,25 @@ OSHMEM_DECLSPEC void pshmemx_int64_prod_to_all(int64_t *target, const int64_t *s

#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

Expand Down
14 changes: 14 additions & 0 deletions oshmem/include/shmem.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member

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.

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);
Expand All @@ -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);

Copy link
Member

Choose a reason for hiding this comment

The 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);
Expand Down
17 changes: 17 additions & 0 deletions oshmem/include/shmemx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Copy link
Member

Choose a reason for hiding this comment

The 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);
Expand All @@ -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);

Copy link
Member

Choose a reason for hiding this comment

The 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);
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions oshmem/shmem/c/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 2 additions & 0 deletions oshmem/shmem/c/profile/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
17 changes: 17 additions & 0 deletions oshmem/shmem/c/profile/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The 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
Expand All @@ -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
Copy link
Member

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.


/* Atomic Fetch&Inc */
#define shmem_int_finc pshmem_int_finc
#define shmem_long_finc pshmem_long_finc
Expand Down
71 changes: 71 additions & 0 deletions oshmem/shmem/c/shmem_fetch.c
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
Copy link
Member

Choose a reason for hiding this comment

The 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, \
Copy link
Member

Choose a reason for hiding this comment

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

is target updated with 0 in this call?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The 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)

66 changes: 66 additions & 0 deletions oshmem/shmem/c/shmem_set.c
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)

8 changes: 8 additions & 0 deletions oshmem/shmem/fortran/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,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 \
Expand Down
8 changes: 8 additions & 0 deletions oshmem/shmem/fortran/profile/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,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 \
Expand Down
Loading