Skip to content

Commit 566412e

Browse files
committed
op_avx: use MCA enum flags instead of integer values
MCA enums make it easier for users to see/set MCA flag values. Also add "op_avx_capabilities" read-only MCA var that shows what is supported on your platform, regardless of what value the user has set in "opal_avx_support". For example, ompi_output shows all the valid values: ``` $ ompi_info --all --parsable | grep _avx_ mca:op:avx:param:op_avx_capabilities:value:SSE,SSE2,SSE3,SSE4.1,AVX mca:op:avx:param:op_avx_capabilities:source:default mca:op:avx:param:op_avx_capabilities:status:read-only mca:op:avx:param:op_avx_capabilities:level:4 mca:op:avx:param:op_avx_capabilities:help:Level of SSE/MMX/AVX support available in the current environment mca:op:avx:param:op_avx_capabilities:enumerator:value:1:SSE mca:op:avx:param:op_avx_capabilities:enumerator:value:2:SSE2 mca:op:avx:param:op_avx_capabilities:enumerator:value:4:SSE3 mca:op:avx:param:op_avx_capabilities:enumerator:value:8:SSE4.1 mca:op:avx:param:op_avx_capabilities:enumerator:value:16:AVX mca:op:avx:param:op_avx_capabilities:enumerator:value:32:AVX2 mca:op:avx:param:op_avx_capabilities:enumerator:value:256:AVX512F mca:op:avx:param:op_avx_capabilities:enumerator:value:512:AVX512BW mca:op:avx:param:op_avx_capabilities:deprecated:no mca:op:avx:param:op_avx_capabilities:type:int mca:op:avx:param:op_avx_capabilities:disabled:false mca:op:avx:param:op_avx_support:value:SSE,SSE2,SSE3,SSE4.1,AVX mca:op:avx:param:op_avx_support:source:default mca:op:avx:param:op_avx_support:status:read-only mca:op:avx:param:op_avx_support:level:4 mca:op:avx:param:op_avx_support:help:Level of SSE/MMX/AVX support to be used, capped by the local architecture capabilities mca:op:avx:param:op_avx_support:enumerator:value:1:SSE mca:op:avx:param:op_avx_support:enumerator:value:2:SSE2 mca:op:avx:param:op_avx_support:enumerator:value:4:SSE3 mca:op:avx:param:op_avx_support:enumerator:value:8:SSE4.1 mca:op:avx:param:op_avx_support:enumerator:value:16:AVX mca:op:avx:param:op_avx_support:enumerator:value:32:AVX2 mca:op:avx:param:op_avx_support:enumerator:value:256:AVX512F mca:op:avx:param:op_avx_support:enumerator:value:512:AVX512BW mca:op:avx:param:op_avx_support:deprecated:no mca:op:avx:param:op_avx_support:type:int mca:op:avx:param:op_avx_support:disabled:false ``` Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
1 parent 3598c82 commit 566412e

File tree

2 files changed

+44
-6
lines changed

2 files changed

+44
-6
lines changed

ompi/mca/op/avx/op_avx.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ typedef struct {
4646
avxs; replace them with whatever is relevant for your
4747
component. */
4848

49-
uint32_t flags; /* AVX capabilities supported by the processor */
49+
uint32_t supported; /* AVX capabilities supported by the environment */
50+
uint32_t flags; /* AVX capabilities requested by this process */
5051
} ompi_op_avx_component_t;
5152

5253
/**

ompi/mca/op/avx/op_avx_component.c

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* reserved.
55
* Copyright (c) 2020 Research Organization for Information Science
66
* and Technology (RIST). All rights reserved.
7+
* Copyright (c) 2021 Cisco Systems, Inc. All rights reserved.
78
* $COPYRIGHT$
89
*
910
* Additional copyrights may follow
@@ -20,6 +21,7 @@
2021
#include "ompi_config.h"
2122

2223
#include "opal/util/printf.h"
24+
#include "ompi/include/mpi_portable_platform.h"
2325

2426
#include "ompi/constants.h"
2527
#include "ompi/op/op.h"
@@ -35,6 +37,18 @@ static struct ompi_op_base_module_1_0_0_t *
3537
avx_component_op_query(struct ompi_op_t *op, int *priority);
3638
static int avx_component_register(void);
3739

40+
static mca_base_var_enum_value_flag_t avx_support_flags[] = {
41+
{ .flag = 0x001, .string = "SSE" },
42+
{ .flag = 0x002, .string = "SSE2" },
43+
{ .flag = 0x004, .string = "SSE3" },
44+
{ .flag = 0x008, .string = "SSE4.1" },
45+
{ .flag = 0x010, .string = "AVX" },
46+
{ .flag = 0x020, .string = "AVX2" },
47+
{ .flag = 0x100, .string = "AVX512F" },
48+
{ .flag = 0x200, .string = "AVX512BW" },
49+
{ .flag = 0, .string = NULL },
50+
};
51+
3852
/**
3953
* A slightly modified code from
4054
* https://software.intel.com/en-us/articles/how-to-detect-new-instruction-support-in-the-4th-generation-intel-core-processor-family
@@ -177,15 +191,38 @@ static int avx_component_close(void)
177191
static int
178192
avx_component_register(void)
179193
{
180-
int32_t requested_flags = mca_op_avx_component.flags = has_intel_AVX_features();
194+
mca_op_avx_component.supported =
195+
mca_op_avx_component.flags = has_intel_AVX_features();
196+
197+
// MCA var enum flag for conveniently seeing SSE/MMX/AVX support
198+
// values
199+
mca_base_var_enum_flag_t *new_enum_flag;
200+
(void) mca_base_var_enum_create_flag("op_avx_support_flags",
201+
avx_support_flags, &new_enum_flag);
202+
(void) mca_base_var_enum_register("ompi", "op", "avx", "support_flags",
203+
&new_enum_flag);
204+
205+
(void) mca_base_component_var_register(&mca_op_avx_component.super.opc_version,
206+
"capabilities",
207+
"Level of SSE/MMX/AVX support available in the current environment",
208+
MCA_BASE_VAR_TYPE_INT,
209+
&(new_enum_flag->super), 0, 0,
210+
OPAL_INFO_LVL_4,
211+
MCA_BASE_VAR_SCOPE_CONSTANT,
212+
&mca_op_avx_component.supported);
213+
181214
(void) mca_base_component_var_register(&mca_op_avx_component.super.opc_version,
182215
"support",
183-
"Level of SSE/MMX/AVX support to be used (combination of processor capabilities as follow SSE 0x01, SSE2 0x02, SSE3 0x04, SSE4.1 0x08, AVX 0x010, AVX2 0x020, AVX512F 0x100, AVX512BW 0x200) capped by the local architecture capabilities",
184-
MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
185-
OPAL_INFO_LVL_6,
216+
"Level of SSE/MMX/AVX support to be used, capped by the local architecture capabilities",
217+
MCA_BASE_VAR_TYPE_INT,
218+
&(new_enum_flag->super), 0, 0,
219+
OPAL_INFO_LVL_4,
186220
MCA_BASE_VAR_SCOPE_LOCAL,
187221
&mca_op_avx_component.flags);
188-
mca_op_avx_component.flags &= requested_flags;
222+
OBJ_RELEASE(new_enum_flag);
223+
224+
mca_op_avx_component.flags &= mca_op_avx_component.supported;
225+
189226
return OMPI_SUCCESS;
190227
}
191228

0 commit comments

Comments
 (0)