Try to switch to a shared_ptr to avoid segfaults or leaks...
if (*comm_cart == MPI_COMM_NULL) {
delete topo;
} else {
if (*comm_cart == MPI_COMM_NULL) {
delete topo;
} else {
- xbt_assert((*comm_cart)->topo() == topo);
+ xbt_assert((*comm_cart)->topo().get() == topo);
CHECK_COMM(1)
CHECK_NULL(1, MPI_ERR_TOPOLOGY, comm->topo())
CHECK_NULL(2, MPI_SUCCESS, coords)
CHECK_COMM(1)
CHECK_NULL(1, MPI_ERR_TOPOLOGY, comm->topo())
CHECK_NULL(2, MPI_SUCCESS, coords)
- MPIR_Cart_Topology topo = static_cast<MPIR_Cart_Topology>(comm->topo());
+ MPIR_Cart_Topology topo = static_cast<MPIR_Cart_Topology>(comm->topo().get());
if (topo==nullptr) {
return MPI_ERR_ARG;
}
if (topo==nullptr) {
return MPI_ERR_ARG;
}
CHECK_NEGATIVE(3, MPI_ERR_ARG, direction)
CHECK_NULL(4, MPI_ERR_ARG, source)
CHECK_NULL(5, MPI_ERR_ARG, dest)
CHECK_NEGATIVE(3, MPI_ERR_ARG, direction)
CHECK_NULL(4, MPI_ERR_ARG, source)
CHECK_NULL(5, MPI_ERR_ARG, dest)
- MPIR_Cart_Topology topo = static_cast<MPIR_Cart_Topology>(comm->topo());
+ MPIR_Cart_Topology topo = static_cast<MPIR_Cart_Topology>(comm->topo().get());
if (topo==nullptr) {
return MPI_ERR_ARG;
}
if (topo==nullptr) {
return MPI_ERR_ARG;
}
if(maxdims==0 || coords == nullptr) {
return MPI_SUCCESS;
}
if(maxdims==0 || coords == nullptr) {
return MPI_SUCCESS;
}
- MPIR_Cart_Topology topo = static_cast<MPIR_Cart_Topology>(comm->topo());
+ MPIR_Cart_Topology topo = static_cast<MPIR_Cart_Topology>(comm->topo().get());
if (topo==nullptr) {
return MPI_ERR_ARG;
}
if (topo==nullptr) {
return MPI_ERR_ARG;
}
CHECK_COMM(1)
CHECK_NULL(1, MPI_ERR_TOPOLOGY, comm->topo())
CHECK_NEGATIVE(3, MPI_ERR_ARG, maxdims)
CHECK_COMM(1)
CHECK_NULL(1, MPI_ERR_TOPOLOGY, comm->topo())
CHECK_NEGATIVE(3, MPI_ERR_ARG, maxdims)
- MPIR_Cart_Topology topo = static_cast<MPIR_Cart_Topology>(comm->topo());
+ MPIR_Cart_Topology topo = static_cast<MPIR_Cart_Topology>(comm->topo().get());
if (topo==nullptr) {
return MPI_ERR_ARG;
}
if (topo==nullptr) {
return MPI_ERR_ARG;
}
CHECK_COMM(1)
CHECK_NULL(1, MPI_ERR_TOPOLOGY, comm->topo())
CHECK_NULL(2, MPI_ERR_ARG, ndims)
CHECK_COMM(1)
CHECK_NULL(1, MPI_ERR_TOPOLOGY, comm->topo())
CHECK_NULL(2, MPI_ERR_ARG, ndims)
- MPIR_Cart_Topology topo = static_cast<MPIR_Cart_Topology>(comm->topo());
+ MPIR_Cart_Topology topo = static_cast<MPIR_Cart_Topology>(comm->topo().get());
if (topo==nullptr) {
return MPI_ERR_ARG;
}
if (topo==nullptr) {
return MPI_ERR_ARG;
}
CHECK_COMM(1)
CHECK_NULL(1, MPI_ERR_TOPOLOGY, comm->topo())
CHECK_NULL(3, MPI_ERR_ARG, comm_new)
CHECK_COMM(1)
CHECK_NULL(1, MPI_ERR_TOPOLOGY, comm->topo())
CHECK_NULL(3, MPI_ERR_ARG, comm_new)
- MPIR_Cart_Topology topo = static_cast<MPIR_Cart_Topology>(comm->topo());
+ MPIR_Cart_Topology topo = static_cast<MPIR_Cart_Topology>(comm->topo().get());
if (topo==nullptr) {
return MPI_ERR_ARG;
}
if (topo==nullptr) {
return MPI_ERR_ARG;
}
#include <list>
#include <string>
#include <list>
#include <string>
#include "smpi_errhandler.hpp"
#include "smpi_keyvals.hpp"
#include "smpi_group.hpp"
#include "smpi_errhandler.hpp"
#include "smpi_keyvals.hpp"
#include "smpi_group.hpp"
friend Topo;
MPI_Group group_;
SMPI_Topo_type topoType_ = MPI_INVALID_TOPO;
friend Topo;
MPI_Group group_;
SMPI_Topo_type topoType_ = MPI_INVALID_TOPO;
- MPI_Topology topo_; // to be replaced by an union
+ std::shared_ptr<Topo> topo_; // to be replaced by an union
int refcount_ = 1;
MPI_Comm leaders_comm_ = MPI_COMM_NULL; // inter-node communicator
MPI_Comm intra_comm_ = MPI_COMM_NULL; // intra-node communicator. For MPI_COMM_WORLD this can't be used, as var is
int refcount_ = 1;
MPI_Comm leaders_comm_ = MPI_COMM_NULL; // inter-node communicator
MPI_Comm intra_comm_ = MPI_COMM_NULL; // intra-node communicator. For MPI_COMM_WORLD this can't be used, as var is
int dup_with_info(MPI_Info info, MPI_Comm* newcomm);
MPI_Group group();
MPI_Topology topo() { return topo_; }
int dup_with_info(MPI_Info info, MPI_Comm* newcomm);
MPI_Group group();
MPI_Topology topo() { return topo_; }
+ void set_topo(MPI_Topology topo){topo_=topo;}
int size();
int rank();
int id();
int size();
int rank();
int id();
#include "smpi_comm.hpp"
#include "smpi_status.hpp"
#include "smpi_comm.hpp"
#include "smpi_status.hpp"
-typedef SMPI_Topology *MPI_Topology;
+typedef std::shared_ptr<SMPI_Topology> MPI_Topology;
namespace simgrid{
namespace smpi{
namespace simgrid{
namespace smpi{
Request::recv(&group_out, 1, MPI_PTR, 0, system_tag, this, MPI_STATUS_IGNORE);
} /* otherwise, exit with group_out == nullptr */
}
Request::recv(&group_out, 1, MPI_PTR, 0, system_tag, this, MPI_STATUS_IGNORE);
} /* otherwise, exit with group_out == nullptr */
}
- return group_out!=nullptr ? new Comm(group_out, nullptr) : MPI_COMM_NULL;
+ return group_out!=nullptr ? new Comm(group_out, topo_) : MPI_COMM_NULL;
simgrid::smpi::Info::unref(comm->info_);
if (comm->errhandler_ != MPI_ERRHANDLER_NULL)
simgrid::smpi::Errhandler::unref(comm->errhandler_);
simgrid::smpi::Info::unref(comm->info_);
if (comm->errhandler_ != MPI_ERRHANDLER_NULL)
simgrid::smpi::Errhandler::unref(comm->errhandler_);
- delete comm->topo_; // there's no use count on topos
{
xbt_assert(not comm_);
comm_ = comm;
{
xbt_assert(not comm_);
comm_ = comm;
- if (comm_)
- comm_->topo_ = this;
}
/*******************************************************************************
}
/*******************************************************************************
for (int i = 0 ; i < newSize ; i++) {
newGroup->set_mapping(oldGroup->actor(i), i);
}
for (int i = 0 ; i < newSize ; i++) {
newGroup->set_mapping(oldGroup->actor(i), i);
}
- *comm_cart = new Comm(newGroup, this);
+ *comm_cart = new Comm(newGroup, std::shared_ptr<Topo>(this));
}
} else {
if(comm_cart != nullptr){
if (rank == 0) {
MPI_Group group = new Group(MPI_COMM_SELF->group());
}
} else {
if(comm_cart != nullptr){
if (rank == 0) {
MPI_Group group = new Group(MPI_COMM_SELF->group());
- *comm_cart = new Comm(group, this);
+ *comm_cart = new Comm(group, std::shared_ptr<Topo>(this));
} else {
*comm_cart = MPI_COMM_NULL;
}
}
}
} else {
*comm_cart = MPI_COMM_NULL;
}
}
}
- if(comm_cart != nullptr)
+ if(comm_cart != nullptr){
}
Topo_Cart* Topo_Cart::sub(const int remain_dims[], MPI_Comm *newcomm) {
}
Topo_Cart* Topo_Cart::sub(const int remain_dims[], MPI_Comm *newcomm) {
} else {
*newcomm = getComm()->split(color, getComm()->rank());
res = new Topo_Cart(getComm(), newNDims, newDims, newPeriodic, 0, nullptr);
} else {
*newcomm = getComm()->split(color, getComm()->rank());
res = new Topo_Cart(getComm(), newNDims, newDims, newPeriodic, 0, nullptr);
+ std::shared_ptr<Topo> topo=std::shared_ptr<Topo>(res);
+ (*newcomm)->set_topo(topo);
}
delete[] newDims;
delete[] newPeriodic;
}
delete[] newDims;
delete[] newPeriodic;