diff --git a/ompi/mpi/tool/cvar_read.c b/ompi/mpi/tool/cvar_read.c index 63ce6aa105..2246c5f88b 100644 --- a/ompi/mpi/tool/cvar_read.c +++ b/ompi/mpi/tool/cvar_read.c @@ -1,6 +1,6 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * Copyright (c) 2012-2018 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2016 Intel, Inc. All rights reserved. @@ -51,6 +51,15 @@ int MPI_T_cvar_read (MPI_T_cvar_handle handle, void *buf) case MCA_BASE_VAR_TYPE_UNSIGNED_INT: ((int *) buf)[0] = value->intval; break; + case MCA_BASE_VAR_TYPE_INT32_T: + case MCA_BASE_VAR_TYPE_UINT32_T: + ((int32_t *) buf)[0] = value->int32tval; + break; + case MCA_BASE_VAR_TYPE_INT64_T: + case MCA_BASE_VAR_TYPE_UINT64_T: + ((int64_t *) buf)[0] = value->int64tval; + break; + case MCA_BASE_VAR_TYPE_LONG: case MCA_BASE_VAR_TYPE_UNSIGNED_LONG: ((unsigned long *) buf)[0] = value->ulval; break; @@ -61,7 +70,7 @@ int MPI_T_cvar_read (MPI_T_cvar_handle handle, void *buf) ((size_t *) buf)[0] = value->sizetval; break; case MCA_BASE_VAR_TYPE_BOOL: - ((int *) buf)[0] = value->boolval; + ((bool *) buf)[0] = value->boolval; break; case MCA_BASE_VAR_TYPE_DOUBLE: ((double *) buf)[0] = value->lfval; diff --git a/ompi/mpi/tool/mpit_common.c b/ompi/mpi/tool/mpit_common.c index c21723faab..d30e1b89c9 100644 --- a/ompi/mpi/tool/mpit_common.c +++ b/ompi/mpi/tool/mpit_common.c @@ -1,6 +1,6 @@ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights + * Copyright (c) 2012-2018 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. @@ -28,53 +28,41 @@ void ompi_mpit_unlock (void) opal_mutex_unlock (&ompi_mpit_big_lock); } +static MPI_Datatype mca_to_mpi_datatypes[MCA_BASE_VAR_TYPE_MAX] = { + [MCA_BASE_VAR_TYPE_INT] = MPI_INT, + [MCA_BASE_VAR_TYPE_UNSIGNED_INT] = MPI_UNSIGNED, + [MCA_BASE_VAR_TYPE_UNSIGNED_LONG] = MPI_UNSIGNED_LONG, + [MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG] = MPI_UNSIGNED_LONG_LONG, + +#if SIZEOF_SIZE_T == SIZEOF_UNSIGNED_INT + [MCA_BASE_VAR_TYPE_SIZE_T] = MPI_UNSIGNED, +#elif SIZEOF_SIZE_T == SIZEOF_UNSIGNED_LONG + [MCA_BASE_VAR_TYPE_SIZE_T] = MPI_UNSIGNED_LONG, +#elif SIZEOF_SIZE_T == SIZEOF_LONG_LONG + [MCA_BASE_VAR_TYPE_SIZE_T] = MPI_UNSIGNED_LONG_LONG, +#else + [MCA_BASE_VAR_TYPE_SIZE_T] = NULL, +#endif + + [MCA_BASE_VAR_TYPE_STRING] = MPI_CHAR, + [MCA_BASE_VAR_TYPE_VERSION_STRING] = MPI_CHAR, + [MCA_BASE_VAR_TYPE_BOOL] = MPI_C_BOOL, + [MCA_BASE_VAR_TYPE_DOUBLE] = MPI_DOUBLE, + [MCA_BASE_VAR_TYPE_LONG] = MPI_LONG, + [MCA_BASE_VAR_TYPE_INT32_T] = MPI_INT32_T, + [MCA_BASE_VAR_TYPE_UINT32_T] = MPI_UINT32_T, + [MCA_BASE_VAR_TYPE_INT64_T] = MPI_INT64_T, + [MCA_BASE_VAR_TYPE_UINT64_T] = MPI_UINT64_T, +}; + int ompit_var_type_to_datatype (mca_base_var_type_t type, MPI_Datatype *datatype) { if (!datatype) { return OMPI_SUCCESS; } - switch (type) { - case MCA_BASE_VAR_TYPE_INT: - *datatype = MPI_INT; - break; - case MCA_BASE_VAR_TYPE_UNSIGNED_INT: - *datatype = MPI_UNSIGNED; - break; - case MCA_BASE_VAR_TYPE_UNSIGNED_LONG: - *datatype = MPI_UNSIGNED_LONG; - break; - case MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG: - *datatype = MPI_UNSIGNED_LONG_LONG; - break; - case MCA_BASE_VAR_TYPE_SIZE_T: - if (sizeof (size_t) == sizeof (unsigned)) { - *datatype = MPI_UNSIGNED; - } else if (sizeof (size_t) == sizeof (unsigned long)) { - *datatype = MPI_UNSIGNED_LONG; - } else if (sizeof (size_t) == sizeof (unsigned long long)) { - *datatype = MPI_UNSIGNED_LONG_LONG; - } else { - /* not supported -- fixme */ - assert (0); - } - - break; - case MCA_BASE_VAR_TYPE_STRING: - case MCA_BASE_VAR_TYPE_VERSION_STRING: - *datatype = MPI_CHAR; - break; - case MCA_BASE_VAR_TYPE_BOOL: - *datatype = MPI_INT; - break; - case MCA_BASE_VAR_TYPE_DOUBLE: - *datatype = MPI_DOUBLE; - break; - default: - /* not supported -- fixme */ - assert (0); - break; - } + *datatype = mca_to_mpi_datatypes[type]; + assert (*datatype); return OMPI_SUCCESS; } diff --git a/opal/mca/base/mca_base_var.c b/opal/mca/base/mca_base_var.c index ea39fd4e4c..9b07a9664e 100644 --- a/opal/mca/base/mca_base_var.c +++ b/opal/mca/base/mca_base_var.c @@ -11,7 +11,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2008-2015 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2012-2017 Los Alamos National Security, LLC. All rights + * Copyright (c) 2012-2018 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2014-2016 Intel, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science @@ -88,7 +88,12 @@ const char *ompi_var_type_names[] = { "string", "version_string", "bool", - "double" + "double", + "long", + "int32_t", + "uint32_t", + "int64_t", + "uint64_t", }; const size_t ompi_var_type_sizes[] = { @@ -100,7 +105,12 @@ const size_t ompi_var_type_sizes[] = { sizeof (char), sizeof (char), sizeof (bool), - sizeof (double) + sizeof (double), + sizeof (long), + sizeof (int32_t), + sizeof (uint32_t), + sizeof (int64_t), + sizeof (uint64_t), }; static const char *var_source_names[] = { @@ -683,8 +693,13 @@ static int var_set_from_string (mca_base_var_t *var, char *src) switch (var->mbv_type) { case MCA_BASE_VAR_TYPE_INT: + case MCA_BASE_VAR_TYPE_INT32_T: + case MCA_BASE_VAR_TYPE_UINT32_T: + case MCA_BASE_VAR_TYPE_LONG: case MCA_BASE_VAR_TYPE_UNSIGNED_INT: case MCA_BASE_VAR_TYPE_UNSIGNED_LONG: + case MCA_BASE_VAR_TYPE_INT64_T: + case MCA_BASE_VAR_TYPE_UINT64_T: case MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG: case MCA_BASE_VAR_TYPE_BOOL: case MCA_BASE_VAR_TYPE_SIZE_T: @@ -710,6 +725,17 @@ static int var_set_from_string (mca_base_var_t *var, char *src) MCA_BASE_VAR_TYPE_UNSIGNED_INT == var->mbv_type) { int *castme = (int*) var->mbv_storage; *castme = int_value; + } else if (MCA_BASE_VAR_TYPE_INT32_T == var->mbv_type || + MCA_BASE_VAR_TYPE_UINT32_T == var->mbv_type) { + int32_t *castme = (int32_t *) var->mbv_storage; + *castme = int_value; + } else if (MCA_BASE_VAR_TYPE_INT64_T == var->mbv_type || + MCA_BASE_VAR_TYPE_UINT64_T == var->mbv_type) { + int64_t *castme = (int64_t *) var->mbv_storage; + *castme = int_value; + } else if (MCA_BASE_VAR_TYPE_LONG == var->mbv_type) { + long *castme = (long*) var->mbv_storage; + *castme = (long) int_value; } else if (MCA_BASE_VAR_TYPE_UNSIGNED_LONG == var->mbv_type) { unsigned long *castme = (unsigned long*) var->mbv_storage; *castme = (unsigned long) int_value; @@ -1263,11 +1289,18 @@ static int register_variable (const char *project_name, const char *framework_na uintptr_t align = 0; switch (type) { case MCA_BASE_VAR_TYPE_INT: - align = OPAL_ALIGNMENT_INT; - break; case MCA_BASE_VAR_TYPE_UNSIGNED_INT: align = OPAL_ALIGNMENT_INT; break; + case MCA_BASE_VAR_TYPE_INT32_T: + case MCA_BASE_VAR_TYPE_UINT32_T: + align = OPAL_ALIGNMENT_INT32; + break; + case MCA_BASE_VAR_TYPE_INT64_T: + case MCA_BASE_VAR_TYPE_UINT64_T: + align = OPAL_ALIGNMENT_INT64; + break; + case MCA_BASE_VAR_TYPE_LONG: case MCA_BASE_VAR_TYPE_UNSIGNED_LONG: align = OPAL_ALIGNMENT_LONG; break; @@ -1914,6 +1947,21 @@ static int var_value_string (mca_base_var_t *var, char **value_string) case MCA_BASE_VAR_TYPE_INT: ret = asprintf (value_string, "%d", value->intval); break; + case MCA_BASE_VAR_TYPE_INT32_T: + ret = asprintf (value_string, "%" PRId32, value->int32tval); + break; + case MCA_BASE_VAR_TYPE_UINT32_T: + ret = asprintf (value_string, "%" PRIu32, value->uint32tval); + break; + case MCA_BASE_VAR_TYPE_INT64_T: + ret = asprintf (value_string, "%" PRId64, value->int64tval); + break; + case MCA_BASE_VAR_TYPE_UINT64_T: + ret = asprintf (value_string, "%" PRIu64, value->uint64tval); + break; + case MCA_BASE_VAR_TYPE_LONG: + ret = asprintf (value_string, "%ld", value->longval); + break; case MCA_BASE_VAR_TYPE_UNSIGNED_INT: ret = asprintf (value_string, "%u", value->uintval); break; diff --git a/opal/mca/base/mca_base_var.h b/opal/mca/base/mca_base_var.h index 0b307fa6cb..946e0b5852 100644 --- a/opal/mca/base/mca_base_var.h +++ b/opal/mca/base/mca_base_var.h @@ -11,7 +11,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2008-2011 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights + * Copyright (c) 2012-2018 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2016 Intel, Inc. All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. @@ -92,6 +92,17 @@ typedef enum { MCA_BASE_VAR_TYPE_BOOL, /** The variable is of type double */ MCA_BASE_VAR_TYPE_DOUBLE, + /** The variable is of type long int */ + MCA_BASE_VAR_TYPE_LONG, + /** The variable is of type int32_t */ + MCA_BASE_VAR_TYPE_INT32_T, + /** The variable is of type uint32_t */ + MCA_BASE_VAR_TYPE_UINT32_T, + /** The variable is of type int64_t */ + MCA_BASE_VAR_TYPE_INT64_T, + /** The variable is of type uint64_t */ + MCA_BASE_VAR_TYPE_UINT64_T, + /** Maximum variable type. */ MCA_BASE_VAR_TYPE_MAX } mca_base_var_type_t; @@ -204,14 +215,24 @@ typedef enum { typedef union { /** integer value */ int intval; + /** int32_t value */ + int32_t int32tval; + /** long value */ + long longval; + /** int64_t value */ + int64_t int64tval; /** unsigned int value */ unsigned int uintval; + /** uint32_t value */ + uint32_t uint32tval; /** string value */ char *stringval; /** boolean value */ bool boolval; /** unsigned long value */ unsigned long ulval; + /** uint64_t value */ + uint64_t uint64tval; /** unsigned long long value */ unsigned long long ullval; /** size_t value */