From: Gabriel Corona Date: Tue, 28 Apr 2015 09:42:09 +0000 (+0200) Subject: [smpi] Better implementation of predefined attributes X-Git-Tag: v3_12~732^2~35 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/73f730073c2793c40652d390f90fc8e1d2f32bbf [smpi] Better implementation of predefined attributes Fixes test-smpi-mpich3-attr-raw. --- diff --git a/include/smpi/mpif.h.in b/include/smpi/mpif.h.in index fbd61612c5..7f75138183 100644 --- a/include/smpi/mpif.h.in +++ b/include/smpi/mpif.h.in @@ -18,7 +18,6 @@ integer MPI_MAX_DATAREP_STRIN, MPI_MAX_INFO_KEY integer MPI_MAX_INFO_VAL, MPI_MAX_OBJECT_NAME, MPI_MAX_PORT_NAME integer MPI_ANY_SOURCE, MPI_PROC_NULL, MPI_ANY_TAG, MPI_UNDEFINED - integer MPI_TAG_UB, MPI_TAG_LB integer MPI_SOURCE, MPI_TAG, MPI_ERROR integer MPI_VERSION, MPI_SUBVERSION parameter(MPI_MAX_PROCESSOR_NAME=100) @@ -35,8 +34,6 @@ parameter(MPI_SOURCE=1) parameter(MPI_TAG=2) parameter(MPI_ERROR=3) - parameter(MPI_TAG_UB=0) - parameter(MPI_TAG_LB=0) parameter(MPI_VERSION=1) parameter(MPI_SUBVERSION=1) integer MPI_MODE_NOSTORE, MPI_MODE_NOPUT, MPI_MODE_NOPRECEDE @@ -51,9 +48,8 @@ integer MPI_ERR_REQUEST, MPI_ERR_INTERN, MPI_ERR_COUNT integer MPI_ERR_RANK, MPI_ERR_OTHER, MPI_ERR_UNKNOWN integer MPI_ERR_TAG, MPI_ERR_TRUNCATE, MPI_ERR_GROUP, MPI_ERR_OP - integer MPI_LASTUSEDCODE, MPI_ERR_LASTCODE + integer MPI_ERR_LASTCODE integer MPI_IDENT, MPI_SIMILAR, MPI_UNEQUAL, MPI_CONGRUENT - integer MPI_WTIME_IS_GLOBAL parameter(MPI_SUCCESS=0) parameter(MPI_ERR_COMM=1) parameter(MPI_ERR_ARG=2) @@ -68,13 +64,12 @@ parameter(MPI_ERR_OP=11) parameter(MPI_ERR_OTHER=12) parameter(MPI_ERR_UNKNOWN=13) - parameter(MPI_LASTUSEDCODE=0) parameter(MPI_ERR_LASTCODE=74) parameter(MPI_IDENT=0) parameter(MPI_SIMILAR=1) parameter(MPI_UNEQUAL=2) parameter(MPI_CONGRUENT=3) - parameter(MPI_WTIME_IS_GLOBAL=1) + integer MPI_NULL_COPY_FN, MPI_NULL_DELETE_FN parameter(MPI_NULL_COPY_FN =0) @@ -85,23 +80,32 @@ integer MPI_COMM_NULL_DUP_FN, MPI_COMM_DUP_FN parameter(MPI_COMM_NULL_DUP_FN =0) parameter(MPI_COMM_DUP_FN =0) - integer MPI_APPNUM, MPI_HOST, MPI_IO - parameter(MPI_APPNUM=0) - parameter(MPI_HOST=0) - parameter(MPI_IO=0) + + + integer MPI_ROOT, MPI_INFO_NULL,MPI_COMM_TYPE_SHARED parameter(MPI_ROOT=0) parameter(MPI_INFO_NULL=0) parameter(MPI_COMM_TYPE_SHARED=1) +! Attribute keys + integer MPI_IO, MPI_HOST, MPI_WTIME_IS_GLOBAL, MPI_APPNUM + integer MPI_TAG_UB, MPI_TAG_LB + integer MPI_UNIVERSE_SIZE, MPI_LASTUSEDCODE + parameter(MPI_IO=-1) + parameter(MPI_HOST=-2) + parameter(MPI_WTIME_IS_GLOBAL=-3) + parameter(MPI_APPNUM=-4) + parameter(MPI_TAG_UB=-5) + parameter(MPI_TAG_LB=-6) + parameter(MPI_UNIVERSE_SIZE=-7) + parameter(MPI_LASTUSEDCODE=-8) + ! These should be ordered as in smpi_f77.c integer MPI_COMM_NULL, MPI_COMM_WORLD, MPI_COMM_SELF - integer MPI_UNIVERSE_SIZE parameter(MPI_COMM_NULL=-1) parameter(MPI_COMM_SELF=-2) parameter(MPI_COMM_WORLD=0) - parameter(MPI_UNIVERSE_SIZE=0) - integer MPI_GROUP_NULL, MPI_GROUP_EMPTY parameter(MPI_GROUP_NULL=-1) diff --git a/include/smpi/smpi.h b/include/smpi/smpi.h index 73c7525ba5..97d02cc1ab 100644 --- a/include/smpi/smpi.h +++ b/include/smpi/smpi.h @@ -129,12 +129,19 @@ SG_BEGIN_DECL() #define MPI_SIMILAR 1 #define MPI_UNEQUAL 2 #define MPI_CONGRUENT 3 -#define MPI_WTIME_IS_GLOBAL 1 -#define MPI_TAG_UB 1000000 -#define MPI_HOST 0 -#define MPI_IO 0 + + #define MPI_BSEND_OVERHEAD 0 +/* Attribute keys */ +#define MPI_IO -1 +#define MPI_HOST -2 +#define MPI_WTIME_IS_GLOBAL -3 +#define MPI_APPNUM -4 +#define MPI_TAG_UB -5 +#define MPI_TAG_LB -6 +#define MPI_UNIVERSE_SIZE -7 +#define MPI_LASTUSEDCODE -8 #define MPI_MODE_NOSTORE 0x1 #define MPI_MODE_NOPUT 0x2 @@ -142,12 +149,9 @@ SG_BEGIN_DECL() #define MPI_MODE_NOSUCCEED 0x8 #define MPI_MODE_NOCHECK 0x10 - #define MPI_KEYVAL_INVALID 0 #define MPI_NULL_COPY_FN NULL #define MPI_NULL_DELETE_FN NULL -#define MPI_APPNUM 0 -#define MPI_LASTUSEDCODE MPI_SUCCESS #define MPI_ERR_LASTCODE 74 #define MPI_CXX_BOOL MPI_DATATYPE_NULL @@ -356,7 +360,6 @@ typedef struct s_smpi_mpi_communicator *MPI_Comm; #define MPI_COMM_NULL ((MPI_Comm)NULL) XBT_PUBLIC_DATA( MPI_Comm ) MPI_COMM_WORLD; -XBT_PUBLIC_DATA( int ) MPI_UNIVERSE_SIZE; #define MPI_COMM_SELF smpi_process_comm_self() struct s_smpi_mpi_request; diff --git a/src/smpi/private.h b/src/smpi/private.h index 050f2198e5..a6d4189ee1 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -770,6 +770,7 @@ typedef struct s_smpi_privatisation_region { extern smpi_privatisation_region_t smpi_privatisation_regions; extern int smpi_loaded_page; +extern int smpi_universe_size; int SIMIX_process_get_PID(smx_process_t self); diff --git a/src/smpi/smpi_comm.c b/src/smpi/smpi_comm.c index c06b16d9f0..e2df67d4a5 100644 --- a/src/smpi/smpi_comm.c +++ b/src/smpi/smpi_comm.c @@ -18,7 +18,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_comm, smpi, "Logging specific to SMPI (comm)"); xbt_dict_t smpi_comm_keyvals = NULL; -int comm_keyval_id=MPI_TAG_UB+1;//avoid collisions +int comm_keyval_id = 0;//avoid collisions /* Support for cartesian topology was added, but there are 2 other types of * topology, graph et dist graph. In order to support them, we have to add a @@ -617,4 +617,3 @@ int smpi_comm_keyval_free(int* keyval){ xbt_free(elem); return MPI_SUCCESS; } - diff --git a/src/smpi/smpi_global.c b/src/smpi/smpi_global.c index f47536e177..ebddf585b0 100644 --- a/src/smpi/smpi_global.c +++ b/src/smpi/smpi_global.c @@ -44,11 +44,11 @@ typedef struct s_smpi_process_data { static smpi_process_data_t *process_data = NULL; int process_count = 0; +int smpi_universe_size = 0; int* index_to_process_data = NULL; extern double smpi_total_benched_time; xbt_os_timer_t global_timer; MPI_Comm MPI_COMM_WORLD = MPI_COMM_UNINITIALIZED; -int MPI_UNIVERSE_SIZE; MPI_Errhandler *MPI_ERRORS_RETURN = NULL; MPI_Errhandler *MPI_ERRORS_ARE_FATAL = NULL; @@ -426,6 +426,7 @@ void smpi_global_init(void) process_count = SIMIX_process_count(); smpirun=1; } + smpi_universe_size = process_count; process_data = xbt_new0(smpi_process_data_t, process_count); for (i = 0; i < process_count; i++) { process_data[i] = xbt_new(s_smpi_process_data_t, 1); @@ -453,9 +454,9 @@ void smpi_global_init(void) if(smpirun){ group = smpi_group_new(process_count); MPI_COMM_WORLD = smpi_comm_new(group, NULL); + MPI_Attr_put(MPI_COMM_WORLD, MPI_UNIVERSE_SIZE, (void *)(MPI_Aint)process_count); xbt_bar_t bar=xbt_barrier_init(process_count); - MPI_UNIVERSE_SIZE = smpi_comm_size(MPI_COMM_WORLD); for (i = 0; i < process_count; i++) { smpi_group_set_mapping(group, i, i); process_data[i]->finalization_barrier = bar; diff --git a/src/smpi/smpi_pmpi.c b/src/smpi/smpi_pmpi.c index 75e2eddbe8..cc3bdb98b2 100644 --- a/src/smpi/smpi_pmpi.c +++ b/src/smpi/smpi_pmpi.c @@ -3094,20 +3094,47 @@ int PMPI_Attr_delete(MPI_Comm comm, int keyval) { } int PMPI_Attr_get(MPI_Comm comm, int keyval, void* attr_value, int* flag) { + static int one = 1; + static int zero = 0; + static int tag_ub = 1000000; + static int last_used_code = MPI_ERR_LASTCODE; + if (comm==MPI_COMM_NULL){ - *flag=0; + *flag = 0; return MPI_ERR_COMM; - } else if(keyval == MPI_TAG_UB||keyval == MPI_HOST||keyval == MPI_IO - ||keyval == MPI_WTIME_IS_GLOBAL||keyval == MPI_APPNUM - ||keyval == MPI_UNIVERSE_SIZE||keyval == MPI_LASTUSEDCODE){ + } + + switch (keyval) { + case MPI_HOST: + case MPI_IO: + case MPI_APPNUM: + *flag = 1; + *(int**)attr_value = &zero; + return MPI_SUCCESS; + + case MPI_UNIVERSE_SIZE: + *flag = 1; + *(int**)attr_value = &smpi_universe_size; + return MPI_SUCCESS; + + case MPI_LASTUSEDCODE: + *flag = 1; + *(int**)attr_value = &last_used_code; + return MPI_SUCCESS; + + case MPI_TAG_UB: *flag=1; - //FIXME : not ideal and leaky, but should not be called too much - int* res = xbt_new(int, 1); - *res=keyval; - *(int**)attr_value=res; + *(int**)attr_value = &tag_ub; + return MPI_SUCCESS; + + case MPI_WTIME_IS_GLOBAL: + *flag = 1; + *(int**)attr_value = &one; return MPI_SUCCESS; - } else - return smpi_comm_attr_get(comm, keyval, attr_value, flag); + + default: + return smpi_comm_attr_get(comm, keyval, attr_value, flag); + } } int PMPI_Attr_put(MPI_Comm comm, int keyval, void* attr_value) { @@ -3635,4 +3662,3 @@ int PMPI_Win_test(MPI_Win win, int *flag){ int PMPI_Win_unlock(int rank, MPI_Win win){ NOT_YET_IMPLEMENTED } -