const s_smpi_key_elem_t* elem = T::keyvals_.at(keyval);
if(elem==nullptr)
return MPI_ERR_ARG;
- if(attributes()->empty()){
- *flag=0;
- return MPI_SUCCESS;
- }
+
const auto& attribs = attributes();
auto attr = attribs->find(keyval);
if (attr != attribs->end()) {
}
template <typename T> void Keyval::cleanup_attr(){
- if (not attributes()->empty()) {
- int flag=0;
- for (auto const& it : attributes_) {
- auto elm = T::keyvals_.find(it.first);
- if (elm != T::keyvals_.end()) {
- smpi_key_elem elem = elm->second;
- if(elem != nullptr){
- call_deleter<T>((T*)this, elem, it.first,it.second,&flag);
- }
- } else {
- // already deleted, not a problem
- flag=0;
+ int flag = 0;
+ for (auto const& it : attributes_) {
+ auto elm = T::keyvals_.find(it.first);
+ if (elm != T::keyvals_.end()) {
+ smpi_key_elem elem = elm->second;
+ if (elem != nullptr) {
+ call_deleter<T>((T*)this, elem, it.first, it.second, &flag);
}
+ } else {
+ // already deleted, not a problem
+ flag = 0;
}
}
}
(*newcomm) = new Comm(cp, this->topo());
int ret = MPI_SUCCESS;
- if (not attributes()->empty()) {
- int flag=0;
- void* value_out=nullptr;
- for (auto const& it : *attributes()) {
- smpi_key_elem elem = keyvals_.at(it.first);
- if (elem != nullptr){
- if( elem->copy_fn.comm_copy_fn != MPI_NULL_COPY_FN &&
- elem->copy_fn.comm_copy_fn != MPI_COMM_DUP_FN)
- ret = elem->copy_fn.comm_copy_fn(this, it.first, elem->extra_state, it.second, &value_out, &flag);
- else if ( elem->copy_fn.comm_copy_fn_fort != MPI_NULL_COPY_FN &&
- *(int*)*elem->copy_fn.comm_copy_fn_fort != 1){
- value_out=(int*)xbt_malloc(sizeof(int));
- elem->copy_fn.comm_copy_fn_fort(this, it.first, elem->extra_state, it.second, value_out, &flag,&ret);
- }
- if (ret != MPI_SUCCESS) {
- Comm::destroy(*newcomm);
- *newcomm = MPI_COMM_NULL;
- return ret;
- }
- if (elem->copy_fn.comm_copy_fn == MPI_COMM_DUP_FN ||
- ((elem->copy_fn.comm_copy_fn_fort != MPI_NULL_COPY_FN) && *(int*)*elem->copy_fn.comm_copy_fn_fort == 1)){
- elem->refcount++;
- (*newcomm)->attributes()->insert({it.first, it.second});
- }else if (flag){
- elem->refcount++;
- (*newcomm)->attributes()->insert({it.first, value_out});
- }
+ for (auto const& it : *attributes()) {
+ smpi_key_elem elem = keyvals_.at(it.first);
+ if (elem != nullptr) {
+ int flag = 0;
+ void* value_out = nullptr;
+ if (elem->copy_fn.comm_copy_fn != MPI_NULL_COPY_FN && elem->copy_fn.comm_copy_fn != MPI_COMM_DUP_FN)
+ ret = elem->copy_fn.comm_copy_fn(this, it.first, elem->extra_state, it.second, &value_out, &flag);
+ else if (elem->copy_fn.comm_copy_fn_fort != MPI_NULL_COPY_FN && *(int*)*elem->copy_fn.comm_copy_fn_fort != 1) {
+ value_out = (int*)xbt_malloc(sizeof(int));
+ elem->copy_fn.comm_copy_fn_fort(this, it.first, elem->extra_state, it.second, value_out, &flag, &ret);
+ }
+ if (ret != MPI_SUCCESS) {
+ Comm::destroy(*newcomm);
+ *newcomm = MPI_COMM_NULL;
+ return ret;
+ }
+ if (elem->copy_fn.comm_copy_fn == MPI_COMM_DUP_FN ||
+ ((elem->copy_fn.comm_copy_fn_fort != MPI_NULL_COPY_FN) && *(int*)*elem->copy_fn.comm_copy_fn_fort == 1)) {
+ elem->refcount++;
+ (*newcomm)->attributes()->insert({it.first, it.second});
+ } else if (flag) {
+ elem->refcount++;
+ (*newcomm)->attributes()->insert({it.first, value_out});
}
}
}
int Datatype::copy_attrs(Datatype* datatype){
flags_ &= ~DT_FLAG_PREDEFINED;
int ret = MPI_SUCCESS;
-
- if (not datatype->attributes()->empty()) {
- int flag=0;
- void* value_out;
- for (auto const& it : *(datatype->attributes())) {
- smpi_key_elem elem = keyvals_.at(it.first);
- if (elem != nullptr){
- if( elem->copy_fn.type_copy_fn != MPI_NULL_COPY_FN &&
- elem->copy_fn.type_copy_fn != MPI_TYPE_DUP_FN)
- ret = elem->copy_fn.type_copy_fn(datatype, it.first, elem->extra_state, it.second, &value_out, &flag);
- else if ( elem->copy_fn.type_copy_fn_fort != MPI_NULL_COPY_FN &&
- (*(int*)*elem->copy_fn.type_copy_fn_fort) != 1){
- value_out=(int*)xbt_malloc(sizeof(int));
- elem->copy_fn.type_copy_fn_fort(datatype, it.first, elem->extra_state, it.second, value_out, &flag, &ret);
- }
- if (ret != MPI_SUCCESS) {
- break;
- }
- if(elem->copy_fn.type_copy_fn == MPI_TYPE_DUP_FN ||
- ((elem->copy_fn.type_copy_fn_fort != MPI_NULL_COPY_FN) && (*(int*)*elem->copy_fn.type_copy_fn_fort == 1))){
- elem->refcount++;
- attributes()->insert({it.first, it.second});
- } else if (flag){
- elem->refcount++;
- attributes()->insert({it.first, value_out});
- }
+
+ for (auto const& it : *(datatype->attributes())) {
+ smpi_key_elem elem = keyvals_.at(it.first);
+ if (elem != nullptr) {
+ int flag = 0;
+ void* value_out;
+ if (elem->copy_fn.type_copy_fn != MPI_NULL_COPY_FN && elem->copy_fn.type_copy_fn != MPI_TYPE_DUP_FN)
+ ret = elem->copy_fn.type_copy_fn(datatype, it.first, elem->extra_state, it.second, &value_out, &flag);
+ else if (elem->copy_fn.type_copy_fn_fort != MPI_NULL_COPY_FN && (*(int*)*elem->copy_fn.type_copy_fn_fort) != 1) {
+ value_out = (int*)xbt_malloc(sizeof(int));
+ elem->copy_fn.type_copy_fn_fort(datatype, it.first, elem->extra_state, it.second, value_out, &flag, &ret);
+ }
+ if (ret != MPI_SUCCESS) {
+ break;
+ }
+ if (elem->copy_fn.type_copy_fn == MPI_TYPE_DUP_FN ||
+ ((elem->copy_fn.type_copy_fn_fort != MPI_NULL_COPY_FN) && (*(int*)*elem->copy_fn.type_copy_fn_fort == 1))) {
+ elem->refcount++;
+ attributes()->insert({it.first, it.second});
+ } else if (flag) {
+ elem->refcount++;
+ attributes()->insert({it.first, value_out});
}
}
}