- //todo: faire en sorte que ça fonctionne avec un communicator dupliqué (refaire un init_smp ?)
-
- /* MPI_Comm tmp=smpi_comm_get_intra_comm(comm);
- if( tmp != MPI_COMM_NULL)
- smpi_comm_set_intra_comm((*newcomm), smpi_comm_dup(tmp));
- tmp=smpi_comm_get_leaders_comm(comm);
- if( tmp != MPI_COMM_NULL)
- smpi_comm_set_leaders_comm((*newcomm), smpi_comm_dup(tmp));
- if(comm->non_uniform_map !=NULL){
- (*newcomm)->non_uniform_map=
- xbt_malloc(smpi_comm_size(comm->leaders_comm)*sizeof(int));
- memcpy((*newcomm)->non_uniform_map,
- comm->non_uniform_map,smpi_comm_size(comm->leaders_comm)*sizeof(int) );
- }
- if(comm->leaders_map !=NULL){
- (*newcomm)->leaders_map=xbt_malloc(smpi_comm_size(comm)*sizeof(int));
- memcpy((*newcomm)->leaders_map,
- comm->leaders_map,smpi_comm_size(comm)*sizeof(int) );
- }*/
- if(comm->attributes !=NULL){
- (*newcomm)->attributes=xbt_dict_new();
- xbt_dict_cursor_t cursor = NULL;
- 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<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals, (const char*)key, sizeof(int)));
- if(elem && elem->copy_fn!=MPI_NULL_COPY_FN){
- ret = elem->copy_fn(comm, *key, NULL, 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, (const char*)key, sizeof(int),value_out, NULL);
+
+ if(!attributes()->empty()){
+ int flag;
+ void* value_out;
+ for(auto it : *attributes()){
+ smpi_key_elem elem = keyvals_.at(it.first);
+ if (elem != nullptr && elem->copy_fn.comm_copy_fn != MPI_NULL_COPY_FN) {
+ ret = elem->copy_fn.comm_copy_fn(this, it.first, nullptr, it.second, &value_out, &flag);
+ if (ret != MPI_SUCCESS) {
+ Comm::destroy(*newcomm);
+ *newcomm = MPI_COMM_NULL;
+ return ret;
+ }
+ if (flag){
+ elem->refcount++;
+ (*newcomm)->attributes()->insert({it.first, value_out});