X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d4f3a012fbbb4484ed74c6cec7b5444ffb15f27f..46b56a2fa00e6db1409f4c07c50b50ab726950ed:/src/smpi/smpi_datatype.cpp diff --git a/src/smpi/smpi_datatype.cpp b/src/smpi/smpi_datatype.cpp index 5d39365f41..52ca497300 100644 --- a/src/smpi/smpi_datatype.cpp +++ b/src/smpi/smpi_datatype.cpp @@ -1,5 +1,5 @@ /* smpi_datatype.cpp -- MPI primitives to handle datatypes */ -/* Copyright (c) 2009-2015. The SimGrid Team. +/* Copyright (c) 2009-2017. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -19,7 +19,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_datatype, smpi, "Logging specific to SMPI (datatype)"); #define CREATE_MPI_DATATYPE(name, type) \ - static Datatype mpi_##name ( \ + static simgrid::smpi::Datatype mpi_##name ( \ (char*) # name, \ sizeof(type), /* size */ \ 0, /* lb */ \ @@ -29,7 +29,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_datatype, smpi, "Logging specific to SMPI ( const MPI_Datatype name = &mpi_##name; #define CREATE_MPI_DATATYPE_NULL(name) \ - static Datatype mpi_##name ( \ + static simgrid::smpi::Datatype mpi_##name ( \ (char*) # name, \ 0, /* size */ \ 0, /* lb */ \ @@ -127,10 +127,11 @@ Datatype::Datatype(Datatype *datatype, int* ret) : name_(nullptr), lb_(datatype- *ret = MPI_SUCCESS; if(datatype->name_) name_ = xbt_strdup(datatype->name_); - if(!(datatype->attributes_.empty())){ + + if(!(datatype->attributes()->empty())){ int flag; void* value_out; - for(auto it = datatype->attributes_.begin(); it != datatype->attributes_.end(); it++){ + for(auto it = datatype->attributes()->begin(); it != datatype->attributes()->end(); it++){ smpi_key_elem elem = keyvals_.at((*it).first); if (elem != nullptr && elem->copy_fn.type_copy_fn != MPI_NULL_COPY_FN) { @@ -140,7 +141,7 @@ Datatype::Datatype(Datatype *datatype, int* ret) : name_(nullptr), lb_(datatype- } if (flag){ elem->refcount++; - attributes_.insert({(*it).first, value_out}); + attributes()->insert({(*it).first, value_out}); } } } @@ -159,18 +160,7 @@ Datatype::~Datatype(){ return; } - if(!attributes_.empty()){ - int flag; - for(auto it = attributes_.begin(); it != attributes_.end(); it++){ - try{ - smpi_key_elem elem = keyvals_.at((*it).first); - if (elem != nullptr && elem->delete_fn.type_delete_fn != nullptr) - elem->delete_fn.type_delete_fn(this, (*it).first, (*it).second, &flag); - }catch(const std::out_of_range& oor) { - //already deleted, not a problem; - } - } - } + cleanup_attr(); xbt_free(name_); } @@ -218,6 +208,10 @@ int Datatype::flags(){ return flags_; } +int Datatype::refcount(){ + return refcount_; +} + void Datatype::addflag(int flag){ flags_ &= flag; } @@ -265,7 +259,7 @@ int Datatype::pack(void* inbuf, int incount, void* outbuf, int outcount, int* po } int Datatype::unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount,MPI_Comm comm){ - if (outcount*(int)size_> insize) + if (outcount*static_cast(size_)> insize) return MPI_ERR_BUFFER; Datatype::copy(static_cast(inbuf) + *position, insize, MPI_CHAR, outbuf, outcount, this); *position += outcount * size_; @@ -276,8 +270,15 @@ int Datatype::unpack(void* inbuf, int insize, int* position, void* outbuf, int o int Datatype::copy(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype){ int count; + + if(smpi_is_shared(sendbuf)){ + XBT_DEBUG("Copy input buf %p is shared. Let's ignore it.", sendbuf); + }else if(smpi_is_shared(recvbuf)){ + XBT_DEBUG("Copy output buf %p is shared. Let's ignore it.", recvbuf); + } + if(smpi_privatize_global_variables){ - smpi_switch_data_segment(smpi_process_index()); + smpi_switch_data_segment(smpi_process()->index()); } /* First check if we really have something to do */ if (recvcount > 0 && recvbuf != sendbuf) { @@ -286,7 +287,7 @@ int Datatype::copy(void *sendbuf, int sendcount, MPI_Datatype sendtype, count = sendcount < recvcount ? sendcount : recvcount; if(!(sendtype->flags() & DT_FLAG_DERIVED) && !(recvtype->flags() & DT_FLAG_DERIVED)) { - if(!smpi_process_get_replaying()) + if(!smpi_process()->replaying()) memcpy(recvbuf, sendbuf, count); } else if (!(sendtype->flags() & DT_FLAG_DERIVED))