X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c540b8009e2e13d461ecaa7cf17f68950b3539fb..2bcb5dd3317c733c31c288ae79e72fb28863d936:/src/smpi/smpi_comm.cpp diff --git a/src/smpi/smpi_comm.cpp b/src/smpi/smpi_comm.cpp index c13a486cc8..7b2cbe07d9 100644 --- a/src/smpi/smpi_comm.cpp +++ b/src/smpi/smpi_comm.cpp @@ -5,14 +5,18 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include +#include + +#include +#include +#include + +#include #include "private.h" -#include "xbt/dict.h" #include "smpi_mpi_dt_private.h" -#include "limits.h" #include "src/simix/smx_private.h" #include "colls/colls.h" -#include "xbt/ex.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_comm, smpi, "Logging specific to SMPI (comm)"); @@ -93,25 +97,26 @@ int smpi_comm_dup(MPI_Comm comm, MPI_Comm* newcomm){ int ret = MPI_SUCCESS; if(comm->attributes !=nullptr){ - (*newcomm)->attributes=xbt_dict_new(); - xbt_dict_cursor_t cursor = nullptr; - int *key; - int flag; - void* value_in; - void* value_out; - xbt_dict_foreach(comm->attributes, cursor, key, value_in){ - smpi_comm_key_elem elem = - static_cast(xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast(key), sizeof(int))); - if(elem!=nullptr && elem->copy_fn!=MPI_NULL_COPY_FN){ - ret = elem->copy_fn(comm, *key, nullptr, value_in, &value_out, &flag ); - if(ret!=MPI_SUCCESS){ - smpi_comm_destroy(*newcomm); - *newcomm=MPI_COMM_NULL; - return ret; - } - if(flag) - xbt_dict_set_ext((*newcomm)->attributes, reinterpret_cast(key), sizeof(int),value_out, nullptr); + (*newcomm)->attributes = xbt_dict_new_homogeneous(nullptr); + xbt_dict_cursor_t cursor = nullptr; + int* key; + int flag; + void* value_in; + void* value_out; + xbt_dict_foreach (comm->attributes, cursor, key, value_in) { + smpi_comm_key_elem elem = static_cast( + xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast(key), sizeof(int))); + if (elem != nullptr && elem->copy_fn != MPI_NULL_COPY_FN) { + ret = elem->copy_fn(comm, *key, nullptr, value_in, &value_out, &flag); + if (ret != MPI_SUCCESS) { + smpi_comm_destroy(*newcomm); + *newcomm = MPI_COMM_NULL; + xbt_dict_cursor_free(&cursor); + return ret; } + if (flag) + xbt_dict_set_ext((*newcomm)->attributes, reinterpret_cast(key), sizeof(int), value_out, nullptr); + } } } return ret; @@ -369,9 +374,9 @@ void smpi_comm_init_smp(MPI_Comm comm){ int intra_comm_size = 0; int i =0; int min_index=INT_MAX;//the minimum index will be the leader - smx_process_t process = nullptr; + smx_actor_t process = nullptr; xbt_swag_foreach(process, process_list) { - int index = SIMIX_process_get_PID(process) -1; + int index = process->pid -1; if(smpi_group_rank(smpi_comm_group(comm), index)!=MPI_UNDEFINED){ intra_comm_size++; @@ -386,7 +391,7 @@ void smpi_comm_init_smp(MPI_Comm comm){ i=0; process = nullptr; xbt_swag_foreach(process, process_list) { - int index = SIMIX_process_get_PID(process) -1; + int index = process->pid -1; if(smpi_group_rank(smpi_comm_group(comm), index)!=MPI_UNDEFINED){ smpi_group_set_mapping(group_intra, index, i); i++; @@ -515,7 +520,7 @@ int smpi_comm_attr_delete(MPI_Comm comm, int keyval){ if(elem==nullptr) return MPI_ERR_ARG; if(elem->delete_fn!=MPI_NULL_DELETE_FN){ - void * value; + void* value = nullptr; int flag; if(smpi_comm_attr_get(comm, keyval, &value, &flag)==MPI_SUCCESS){ int ret = elem->delete_fn(comm, keyval, value, &flag); @@ -535,31 +540,30 @@ int smpi_comm_attr_get(MPI_Comm comm, int keyval, void* attr_value, int* flag){ static_cast(xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast(&keyval), sizeof(int))); if(elem==nullptr) return MPI_ERR_ARG; - xbt_ex_t ex; if(comm->attributes==nullptr){ *flag=0; return MPI_SUCCESS; } - TRY { + try { *static_cast(attr_value) = xbt_dict_get_ext(comm->attributes, reinterpret_cast(&keyval), sizeof(int)); *flag=1; - } CATCH(ex) { + } + catch (xbt_ex& ex) { *flag=0; - xbt_ex_free(ex); } return MPI_SUCCESS; } int smpi_comm_attr_put(MPI_Comm comm, int keyval, void* attr_value){ if(smpi_comm_keyvals==nullptr) - smpi_comm_keyvals = xbt_dict_new(); + smpi_comm_keyvals = xbt_dict_new_homogeneous(nullptr); smpi_comm_key_elem elem = static_cast(xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast(&keyval), sizeof(int))); if(elem==nullptr) return MPI_ERR_ARG; int flag; - void* value; + void* value = nullptr; smpi_comm_attr_get(comm, keyval, &value, &flag); if(flag!=0 && elem->delete_fn!=MPI_NULL_DELETE_FN){ int ret = elem->delete_fn(comm, keyval, value, &flag); @@ -567,7 +571,7 @@ int smpi_comm_attr_put(MPI_Comm comm, int keyval, void* attr_value){ return ret; } if(comm->attributes==nullptr) - comm->attributes=xbt_dict_new(); + comm->attributes = xbt_dict_new_homogeneous(nullptr); xbt_dict_set_ext(comm->attributes, reinterpret_cast(&keyval), sizeof(int), attr_value, nullptr); return MPI_SUCCESS; @@ -576,7 +580,7 @@ int smpi_comm_attr_put(MPI_Comm comm, int keyval, void* attr_value){ int smpi_comm_keyval_create(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delete_attr_function* delete_fn, int* keyval, void* extra_state){ if(smpi_comm_keyvals==nullptr) - smpi_comm_keyvals = xbt_dict_new(); + smpi_comm_keyvals = xbt_dict_new_homogeneous(nullptr); smpi_comm_key_elem value = static_cast(xbt_new0(s_smpi_mpi_comm_key_elem_t,1));