diff --git a/src/mca/ptl/base/ptl_base_sendreq.h b/src/mca/ptl/base/ptl_base_sendreq.h index bcbd76a6a4..19208b9703 100644 --- a/src/mca/ptl/base/ptl_base_sendreq.h +++ b/src/mca/ptl/base/ptl_base_sendreq.h @@ -58,7 +58,7 @@ static inline void mca_ptl_base_send_request_offset( mca_ptl_base_send_request_t* request, size_t offset) { - OMPI_THREAD_ADD32((size_t*)(&request->req_offset), offset); + OMPI_THREAD_ADD_SIZE_T((&request->req_offset), offset); } diff --git a/src/threads/mutex.h b/src/threads/mutex.h index 818b5c6021..4e99c419df 100644 --- a/src/threads/mutex.h +++ b/src/threads/mutex.h @@ -258,11 +258,25 @@ static inline bool ompi_set_using_threads(bool have) #if OMPI_HAVE_THREAD_SUPPORT #define OMPI_THREAD_ADD64(x,y) \ ((OMPI_HAVE_THREAD_SUPPORT && ompi_using_threads()) ? \ - ompi_atomic_add_32(x,y) : (*x += y)) + ompi_atomic_add_64(x,y) : (*x += y)) #else #define OMPI_THREAD_ADD64(x,y) (*x += y) #endif +#if OMPI_HAVE_THREAD_SUPPORT +#if OMPI_SIZEOF_SIZE_T == 4 +#define OMPI_THREAD_ADD_SIZE_T(x,y) \ + ((OMPI_HAVE_THREAD_SUPPORT && ompi_using_threads()) ? \ + ompi_atomic_add_32(x,y) : (*x += y)) +#elif OMPI_SIZEOF_SIZE_T == 8 +#define OMPI_THREAD_ADD_SIZE_T(x,y) \ + ((OMPI_HAVE_THREAD_SUPPORT && ompi_using_threads()) ? \ + ompi_atomic_add_64(x,y) : (*x += y)) +#endif +#else +#define OMPI_THREAD_ADD_SIZE_T(x,y) (*x += y) +#endif + /** * Always locks a mutex (never compile- or run-time removed)