From 053578365f61ee7134cad9034407214cbb28eb19 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Mon, 29 Apr 2019 14:51:26 +0200 Subject: [PATCH] Const for MPI_Type_struct and MPI_Type_hindexed. --- include/smpi/smpi.h | 4 ++-- src/smpi/bindings/smpi_mpi.cpp | 4 ++-- src/smpi/bindings/smpi_pmpi_type.cpp | 11 +++++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/smpi/smpi.h b/include/smpi/smpi.h index e55d9c1187..8b0e629a85 100644 --- a/include/smpi/smpi.h +++ b/include/smpi/smpi.h @@ -438,7 +438,7 @@ MPI_CALL(XBT_PUBLIC int, MPI_Type_lb, (MPI_Datatype datatype, MPI_Aint* disp)); MPI_CALL(XBT_PUBLIC int, MPI_Type_ub, (MPI_Datatype datatype, MPI_Aint* disp)); MPI_CALL(XBT_PUBLIC int, MPI_Type_commit, (MPI_Datatype * datatype)); MPI_CALL(XBT_PUBLIC int, MPI_Type_hindexed, - (int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* newtype)); + (int count, const int* blocklens, const MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* newtype)); MPI_CALL(XBT_PUBLIC int, MPI_Type_create_hindexed, (int count, const int* blocklens, const MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* newtype)); MPI_CALL(XBT_PUBLIC int, MPI_Type_create_hindexed_block, @@ -454,7 +454,7 @@ MPI_CALL(XBT_PUBLIC int, MPI_Type_create_indexed, MPI_CALL(XBT_PUBLIC int, MPI_Type_create_indexed_block, (int count, int blocklength, const int* indices, MPI_Datatype old_type, MPI_Datatype* newtype)); MPI_CALL(XBT_PUBLIC int, MPI_Type_struct, - (int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* newtype)); + (int count, const int* blocklens, const MPI_Aint* indices, const MPI_Datatype* old_types, MPI_Datatype* newtype)); MPI_CALL(XBT_PUBLIC int, MPI_Type_create_struct, (int count, const int* blocklens, const MPI_Aint* indices, const MPI_Datatype* old_types, MPI_Datatype* newtype)); MPI_CALL(XBT_PUBLIC int, MPI_Type_vector, diff --git a/src/smpi/bindings/smpi_mpi.cpp b/src/smpi/bindings/smpi_mpi.cpp index d0081a6285..fda923adb0 100644 --- a/src/smpi/bindings/smpi_mpi.cpp +++ b/src/smpi/bindings/smpi_mpi.cpp @@ -240,7 +240,7 @@ WRAPPED_PMPI_CALL(int,MPI_Type_get_attr ,(MPI_Datatype type, int type_keyval, vo WRAPPED_PMPI_CALL(int,MPI_Type_get_extent,(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent),(datatype, lb, extent)) WRAPPED_PMPI_CALL(int,MPI_Type_get_name,(MPI_Datatype datatype, char * name, int* len),(datatype,name,len)) WRAPPED_PMPI_CALL(int,MPI_Type_get_true_extent,(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent),(datatype, lb, extent)) -WRAPPED_PMPI_CALL(int,MPI_Type_hindexed,(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* newtype) ,(count, blocklens, indices, old_type, newtype)) +WRAPPED_PMPI_CALL(int,MPI_Type_hindexed,(int count, const int* blocklens, const MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* newtype) ,(count, blocklens, indices, old_type, newtype)) WRAPPED_PMPI_CALL(int,MPI_Type_hvector,(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* newtype) ,(count, blocklen, stride, old_type, newtype)) WRAPPED_PMPI_CALL(int,MPI_Type_indexed,(int count, const int* blocklens, const int* indices, MPI_Datatype old_type, MPI_Datatype* newtype) ,(count, blocklens, indices, old_type, newtype)) WRAPPED_PMPI_CALL(int,MPI_Type_lb,(MPI_Datatype datatype, MPI_Aint * disp),(datatype, disp)) @@ -248,7 +248,7 @@ WRAPPED_PMPI_CALL(int,MPI_Type_set_attr ,(MPI_Datatype type, int type_keyval, vo WRAPPED_PMPI_CALL(int,MPI_Type_set_name,(MPI_Datatype datatype, const char * name),(datatype, name)) WRAPPED_PMPI_CALL(int,MPI_Type_size,(MPI_Datatype datatype, int *size),(datatype, size)) WRAPPED_PMPI_CALL(int,MPI_Type_size_x,(MPI_Datatype datatype, MPI_Count *size),(datatype, size)) -WRAPPED_PMPI_CALL(int,MPI_Type_struct,(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* newtype) ,(count, blocklens, indices, old_types, newtype)) +WRAPPED_PMPI_CALL(int,MPI_Type_struct,(int count, const int* blocklens, const MPI_Aint* indices, const MPI_Datatype* old_types, MPI_Datatype* newtype) ,(count, blocklens, indices, old_types, newtype)) WRAPPED_PMPI_CALL(int,MPI_Type_ub,(MPI_Datatype datatype, MPI_Aint * disp),(datatype, disp)) WRAPPED_PMPI_CALL(int,MPI_Type_vector,(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* newtype) ,(count, blocklen, stride, old_type, newtype)) WRAPPED_PMPI_CALL(int,MPI_Unpack,(const void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm) ,(inbuf, insize, position, outbuf, outcount, type, comm)) diff --git a/src/smpi/bindings/smpi_pmpi_type.cpp b/src/smpi/bindings/smpi_pmpi_type.cpp index 7d3e0db66b..868a2a9622 100644 --- a/src/smpi/bindings/smpi_pmpi_type.cpp +++ b/src/smpi/bindings/smpi_pmpi_type.cpp @@ -196,7 +196,8 @@ int PMPI_Type_create_indexed_block(int count, int blocklength, const int* indice } } -int PMPI_Type_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) +int PMPI_Type_hindexed(int count, const int* blocklens, const MPI_Aint* indices, MPI_Datatype old_type, + MPI_Datatype* new_type) { if (old_type == MPI_DATATYPE_NULL) { return MPI_ERR_TYPE; @@ -209,7 +210,7 @@ int PMPI_Type_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatyp int PMPI_Type_create_hindexed(int count, const int* blocklens, const MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) { - return PMPI_Type_hindexed(count, const_cast(blocklens),const_cast(indices),old_type,new_type); + return PMPI_Type_hindexed(count, blocklens, indices, old_type, new_type); } int PMPI_Type_create_hindexed_block(int count, int blocklength, const MPI_Aint* indices, MPI_Datatype old_type, @@ -228,7 +229,9 @@ int PMPI_Type_create_hindexed_block(int count, int blocklength, const MPI_Aint* } } -int PMPI_Type_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type) { +int PMPI_Type_struct(int count, const int* blocklens, const MPI_Aint* indices, const MPI_Datatype* old_types, + MPI_Datatype* new_type) +{ if (count<0){ return MPI_ERR_COUNT; } else { @@ -241,7 +244,7 @@ int PMPI_Type_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* int PMPI_Type_create_struct(int count, const int* blocklens, const MPI_Aint* indices, const MPI_Datatype* old_types, MPI_Datatype* new_type) { - return PMPI_Type_struct(count, const_cast(blocklens), const_cast(indices), const_cast(old_types), new_type); + return PMPI_Type_struct(count, blocklens, indices, old_types, new_type); } -- 2.20.1