-int smpi_comm_attr_put(MPI_Comm comm, int keyval, void* attr_value){
- if(smpi_comm_keyvals==nullptr)
- smpi_comm_keyvals = xbt_dict_new_homogeneous(nullptr);
- smpi_comm_key_elem elem =
- static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast<const char*>(&keyval), sizeof(int)));
- if(elem==nullptr)
- return MPI_ERR_ARG;
- int flag;
- 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);
- if(ret!=MPI_SUCCESS)
- return ret;
- }
- if(comm->attributes==nullptr)
- comm->attributes = xbt_dict_new_homogeneous(nullptr);