rbuf, 1, new_rdtype, recvfrom,
COLL_TAG_ALLGATHERV,
comm, MPI_STATUS_IGNORE);
- new_sdtype->unuse();
- new_rdtype->unuse();
+ Datatype::unref(new_sdtype);
+ Datatype::unref(new_rdtype);
}
send_data_from = recv_data_from[i_parity];
- new_sdtype->unuse();
- new_rdtype->unuse();
+ Datatype::unref(new_sdtype);
+ Datatype::unref(new_rdtype);
}
return MPI_SUCCESS;
Request::sendrecv(tmp_buff, position, MPI_PACKED, dst, tag, recv_buff, 1,
new_type, src, tag, comm, &status);
- smpi_datatype_unuse(new_type);
+ Datatype::unref(new_type);
pof2 *= 2;
}
/* Free the requests. */
for (i = 0; i < nreqs; ++i) {
if(ireqs[i]!=MPI_REQUEST_NULL)
- Request::unuse(&ireqs[i]);
+ Request::unref(&ireqs[i]);
}
free(ireqs);
}
}
- sendtype->unuse();
- recvtype->unuse();
+ Datatype::unref(sendtype);
+ Datatype::unref(recvtype);
mask <<= 1;
i++;
Request::startall(size - 1, requests);
Request::waitall(size - 1, requests, MPI_STATUS_IGNORE);
for (int src = 0; src < size-1; src++) {
- Request::unuse(&requests[src]);
+ Request::unref(&requests[src]);
}
xbt_free(requests);
}
Request::startall(size - 1, requests);
Request::waitall(size - 1, requests, MPI_STATUS_IGNORE);
for (int src = 0; src < size-1; src++) {
- Request::unuse(&requests[src]);
+ Request::unref(&requests[src]);
}
xbt_free(requests);
}
Request::startall(2 * (size - 1), requests);
Request::waitall(2 * (size - 1), requests, MPI_STATUS_IGNORE);
for (int other = 0; other < 2*(size-1); other++) {
- Request::unuse(&requests[other]);
+ Request::unref(&requests[other]);
}
xbt_free(requests);
}
Request::startall(2 * (size - 1), requests);
Request::waitall(2 * (size - 1), requests, MPI_STATUS_IGNORE);
for (int other = 0; other < 2*(size-1); other++) {
- Request::unuse(&requests[other]);
+ Request::unref(&requests[other]);
}
xbt_free(requests);
}
Request::startall(size - 1, requests);
Request::waitall(size - 1, requests, MPI_STATUS_IGNORE);
for (int dst = 0; dst < size-1; dst++) {
- Request::unuse(&requests[dst]);
+ Request::unref(&requests[dst]);
}
xbt_free(requests);
}
Request::startall(size - 1, requests);
Request::waitall(size - 1, requests, MPI_STATUS_IGNORE);
for (int dst = 0; dst < size-1; dst++) {
- Request::unuse(&requests[dst]);
+ Request::unref(&requests[dst]);
}
xbt_free(requests);
}
if(index == MPI_UNDEFINED) {
break;
}else{
- Request::unuse(&requests[index]);
+ Request::unref(&requests[index]);
}
if(op) /* op can be MPI_OP_NULL that does nothing */
if(op!=MPI_OP_NULL) op->apply( tmpbufs[index], recvbuf, &count, datatype);
smpi_free_tmp_buffer(tmpbufs[index]);
}
for(index = 0; index < size-1; index++) {
- Request::unuse(&requests[index]);
+ Request::unref(&requests[index]);
}
xbt_free(tmpbufs);
xbt_free(requests);
smpi_free_tmp_buffer(tmpbufs[index]);
}
for(index = 0; index < size-1; index++) {
- Request::unuse(&requests[index]);
+ Request::unref(&requests[index]);
}
xbt_free(tmpbufs);
xbt_free(requests);
Request::waitall(count, requests, MPI_STATUS_IGNORE);
for(i = 0; i < count; i++) {
if(requests[i]!=MPI_REQUEST_NULL)
- Request::unuse(&requests[i]);
+ Request::unref(&requests[i]);
}
xbt_free(requests);
}
Request::waitall(count, requests, MPI_STATUS_IGNORE);
for(i = 0; i < count; i++) {
if(requests[i]!=MPI_REQUEST_NULL)
- Request::unuse(&requests[i]);
+ Request::unref(&requests[i]);
}
xbt_free(requests);
}
Request::waitall(count, requests, MPI_STATUS_IGNORE);
for(i = 0; i < count; i++) {
if(requests[i]!=MPI_REQUEST_NULL)
- Request::unuse(&requests[i]);
+ Request::unref(&requests[i]);
}
xbt_free(requests);
}
MPI_Datatype Datatype::null_id_=MPI_DATATYPE_NULL;
-Datatype::Datatype(int size,MPI_Aint lb, MPI_Aint ub, int flags) : name_(nullptr), size_(size), lb_(lb), ub_(ub), flags_(flags), attributes_(nullptr), in_use_(1){
+Datatype::Datatype(int size,MPI_Aint lb, MPI_Aint ub, int flags) : name_(nullptr), size_(size), lb_(lb), ub_(ub), flags_(flags), attributes_(nullptr), refcount_(1){
#if HAVE_MC
if(MC_is_active())
- MC_ignore(&(in_use_), sizeof(in_use_));
+ MC_ignore(&(refcount_), sizeof(refcount_));
#endif
}
//for predefined types, so in_use = 0.
-Datatype::Datatype(char* name, int size,MPI_Aint lb, MPI_Aint ub, int flags) : name_(name), size_(size), lb_(lb), ub_(ub), flags_(flags), attributes_(nullptr), in_use_(0){
+Datatype::Datatype(char* name, int size,MPI_Aint lb, MPI_Aint ub, int flags) : name_(name), size_(size), lb_(lb), ub_(ub), flags_(flags), attributes_(nullptr), refcount_(0){
#if HAVE_MC
if(MC_is_active())
- MC_ignore(&(in_use_), sizeof(in_use_));
+ MC_ignore(&(refcount_), sizeof(refcount_));
#endif
}
-Datatype::Datatype(Datatype *datatype, int* ret) : name_(nullptr), lb_(datatype->lb_), ub_(datatype->ub_), flags_(datatype->flags_), attributes_(nullptr), in_use_(1)
+Datatype::Datatype(Datatype *datatype, int* ret) : name_(nullptr), lb_(datatype->lb_), ub_(datatype->ub_), flags_(datatype->flags_), attributes_(nullptr), refcount_(1)
{
flags_ &= ~DT_FLAG_PREDEFINED;
*ret = MPI_SUCCESS;
}
Datatype::~Datatype(){
- xbt_assert(in_use_ >= 0);
+ xbt_assert(refcount_ >= 0);
if(flags_ & DT_FLAG_PREDEFINED)
return;
//if still used, mark for deletion
- if(in_use_!=0){
+ if(refcount_!=0){
flags_ |=DT_FLAG_DESTROYED;
return;
}
}
-void Datatype::use(){
+void Datatype::ref(){
- in_use_++;
+ refcount_++;
#if HAVE_MC
if(MC_is_active())
- MC_ignore(&(in_use_), sizeof(in_use_));
+ MC_ignore(&(refcount_), sizeof(refcount_));
#endif
}
-void Datatype::unuse()
+void Datatype::unref(MPI_Datatype datatype)
{
- if (in_use_ > 0)
- in_use_--;
+ if (datatype->refcount_ > 0)
+ datatype->refcount_--;
- if (in_use_ == 0)
- this->~Datatype();
+ if (datatype->refcount_ == 0 && !(datatype->flags_ & DT_FLAG_PREDEFINED))
+ delete datatype;
#if HAVE_MC
if(MC_is_active())
- MC_ignore(&(in_use_), sizeof(in_use_));
+ MC_ignore(&(datatype->refcount_), sizeof(datatype->refcount_));
#endif
}
MPI_Aint ub_;
int flags_;
xbt_dict_t attributes_;
- int in_use_;
+ int refcount_;
public:
static MPI_Datatype null_id_;
Datatype(char* name, int size,MPI_Aint lb, MPI_Aint ub, int flags);
Datatype(Datatype *datatype, int* ret);
virtual ~Datatype();
- void use();
- void unuse();
+ void ref();
+ static void unref(MPI_Datatype datatype);
void commit();
bool is_valid();
size_t size();
Type_Contiguous::Type_Contiguous(int size, MPI_Aint lb, MPI_Aint ub, int flags, int block_count, MPI_Datatype old_type): Datatype(size, lb, ub, flags), block_count_(block_count), old_type_(old_type){
- old_type_->use();
+ old_type_->ref();
}
Type_Contiguous::~Type_Contiguous(){
- old_type_->unuse();
+ Datatype::unref(old_type_);
}
-void Type_Contiguous::use(){
- old_type_->use();
+void Type_Contiguous::ref(){
+ old_type_->ref();
};
void Type_Contiguous::serialize( void* noncontiguous_buf, void *contiguous_buf,
Type_Vector::Type_Vector(int size,MPI_Aint lb, MPI_Aint ub, int flags, int count, int block_length, int stride, MPI_Datatype old_type): Datatype(size, lb, ub, flags), block_count_(count), block_length_(block_length),block_stride_(stride), old_type_(old_type){
-old_type_->use();
+ old_type_->ref();
}
Type_Vector::~Type_Vector(){
- old_type_->unuse();
+ Datatype::unref(old_type_);
}
-void Type_Vector::use(){
- old_type_->use();
+void Type_Vector::ref(){
+ old_type_->ref();
}
}
Type_Hvector::Type_Hvector(int size,MPI_Aint lb, MPI_Aint ub, int flags, int count, int block_length, MPI_Aint stride, MPI_Datatype old_type): Datatype(size, lb, ub, flags), block_count_(count), block_length_(block_length), block_stride_(stride), old_type_(old_type){
- old_type->use();
+ old_type->ref();
}
Type_Hvector::~Type_Hvector(){
- old_type_->unuse();
+ Datatype::unref(old_type_);
}
-void Type_Hvector::use(){
- old_type_->use();
+void Type_Hvector::ref(){
+ old_type_->ref();
}
void Type_Hvector::serialize( void* noncontiguous_buf, void *contiguous_buf,
}
Type_Indexed::Type_Indexed(int size,MPI_Aint lb, MPI_Aint ub, int flags, int count, int* block_lengths, int* block_indices, MPI_Datatype old_type): Datatype(size, lb, ub, flags), block_count_(count), old_type_(old_type){
- old_type->use();
+ old_type->ref();
block_lengths_ = new int[count];
block_indices_ = new int[count];
for (int i = 0; i < count; i++) {
}
Type_Indexed::~Type_Indexed(){
- old_type_->unuse();
- if(in_use_==0){
+ Datatype::unref(old_type_);
+ if(refcount_==0){
delete[] block_lengths_;
delete[] block_indices_;
}
}
-void Type_Indexed::use(){
- old_type_->use();
+void Type_Indexed::ref(){
+ old_type_->ref();
}
void Type_Indexed::serialize( void* noncontiguous_buf, void *contiguous_buf,
Type_Hindexed::Type_Hindexed(int size,MPI_Aint lb, MPI_Aint ub, int flags, int count, int* block_lengths, MPI_Aint* block_indices, MPI_Datatype old_type)
: Datatype(size, lb, ub, flags), block_count_(count), old_type_(old_type)
{
- old_type_->use();
+ old_type_->ref();
block_lengths_ = new int[count];
block_indices_ = new MPI_Aint[count];
for (int i = 0; i < count; i++) {
}
Type_Hindexed::~Type_Hindexed(){
- old_type_->unuse();
- if(in_use_==0){
+ Datatype::unref(old_type_);
+ if(refcount_==0){
delete[] block_lengths_;
delete[] block_indices_;
}
}
-void Type_Hindexed::use(){
- old_type_->use();
+void Type_Hindexed::ref(){
+ old_type_->ref();
}
void Type_Hindexed::serialize( void* noncontiguous_buf, void *contiguous_buf,
int count){
block_lengths_[i]=block_lengths[i];
block_indices_[i]=block_indices[i];
old_types_[i]=old_types[i];
- old_types_[i]->use();
+ old_types_[i]->ref();
}
}
Type_Struct::~Type_Struct(){
for (int i = 0; i < block_count_; i++) {
- old_types_[i]->unuse();
+ Datatype::unref(old_types_[i]);
}
- if(in_use_==0){
+ if(refcount_==0){
delete[] block_lengths_;
delete[] block_indices_;
delete[] old_types_;
}
}
-void Type_Struct::use(){
+void Type_Struct::ref(){
for (int i = 0; i < block_count_; i++) {
- old_types_[i]->use();
+ old_types_[i]->ref();
}
}
public:
Type_Contiguous(int size, MPI_Aint lb, MPI_Aint ub, int flags, int block_count, MPI_Datatype old_type);
~Type_Contiguous();
- void use();
+ void ref();
void serialize( void* noncontiguous, void *contiguous,
int count);
void unserialize( void* contiguous_vector, void *noncontiguous_vector,
public:
Type_Vector(int size,MPI_Aint lb, MPI_Aint ub, int flags, int count, int blocklen, int stride, MPI_Datatype old_type);
~Type_Vector();
- void use();
+ void ref();
void serialize( void* noncontiguous, void *contiguous,
int count);
void unserialize( void* contiguous_vector, void *noncontiguous_vector,
public:
Type_Hvector(int size,MPI_Aint lb, MPI_Aint ub, int flags, int block_count, int block_length, MPI_Aint block_stride, MPI_Datatype old_type);
~Type_Hvector();
- void use();
+ void ref();
void serialize( void* noncontiguous, void *contiguous,
int count);
void unserialize( void* contiguous_vector, void *noncontiguous_vector,
public:
Type_Indexed(int size,MPI_Aint lb, MPI_Aint ub, int flags, int block_count, int* block_lengths, int* block_indices, MPI_Datatype old_type);
~Type_Indexed();
- void use();
+ void ref();
void serialize( void* noncontiguous, void *contiguous,
int count);
void unserialize( void* contiguous_vector, void *noncontiguous_vector,
public:
Type_Hindexed(int size,MPI_Aint lb, MPI_Aint ub, int flags, int block_count, int* block_lengths, MPI_Aint* block_indices, MPI_Datatype old_type);
~Type_Hindexed();
- void use();
+ void ref();
void serialize( void* noncontiguous, void *contiguous,
int count);
void unserialize( void* contiguous_vector, void *noncontiguous_vector,
public:
Type_Struct(int size,MPI_Aint lb, MPI_Aint ub, int flags, int block_count, int* block_lengths, MPI_Aint* block_indices, MPI_Datatype* old_types);
~Type_Struct();
- void use();
+ void ref();
void serialize( void* noncontiguous, void *contiguous,
int count);
void unserialize( void* contiguous_vector, void *noncontiguous_vector,
if (*datatype == MPI_DATATYPE_NULL) {
return MPI_ERR_ARG;
} else {
- (*datatype)->unuse();
+ Datatype::unref(*datatype);
return MPI_SUCCESS;
}
}
*newtype = new Datatype(datatype, &retval);
//error when duplicating, free the new datatype
if(retval!=MPI_SUCCESS){
- (*newtype)->unuse();
+ Datatype::unref(*newtype);
*newtype = MPI_DATATYPE_NULL;
}
}
if (*request == MPI_REQUEST_NULL) {
retval = MPI_ERR_ARG;
} else {
- Request::unuse(request);
+ Request::unref(request);
retval = MPI_SUCCESS;
}
smpi_bench_begin();
// This part handles the problem of non-contiguous memory (for the unserialisation at the reception)
old_buf_ = old_buf;
size_ = datatype->size() * count;
- datatype->use();
+ datatype->ref();
comm_->ref();
action_ = nullptr;
detached_ = 0;
}
-void Request::unuse(MPI_Request* request)
+void Request::unref(MPI_Request* request)
{
if((*request) != MPI_REQUEST_NULL){
(*request)->refcount_--;
if((*request)->refcount_<0) xbt_die("wrong refcount");
if((*request)->refcount_==0){
- (*request)->old_type_->unuse();
+ Datatype::unref((*request)->old_type_);
Comm::unref((*request)->comm_);
(*request)->print_request("Destroying");
delete *request;
requests[1] = irecv_init(recvbuf, recvcount, recvtype, src, recvtag, comm);
startall(2, requests);
waitall(2, requests, stats);
- unuse(&requests[0]);
- unuse(&requests[1]);
+ unref(&requests[0]);
+ unref(&requests[1]);
if(status != MPI_STATUS_IGNORE) {
// Copy receive status
*status = stats[1];
if (xbt_cfg_get_boolean("smpi/grow-injected-times"))
nsleeps++;
}
- unuse(&request);
+ unref(&request);
}
simcall_process_sleep(sleeptime);
XBT_DEBUG("receiving size of %zu : sleep %f ", req->real_size_, sleeptime);
}
- unuse(&(req->detached_sender_));
+ unref(&(req->detached_sender_));
}
if(req->flags_ & PERSISTENT)
req->action_ = nullptr;
req->flags_ |= FINISHED;
- unuse(request);
+ unref(request);
}
void start();
static void finish_wait(MPI_Request* request, MPI_Status * status);
- static void unuse(MPI_Request* request);
+ static void unref(MPI_Request* request);
static void wait(MPI_Request* req, MPI_Status * status);
static MPI_Request send_init(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
static MPI_Request isend_init(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
Request::startall(size, reqs);
Request::waitall(size, reqs, MPI_STATUSES_IGNORE);
for(i=0;i<size;i++){
- Request::unuse(&reqs[i]);
+ Request::unref(&reqs[i]);
}
xbt_free(reqs);
opened_++; //we're open for business !
Request::startall(size, reqs);
Request::waitall(size, reqs, MPI_STATUSES_IGNORE);
for(i=0;i<size;i++){
- Request::unuse(&reqs[i]);
+ Request::unref(&reqs[i]);
}
xbt_free(reqs);
opened_++; //we're open for business !
Request::waitall(size, reqs, MPI_STATUSES_IGNORE);
for(i=0;i<size;i++){
- Request::unuse(&reqs[i]);
+ Request::unref(&reqs[i]);
}
xbt_free(reqs);
Request::startall(size, reqs);
Request::waitall(size, reqs, MPI_STATUSES_IGNORE);
for(i=0;i<size;i++){
- Request::unuse(&reqs[i]);
+ Request::unref(&reqs[i]);
}
xbt_free(reqs);
xbt_mutex_acquire(mut_);