Skip to content

Commit 23fe19a

Browse files
committed
btl: add support for more atomics
This commit add support for more atomic operations and type. The operations added are logical and, logical or, logical xor, swap, min, and max. New types are 32-bit int by using the MCA_BTL_ATOMIC_FLAG_32BIT flag, 64-bit float by using the MCA_BTL_ATOMIC_FLAG_FLOAT flag, and 32-bit float by using both flags. Floating point numbers are supported by packing the number in as an int64_t or int32_t. We will update the btl interface in the future to make this less confusing. Signed-off-by: Nathan Hjelm <[email protected]>
1 parent ce783a9 commit 23fe19a

File tree

3 files changed

+63
-5
lines changed

3 files changed

+63
-5
lines changed

opal/mca/btl/base/btl_base_frame.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ mca_base_var_enum_value_flag_t mca_btl_base_atomic_enum_flags[] = {
6161
{MCA_BTL_ATOMIC_SUPPORTS_AND, "and", 0},
6262
{MCA_BTL_ATOMIC_SUPPORTS_OR, "or", 0},
6363
{MCA_BTL_ATOMIC_SUPPORTS_XOR, "xor", 0},
64+
{MCA_BTL_ATOMIC_SUPPORTS_LAND, "land", 0},
65+
{MCA_BTL_ATOMIC_SUPPORTS_LOR, "lor", 0},
66+
{MCA_BTL_ATOMIC_SUPPORTS_LXOR, "lxor", 0},
67+
{MCA_BTL_ATOMIC_SUPPORTS_SWAP, "swap", 0},
68+
{MCA_BTL_ATOMIC_SUPPORTS_MIN, "min", 0},
69+
{MCA_BTL_ATOMIC_SUPPORTS_MAX, "max", 0},
6470
{MCA_BTL_ATOMIC_SUPPORTS_CSWAP, "compare-and-swap", 0},
6571
{MCA_BTL_ATOMIC_SUPPORTS_GLOB, "global"},
6672
{0, NULL, 0}

opal/mca/btl/btl.h

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* University of Stuttgart. All rights reserved.
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
13-
* Copyright (c) 2006-2015 Los Alamos National Security, LLC. All rights
13+
* Copyright (c) 2006-2016 Los Alamos National Security, LLC. All rights
1414
* reserved.
1515
* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
1616
* Copyright (c) 2012-2013 NVIDIA Corporation. All rights reserved.
@@ -293,10 +293,44 @@ enum {
293293
MCA_BTL_ATOMIC_SUPPORTS_OR = 0x00000400,
294294
/** The btl supports atomic bitwise exclusive or */
295295
MCA_BTL_ATOMIC_SUPPORTS_XOR = 0x00000800,
296+
297+
/** The btl supports logical and */
298+
MCA_BTL_ATOMIC_SUPPORTS_LAND = 0x00001000,
299+
/** The btl supports logical or */
300+
MCA_BTL_ATOMIC_SUPPORTS_LOR = 0x00002000,
301+
/** The btl supports logical exclusive or */
302+
MCA_BTL_ATOMIC_SUPPORTS_LXOR = 0x00004000,
303+
304+
/** The btl supports atomic swap */
305+
MCA_BTL_ATOMIC_SUPPORTS_SWAP = 0x00010000,
306+
307+
/** The btl supports atomic min */
308+
MCA_BTL_ATOMIC_SUPPORTS_MIN = 0x00100000,
309+
/** The btl supports atomic min */
310+
MCA_BTL_ATOMIC_SUPPORTS_MAX = 0x00200000,
311+
296312
/** The btl supports atomic compare-and-swap */
297313
MCA_BTL_ATOMIC_SUPPORTS_CSWAP = 0x10000000,
314+
298315
/** The btl guarantees global atomicity (can mix btl atomics with cpu atomics) */
299316
MCA_BTL_ATOMIC_SUPPORTS_GLOB = 0x20000000,
317+
318+
319+
/** The btl supports 32-bit integer operations. Keep in mind the btl may
320+
* support only a subset of the available atomics. */
321+
MCA_BTL_ATOMIC_SUPPORTS_32BIT = 0x40000000,
322+
323+
/** The btl supports floating-point operations. Keep in mind the btl may
324+
* support only a subset of the available atomics and may not support
325+
* both 64 or 32-bit floating point. */
326+
MCA_BTL_ATOMIC_SUPPORTS_FLOAT = 0x80000000,
327+
};
328+
329+
enum {
330+
/** Use 32-bit atomics */
331+
MCA_BTL_ATOMIC_FLAG_32BIT = 0x00000001,
332+
/** Use floating-point atomics */
333+
MCA_BTL_ATOMIC_FLAG_FLOAT = 0x00000002,
300334
};
301335

302336
enum mca_btl_base_atomic_op_t {
@@ -308,6 +342,20 @@ enum mca_btl_base_atomic_op_t {
308342
MCA_BTL_ATOMIC_OR = 0x0012,
309343
/** Atomic xor: (*remote_address) = (*remote_address) ^ operand */
310344
MCA_BTL_ATOMIC_XOR = 0x0014,
345+
/** Atomic logical and: (*remote_address) = (*remote_address) && operand */
346+
MCA_BTL_ATOMIC_LAND = 0x0015,
347+
/** Atomic logical or: (*remote_address) = (*remote_address) || operand */
348+
MCA_BTL_ATOMIC_LOR = 0x0016,
349+
/** Atomic logical xor: (*remote_address) = (*remote_address) != operand */
350+
MCA_BTL_ATOMIC_LXOR = 0x0017,
351+
/** Atomic swap: (*remote_address) = operand */
352+
MCA_BTL_ATOMIC_SWAP = 0x001a,
353+
/** Atomic min */
354+
MCA_BTL_ATOMIC_MIN = 0x0020,
355+
/** Atomic max */
356+
MCA_BTL_ATOMIC_MAX = 0x0021,
357+
358+
MCA_BTL_ATOMIC_LAST,
311359
};
312360
typedef enum mca_btl_base_atomic_op_t mca_btl_base_atomic_op_t;
313361

@@ -977,7 +1025,7 @@ typedef int (*mca_btl_base_module_get_fn_t) (struct mca_btl_base_module_t *btl,
9771025
* (remote_address, remote_address + 8)
9781026
* @param op (IN) Operation to perform
9791027
* @param operand (IN) Operand for the operation
980-
* @param flags (IN) Flags for this put operation
1028+
* @param flags (IN) Flags for this atomic operation
9811029
* @param order (IN) Ordering
9821030
* @param cbfunc (IN) Function to call on completion (if queued)
9831031
* @param cbcontext (IN) Context for the callback
@@ -1021,7 +1069,7 @@ typedef int (*mca_btl_base_module_atomic_op64_fn_t) (struct mca_btl_base_module_
10211069
* (remote_address, remote_address + 8)
10221070
* @param op (IN) Operation to perform
10231071
* @param operand (IN) Operand for the operation
1024-
* @param flags (IN) Flags for this put operation
1072+
* @param flags (IN) Flags for this atomic operation
10251073
* @param order (IN) Ordering
10261074
* @param cbfunc (IN) Function to call on completion (if queued)
10271075
* @param cbcontext (IN) Context for the callback
@@ -1067,7 +1115,7 @@ typedef int (*mca_btl_base_module_atomic_fop64_fn_t) (struct mca_btl_base_module
10671115
* (remote_address, remote_address + 8)
10681116
* @param compare (IN) Operand for the operation
10691117
* @param value (IN) Value to store on success
1070-
* @param flags (IN) Flags for this put operation
1118+
* @param flags (IN) Flags for this atomic operation
10711119
* @param order (IN) Ordering
10721120
* @param cbfunc (IN) Function to call on completion (if queued)
10731121
* @param cbcontext (IN) Context for the callback

opal/mca/btl/openib/btl_openib_atomic.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ int mca_btl_openib_atomic_fop (struct mca_btl_base_module_t *btl, struct mca_btl
112112
void *cbcontext, void *cbdata)
113113
{
114114

115-
if (OPAL_UNLIKELY(MCA_BTL_ATOMIC_ADD != op)) {
115+
if (OPAL_UNLIKELY(MCA_BTL_ATOMIC_ADD != op || (MCA_BTL_ATOMIC_FLAG_32BIT & flags))) {
116116
return OPAL_ERR_NOT_SUPPORTED;
117117
}
118118

@@ -128,6 +128,10 @@ int mca_btl_openib_atomic_cswap (struct mca_btl_base_module_t *btl, struct mca_b
128128
uint64_t value, int flags, int order, mca_btl_base_rdma_completion_fn_t cbfunc,
129129
void *cbcontext, void *cbdata)
130130
{
131+
if (OPAL_UNLIKELY(MCA_BTL_ATOMIC_FLAG_32BIT & flags)) {
132+
return OPAL_ERR_NOT_SUPPORTED;
133+
}
134+
131135
return mca_btl_openib_atomic_internal (btl, endpoint, local_address, remote_address, local_handle,
132136
remote_handle, IBV_WR_ATOMIC_CMP_AND_SWP, compare, value,
133137
flags, order, cbfunc, cbcontext, cbdata);

0 commit comments

Comments
 (0)