Skip to content

Commit 5ed2fc2

Browse files
committed
mca/base: add support for additional variable types
This commit adds long, int32_t, uint32_t, int64_t, and uint64_t as possible MCA variable types. Signed-off-by: Nathan Hjelm <[email protected]>
1 parent 6f58954 commit 5ed2fc2

File tree

4 files changed

+116
-50
lines changed

4 files changed

+116
-50
lines changed

ompi/mpi/tool/cvar_read.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
3+
* Copyright (c) 2012-2018 Los Alamos National Security, LLC. All rights
44
* reserved.
55
* Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
66
* Copyright (c) 2016 Intel, Inc. All rights reserved.
@@ -51,6 +51,15 @@ int MPI_T_cvar_read (MPI_T_cvar_handle handle, void *buf)
5151
case MCA_BASE_VAR_TYPE_UNSIGNED_INT:
5252
((int *) buf)[0] = value->intval;
5353
break;
54+
case MCA_BASE_VAR_TYPE_INT32_T:
55+
case MCA_BASE_VAR_TYPE_UINT32_T:
56+
((int32_t *) buf)[0] = value->int32tval;
57+
break;
58+
case MCA_BASE_VAR_TYPE_INT64_T:
59+
case MCA_BASE_VAR_TYPE_UINT64_T:
60+
((int64_t *) buf)[0] = value->int64tval;
61+
break;
62+
case MCA_BASE_VAR_TYPE_LONG:
5463
case MCA_BASE_VAR_TYPE_UNSIGNED_LONG:
5564
((unsigned long *) buf)[0] = value->ulval;
5665
break;
@@ -61,7 +70,7 @@ int MPI_T_cvar_read (MPI_T_cvar_handle handle, void *buf)
6170
((size_t *) buf)[0] = value->sizetval;
6271
break;
6372
case MCA_BASE_VAR_TYPE_BOOL:
64-
((int *) buf)[0] = value->boolval;
73+
((bool *) buf)[0] = value->boolval;
6574
break;
6675
case MCA_BASE_VAR_TYPE_DOUBLE:
6776
((double *) buf)[0] = value->lfval;

ompi/mpi/tool/mpit_common.c

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights
3+
* Copyright (c) 2012-2018 Los Alamos National Security, LLC. All rights
44
* reserved.
55
* Copyright (c) 2015 Research Organization for Information Science
66
* and Technology (RIST). All rights reserved.
@@ -28,53 +28,41 @@ void ompi_mpit_unlock (void)
2828
opal_mutex_unlock (&ompi_mpit_big_lock);
2929
}
3030

31+
static MPI_Datatype mca_to_mpi_datatypes[MCA_BASE_VAR_TYPE_MAX] = {
32+
[MCA_BASE_VAR_TYPE_INT] = MPI_INT,
33+
[MCA_BASE_VAR_TYPE_UNSIGNED_INT] = MPI_UNSIGNED,
34+
[MCA_BASE_VAR_TYPE_UNSIGNED_LONG] = MPI_UNSIGNED_LONG,
35+
[MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG] = MPI_UNSIGNED_LONG_LONG,
36+
37+
#if SIZEOF_SIZE_T == SIZEOF_UNSIGNED_INT
38+
[MCA_BASE_VAR_TYPE_SIZE_T] = MPI_UNSIGNED,
39+
#elif SIZEOF_SIZE_T == SIZEOF_UNSIGNED_LONG
40+
[MCA_BASE_VAR_TYPE_SIZE_T] = MPI_UNSIGNED_LONG,
41+
#elif SIZEOF_SIZE_T == SIZEOF_LONG_LONG
42+
[MCA_BASE_VAR_TYPE_SIZE_T] = MPI_UNSIGNED_LONG_LONG,
43+
#else
44+
[MCA_BASE_VAR_TYPE_SIZE_T] = NULL,
45+
#endif
46+
47+
[MCA_BASE_VAR_TYPE_STRING] = MPI_CHAR,
48+
[MCA_BASE_VAR_TYPE_VERSION_STRING] = MPI_CHAR,
49+
[MCA_BASE_VAR_TYPE_BOOL] = MPI_C_BOOL,
50+
[MCA_BASE_VAR_TYPE_DOUBLE] = MPI_DOUBLE,
51+
[MCA_BASE_VAR_TYPE_LONG] = MPI_LONG,
52+
[MCA_BASE_VAR_TYPE_INT32_T] = MPI_INT32_T,
53+
[MCA_BASE_VAR_TYPE_UINT32_T] = MPI_UINT32_T,
54+
[MCA_BASE_VAR_TYPE_INT64_T] = MPI_INT64_T,
55+
[MCA_BASE_VAR_TYPE_UINT64_T] = MPI_UINT64_T,
56+
};
57+
3158
int ompit_var_type_to_datatype (mca_base_var_type_t type, MPI_Datatype *datatype)
3259
{
3360
if (!datatype) {
3461
return OMPI_SUCCESS;
3562
}
3663

37-
switch (type) {
38-
case MCA_BASE_VAR_TYPE_INT:
39-
*datatype = MPI_INT;
40-
break;
41-
case MCA_BASE_VAR_TYPE_UNSIGNED_INT:
42-
*datatype = MPI_UNSIGNED;
43-
break;
44-
case MCA_BASE_VAR_TYPE_UNSIGNED_LONG:
45-
*datatype = MPI_UNSIGNED_LONG;
46-
break;
47-
case MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG:
48-
*datatype = MPI_UNSIGNED_LONG_LONG;
49-
break;
50-
case MCA_BASE_VAR_TYPE_SIZE_T:
51-
if (sizeof (size_t) == sizeof (unsigned)) {
52-
*datatype = MPI_UNSIGNED;
53-
} else if (sizeof (size_t) == sizeof (unsigned long)) {
54-
*datatype = MPI_UNSIGNED_LONG;
55-
} else if (sizeof (size_t) == sizeof (unsigned long long)) {
56-
*datatype = MPI_UNSIGNED_LONG_LONG;
57-
} else {
58-
/* not supported -- fixme */
59-
assert (0);
60-
}
61-
62-
break;
63-
case MCA_BASE_VAR_TYPE_STRING:
64-
case MCA_BASE_VAR_TYPE_VERSION_STRING:
65-
*datatype = MPI_CHAR;
66-
break;
67-
case MCA_BASE_VAR_TYPE_BOOL:
68-
*datatype = MPI_INT;
69-
break;
70-
case MCA_BASE_VAR_TYPE_DOUBLE:
71-
*datatype = MPI_DOUBLE;
72-
break;
73-
default:
74-
/* not supported -- fixme */
75-
assert (0);
76-
break;
77-
}
64+
*datatype = mca_to_mpi_datatypes[type];
65+
assert (*datatype);
7866

7967
return OMPI_SUCCESS;
8068
}

opal/mca/base/mca_base_var.c

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
1313
* Copyright (c) 2008-2015 Cisco Systems, Inc. All rights reserved.
14-
* Copyright (c) 2012-2017 Los Alamos National Security, LLC. All rights
14+
* Copyright (c) 2012-2018 Los Alamos National Security, LLC. All rights
1515
* reserved.
1616
* Copyright (c) 2014-2016 Intel, Inc. All rights reserved.
1717
* Copyright (c) 2015 Research Organization for Information Science
@@ -88,7 +88,12 @@ const char *ompi_var_type_names[] = {
8888
"string",
8989
"version_string",
9090
"bool",
91-
"double"
91+
"double",
92+
"long",
93+
"int32_t",
94+
"uint32_t",
95+
"int64_t",
96+
"uint64_t",
9297
};
9398

9499
const size_t ompi_var_type_sizes[] = {
@@ -100,7 +105,12 @@ const size_t ompi_var_type_sizes[] = {
100105
sizeof (char),
101106
sizeof (char),
102107
sizeof (bool),
103-
sizeof (double)
108+
sizeof (double),
109+
sizeof (long),
110+
sizeof (int32_t),
111+
sizeof (uint32_t),
112+
sizeof (int64_t),
113+
sizeof (uint64_t),
104114
};
105115

106116
static const char *var_source_names[] = {
@@ -683,8 +693,13 @@ static int var_set_from_string (mca_base_var_t *var, char *src)
683693

684694
switch (var->mbv_type) {
685695
case MCA_BASE_VAR_TYPE_INT:
696+
case MCA_BASE_VAR_TYPE_INT32_T:
697+
case MCA_BASE_VAR_TYPE_UINT32_T:
698+
case MCA_BASE_VAR_TYPE_LONG:
686699
case MCA_BASE_VAR_TYPE_UNSIGNED_INT:
687700
case MCA_BASE_VAR_TYPE_UNSIGNED_LONG:
701+
case MCA_BASE_VAR_TYPE_INT64_T:
702+
case MCA_BASE_VAR_TYPE_UINT64_T:
688703
case MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG:
689704
case MCA_BASE_VAR_TYPE_BOOL:
690705
case MCA_BASE_VAR_TYPE_SIZE_T:
@@ -710,6 +725,17 @@ static int var_set_from_string (mca_base_var_t *var, char *src)
710725
MCA_BASE_VAR_TYPE_UNSIGNED_INT == var->mbv_type) {
711726
int *castme = (int*) var->mbv_storage;
712727
*castme = int_value;
728+
} else if (MCA_BASE_VAR_TYPE_INT32_T == var->mbv_type ||
729+
MCA_BASE_VAR_TYPE_UINT32_T == var->mbv_type) {
730+
int32_t *castme = (int32_t *) var->mbv_storage;
731+
*castme = int_value;
732+
} else if (MCA_BASE_VAR_TYPE_INT64_T == var->mbv_type ||
733+
MCA_BASE_VAR_TYPE_UINT64_T == var->mbv_type) {
734+
int64_t *castme = (int64_t *) var->mbv_storage;
735+
*castme = int_value;
736+
} else if (MCA_BASE_VAR_TYPE_LONG == var->mbv_type) {
737+
long *castme = (long*) var->mbv_storage;
738+
*castme = (long) int_value;
713739
} else if (MCA_BASE_VAR_TYPE_UNSIGNED_LONG == var->mbv_type) {
714740
unsigned long *castme = (unsigned long*) var->mbv_storage;
715741
*castme = (unsigned long) int_value;
@@ -1263,11 +1289,18 @@ static int register_variable (const char *project_name, const char *framework_na
12631289
uintptr_t align = 0;
12641290
switch (type) {
12651291
case MCA_BASE_VAR_TYPE_INT:
1266-
align = OPAL_ALIGNMENT_INT;
1267-
break;
12681292
case MCA_BASE_VAR_TYPE_UNSIGNED_INT:
12691293
align = OPAL_ALIGNMENT_INT;
12701294
break;
1295+
case MCA_BASE_VAR_TYPE_INT32_T:
1296+
case MCA_BASE_VAR_TYPE_UINT32_T:
1297+
align = OPAL_ALIGNMENT_INT32;
1298+
break;
1299+
case MCA_BASE_VAR_TYPE_INT64_T:
1300+
case MCA_BASE_VAR_TYPE_UINT64_T:
1301+
align = OPAL_ALIGNMENT_INT64;
1302+
break;
1303+
case MCA_BASE_VAR_TYPE_LONG:
12711304
case MCA_BASE_VAR_TYPE_UNSIGNED_LONG:
12721305
align = OPAL_ALIGNMENT_LONG;
12731306
break;
@@ -1914,6 +1947,21 @@ static int var_value_string (mca_base_var_t *var, char **value_string)
19141947
case MCA_BASE_VAR_TYPE_INT:
19151948
ret = asprintf (value_string, "%d", value->intval);
19161949
break;
1950+
case MCA_BASE_VAR_TYPE_INT32_T:
1951+
ret = asprintf (value_string, "%" PRId32, value->int32tval);
1952+
break;
1953+
case MCA_BASE_VAR_TYPE_UINT32_T:
1954+
ret = asprintf (value_string, "%" PRIu32, value->uint32tval);
1955+
break;
1956+
case MCA_BASE_VAR_TYPE_INT64_T:
1957+
ret = asprintf (value_string, "%" PRId64, value->int64tval);
1958+
break;
1959+
case MCA_BASE_VAR_TYPE_UINT64_T:
1960+
ret = asprintf (value_string, "%" PRIu64, value->uint64tval);
1961+
break;
1962+
case MCA_BASE_VAR_TYPE_LONG:
1963+
ret = asprintf (value_string, "%ld", value->longval);
1964+
break;
19171965
case MCA_BASE_VAR_TYPE_UNSIGNED_INT:
19181966
ret = asprintf (value_string, "%u", value->uintval);
19191967
break;

opal/mca/base/mca_base_var.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
1313
* Copyright (c) 2008-2011 Cisco Systems, Inc. All rights reserved.
14-
* Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights
14+
* Copyright (c) 2012-2018 Los Alamos National Security, LLC. All rights
1515
* reserved.
1616
* Copyright (c) 2016 Intel, Inc. All rights reserved.
1717
* Copyright (c) 2017 IBM Corporation. All rights reserved.
@@ -92,6 +92,17 @@ typedef enum {
9292
MCA_BASE_VAR_TYPE_BOOL,
9393
/** The variable is of type double */
9494
MCA_BASE_VAR_TYPE_DOUBLE,
95+
/** The variable is of type long int */
96+
MCA_BASE_VAR_TYPE_LONG,
97+
/** The variable is of type int32_t */
98+
MCA_BASE_VAR_TYPE_INT32_T,
99+
/** The variable is of type uint32_t */
100+
MCA_BASE_VAR_TYPE_UINT32_T,
101+
/** The variable is of type int64_t */
102+
MCA_BASE_VAR_TYPE_INT64_T,
103+
/** The variable is of type uint64_t */
104+
MCA_BASE_VAR_TYPE_UINT64_T,
105+
95106
/** Maximum variable type. */
96107
MCA_BASE_VAR_TYPE_MAX
97108
} mca_base_var_type_t;
@@ -204,14 +215,24 @@ typedef enum {
204215
typedef union {
205216
/** integer value */
206217
int intval;
218+
/** int32_t value */
219+
int32_t int32tval;
220+
/** long value */
221+
long longval;
222+
/** int64_t value */
223+
int64_t int64tval;
207224
/** unsigned int value */
208225
unsigned int uintval;
226+
/** uint32_t value */
227+
uint32_t uint32tval;
209228
/** string value */
210229
char *stringval;
211230
/** boolean value */
212231
bool boolval;
213232
/** unsigned long value */
214233
unsigned long ulval;
234+
/** uint64_t value */
235+
uint64_t uint64tval;
215236
/** unsigned long long value */
216237
unsigned long long ullval;
217238
/** size_t value */

0 commit comments

Comments
 (0)