int flags_;
int refcount_ = 1;
std::unique_ptr<Datatype_contents> contents_ = nullptr;
+ MPI_Datatype duplicated_datatype_ = MPI_DATATYPE_NULL;
protected:
template <typename... Args> void set_contents(Args&&... args)
MPI_Aint ub() const { return ub_; }
int flags() const { return flags_; }
int refcount() const { return refcount_; }
+ MPI_Datatype duplicated_datatype() const { return duplicated_datatype_; }
void ref();
static void unref(MPI_Datatype datatype);
}
Datatype::Datatype(Datatype* datatype, int* ret)
- : size_(datatype->size_), lb_(datatype->lb_), ub_(datatype->ub_), flags_(datatype->flags_)
+ : size_(datatype->size_), lb_(datatype->lb_), ub_(datatype->ub_), flags_(datatype->flags_), duplicated_datatype_(datatype)
{
this->add_f();
+ datatype->ref();
*ret = this->copy_attrs(datatype);
}
return;
//prevent further usage
flags_ &= ~ DT_FLAG_COMMITED;
+ if(duplicated_datatype_ != MPI_DATATYPE_NULL)
+ unref(duplicated_datatype_);
F2C::free_f(this->f2c_id());
//if still used, mark for deletion
if(refcount_!=0){