MPI_DATATYPE_NULL may be passed to the encode function and we hence
need to check if the argument is null; if we just call
dt->encode(), we would always have to check before that call if dt is nullptr
This way, we just call Datatype::encode(dt)
void commit();
bool is_valid();
bool is_basic();
void commit();
bool is_valid();
bool is_basic();
+ static const char* encode(MPI_Datatype dt);
static MPI_Datatype decode(const char* const datatype_id);
bool is_replayable();
void addflag(int flag);
static MPI_Datatype decode(const char* const datatype_id);
bool is_replayable();
void addflag(int flag);
return xbt_str_parse_double(string.c_str(), "%s is not a double");
}
return xbt_str_parse_double(string.c_str(), "%s is not a double");
}
//TODO: this logic should be moved inside the datatype class, to support all predefined types and get rid of is_replayable.
static MPI_Datatype decode_datatype(std::string action)
{
//TODO: this logic should be moved inside the datatype class, to support all predefined types and get rid of is_replayable.
static MPI_Datatype decode_datatype(std::string action)
{
const char* encode_datatype(MPI_Datatype datatype)
{
const char* encode_datatype(MPI_Datatype datatype)
{
- if (datatype == nullptr) /* this actually does seem to be possible, had this in the scatter2 test */
+ if (datatype == MPI_DATATYPE_NULL)
-
- return datatype->encode();
+ return simgrid::smpi::Datatype::encode(datatype);
int dst_traced = MPI_COMM_WORLD->group()->actor(to)->getPid();
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
int dst_traced = MPI_COMM_WORLD->group()->actor(to)->getPid();
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
- new simgrid::instr::Pt2PtTIData("send", to, size, MPI_CURRENT_TYPE->encode()));
+ new simgrid::instr::Pt2PtTIData("send", to, size, Datatype::encode(MPI_CURRENT_TYPE)));
if (not TRACE_smpi_view_internals())
TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, 0, size * MPI_CURRENT_TYPE->size());
if (not TRACE_smpi_view_internals())
TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, 0, size * MPI_CURRENT_TYPE->size());
int my_proc_id = Actor::self()->getPid();
int dst_traced = MPI_COMM_WORLD->group()->actor(to)->getPid();
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
int my_proc_id = Actor::self()->getPid();
int dst_traced = MPI_COMM_WORLD->group()->actor(to)->getPid();
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
- new simgrid::instr::Pt2PtTIData("Isend", to, size, MPI_CURRENT_TYPE->encode()));
+ new simgrid::instr::Pt2PtTIData("Isend", to, size, Datatype::encode(MPI_CURRENT_TYPE)));
if (not TRACE_smpi_view_internals())
TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, 0, size * MPI_CURRENT_TYPE->size());
if (not TRACE_smpi_view_internals())
TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, 0, size * MPI_CURRENT_TYPE->size());
int src_traced = MPI_COMM_WORLD->group()->actor(from)->getPid();
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
int src_traced = MPI_COMM_WORLD->group()->actor(from)->getPid();
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
- new simgrid::instr::Pt2PtTIData("recv", from, size, MPI_CURRENT_TYPE->encode()));
+ new simgrid::instr::Pt2PtTIData("recv", from, size, Datatype::encode(MPI_CURRENT_TYPE)));
//unknown size from the receiver point of view
if (size <= 0.0) {
//unknown size from the receiver point of view
if (size <= 0.0) {
int my_proc_id = Actor::self()->getPid();
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
int my_proc_id = Actor::self()->getPid();
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
- new simgrid::instr::Pt2PtTIData("Irecv", from, size, MPI_CURRENT_TYPE->encode()));
+ new simgrid::instr::Pt2PtTIData("Irecv", from, size, Datatype::encode(MPI_CURRENT_TYPE)));
MPI_Status status;
//unknow size from the receiver pov
if (size <= 0.0) {
MPI_Status status;
//unknow size from the receiver pov
if (size <= 0.0) {
int my_proc_id = Actor::self()->getPid();
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
new simgrid::instr::CollTIData("bcast", MPI_COMM_WORLD->group()->actor(root)->getPid(), -1.0, size,
int my_proc_id = Actor::self()->getPid();
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
new simgrid::instr::CollTIData("bcast", MPI_COMM_WORLD->group()->actor(root)->getPid(), -1.0, size,
- -1, MPI_CURRENT_TYPE->encode(), ""));
+ -1, Datatype::encode(MPI_CURRENT_TYPE), ""));
void *sendbuf = smpi_get_tmp_sendbuffer(size* MPI_CURRENT_TYPE->size());
void *sendbuf = smpi_get_tmp_sendbuffer(size* MPI_CURRENT_TYPE->size());
int my_proc_id = Actor::self()->getPid();
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
new simgrid::instr::CollTIData("reduce", MPI_COMM_WORLD->group()->actor(root)->getPid(), comp_size,
int my_proc_id = Actor::self()->getPid();
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
new simgrid::instr::CollTIData("reduce", MPI_COMM_WORLD->group()->actor(root)->getPid(), comp_size,
- comm_size, -1, MPI_CURRENT_TYPE->encode(), ""));
+ comm_size, -1, Datatype::encode(MPI_CURRENT_TYPE), ""));
void *recvbuf = smpi_get_tmp_sendbuffer(comm_size* MPI_CURRENT_TYPE->size());
void *sendbuf = smpi_get_tmp_sendbuffer(comm_size* MPI_CURRENT_TYPE->size());
void *recvbuf = smpi_get_tmp_sendbuffer(comm_size* MPI_CURRENT_TYPE->size());
void *sendbuf = smpi_get_tmp_sendbuffer(comm_size* MPI_CURRENT_TYPE->size());
double clock = smpi_process()->simulated_elapsed();
int my_proc_id = Actor::self()->getPid();
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::CollTIData("allReduce", -1, comp_size, comm_size, -1,
double clock = smpi_process()->simulated_elapsed();
int my_proc_id = Actor::self()->getPid();
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::CollTIData("allReduce", -1, comp_size, comm_size, -1,
- MPI_CURRENT_TYPE->encode(), ""));
+ Datatype::encode(MPI_CURRENT_TYPE), ""));
void *recvbuf = smpi_get_tmp_recvbuffer(comm_size* MPI_CURRENT_TYPE->size());
void *sendbuf = smpi_get_tmp_sendbuffer(comm_size* MPI_CURRENT_TYPE->size());
void *recvbuf = smpi_get_tmp_recvbuffer(comm_size* MPI_CURRENT_TYPE->size());
void *sendbuf = smpi_get_tmp_sendbuffer(comm_size* MPI_CURRENT_TYPE->size());
int my_proc_id = Actor::self()->getPid();
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
new simgrid::instr::CollTIData("allToAll", -1, -1.0, send_size, recv_size,
int my_proc_id = Actor::self()->getPid();
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
new simgrid::instr::CollTIData("allToAll", -1, -1.0, send_size, recv_size,
- MPI_CURRENT_TYPE->encode(), MPI_CURRENT_TYPE2->encode()));
+ Datatype::encode(MPI_CURRENT_TYPE),
+ Datatype::encode(MPI_CURRENT_TYPE2)));
Colls::alltoall(send, send_size, MPI_CURRENT_TYPE, recv, recv_size, MPI_CURRENT_TYPE2, MPI_COMM_WORLD);
Colls::alltoall(send, send_size, MPI_CURRENT_TYPE, recv, recv_size, MPI_CURRENT_TYPE2, MPI_COMM_WORLD);
if(rank==root)
recv = smpi_get_tmp_recvbuffer(recv_size*comm_size* MPI_CURRENT_TYPE2->size());
if(rank==root)
recv = smpi_get_tmp_recvbuffer(recv_size*comm_size* MPI_CURRENT_TYPE2->size());
- TRACE_smpi_comm_in(rank, __FUNCTION__,
- new simgrid::instr::CollTIData("gather", root, -1.0, send_size, recv_size,
- MPI_CURRENT_TYPE->encode(), MPI_CURRENT_TYPE2->encode()));
+ TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::CollTIData("gather", root, -1.0, send_size, recv_size,
+ Datatype::encode(MPI_CURRENT_TYPE),
+ Datatype::encode(MPI_CURRENT_TYPE2)));
Colls::gather(send, send_size, MPI_CURRENT_TYPE, recv, recv_size, MPI_CURRENT_TYPE2, root, MPI_COMM_WORLD);
Colls::gather(send, send_size, MPI_CURRENT_TYPE, recv, recv_size, MPI_CURRENT_TYPE2, root, MPI_COMM_WORLD);
if (rank == root)
recv = smpi_get_tmp_recvbuffer(recv_size * comm_size * MPI_CURRENT_TYPE2->size());
if (rank == root)
recv = smpi_get_tmp_recvbuffer(recv_size * comm_size * MPI_CURRENT_TYPE2->size());
- TRACE_smpi_comm_in(rank, __FUNCTION__,
- new simgrid::instr::CollTIData("gather", root, -1.0, send_size, recv_size,
- MPI_CURRENT_TYPE->encode(), MPI_CURRENT_TYPE2->encode()));
+ TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::CollTIData("gather", root, -1.0, send_size, recv_size,
+ Datatype::encode(MPI_CURRENT_TYPE),
+ Datatype::encode(MPI_CURRENT_TYPE2)));
Colls::scatter(send, send_size, MPI_CURRENT_TYPE, recv, recv_size, MPI_CURRENT_TYPE2, root, MPI_COMM_WORLD);
Colls::scatter(send, send_size, MPI_CURRENT_TYPE, recv, recv_size, MPI_CURRENT_TYPE2, root, MPI_COMM_WORLD);
if(rank==root)
recv = smpi_get_tmp_recvbuffer(recv_sum* MPI_CURRENT_TYPE2->size());
if(rank==root)
recv = smpi_get_tmp_recvbuffer(recv_sum* MPI_CURRENT_TYPE2->size());
- TRACE_smpi_comm_in(rank, __FUNCTION__,
- new simgrid::instr::VarCollTIData("gatherV", root, send_size, nullptr, -1, recvcounts,
- MPI_CURRENT_TYPE->encode(), MPI_CURRENT_TYPE2->encode()));
+ TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::VarCollTIData(
+ "gatherV", root, send_size, nullptr, -1, recvcounts,
+ Datatype::encode(MPI_CURRENT_TYPE), Datatype::encode(MPI_CURRENT_TYPE2)));
Colls::gatherv(send, send_size, MPI_CURRENT_TYPE, recv, recvcounts->data(), disps.data(), MPI_CURRENT_TYPE2, root,
MPI_COMM_WORLD);
Colls::gatherv(send, send_size, MPI_CURRENT_TYPE, recv, recvcounts->data(), disps.data(), MPI_CURRENT_TYPE2, root,
MPI_COMM_WORLD);
if (rank == root)
send = smpi_get_tmp_sendbuffer(send_sum * MPI_CURRENT_TYPE2->size());
if (rank == root)
send = smpi_get_tmp_sendbuffer(send_sum * MPI_CURRENT_TYPE2->size());
- TRACE_smpi_comm_in(rank, __FUNCTION__,
- new simgrid::instr::VarCollTIData("gatherV", root, -1, sendcounts, recv_size, nullptr,
- MPI_CURRENT_TYPE->encode(), MPI_CURRENT_TYPE2->encode()));
+ TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::VarCollTIData("gatherV", root, -1, sendcounts, recv_size,
+ nullptr, Datatype::encode(MPI_CURRENT_TYPE),
+ Datatype::encode(MPI_CURRENT_TYPE2)));
Colls::scatterv(send, sendcounts->data(), disps.data(), MPI_CURRENT_TYPE, recv, recv_size, MPI_CURRENT_TYPE2, root,
MPI_COMM_WORLD);
Colls::scatterv(send, sendcounts->data(), disps.data(), MPI_CURRENT_TYPE, recv, recv_size, MPI_CURRENT_TYPE2, root,
MPI_COMM_WORLD);
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
new simgrid::instr::VarCollTIData("reduceScatter", -1, 0, nullptr, -1, recvcounts,
std::to_string(comp_size), /* ugly hack to print comp_size */
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
new simgrid::instr::VarCollTIData("reduceScatter", -1, 0, nullptr, -1, recvcounts,
std::to_string(comp_size), /* ugly hack to print comp_size */
- MPI_CURRENT_TYPE->encode()));
+ Datatype::encode(MPI_CURRENT_TYPE)));
void *sendbuf = smpi_get_tmp_sendbuffer(size* MPI_CURRENT_TYPE->size());
void *recvbuf = smpi_get_tmp_recvbuffer(size* MPI_CURRENT_TYPE->size());
void *sendbuf = smpi_get_tmp_sendbuffer(size* MPI_CURRENT_TYPE->size());
void *recvbuf = smpi_get_tmp_recvbuffer(size* MPI_CURRENT_TYPE->size());
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
new simgrid::instr::CollTIData("allGather", -1, -1.0, sendcount, recvcount,
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
new simgrid::instr::CollTIData("allGather", -1, -1.0, sendcount, recvcount,
- MPI_CURRENT_TYPE->encode(), MPI_CURRENT_TYPE2->encode()));
+ Datatype::encode(MPI_CURRENT_TYPE),
+ Datatype::encode(MPI_CURRENT_TYPE2)));
Colls::allgather(sendbuf, sendcount, MPI_CURRENT_TYPE, recvbuf, recvcount, MPI_CURRENT_TYPE2, MPI_COMM_WORLD);
Colls::allgather(sendbuf, sendcount, MPI_CURRENT_TYPE, recvbuf, recvcount, MPI_CURRENT_TYPE2, MPI_COMM_WORLD);
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
new simgrid::instr::VarCollTIData("allGatherV", -1, sendcount, nullptr, -1, recvcounts,
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
new simgrid::instr::VarCollTIData("allGatherV", -1, sendcount, nullptr, -1, recvcounts,
- MPI_CURRENT_TYPE->encode(), MPI_CURRENT_TYPE2->encode()));
+ Datatype::encode(MPI_CURRENT_TYPE),
+ Datatype::encode(MPI_CURRENT_TYPE2)));
Colls::allgatherv(sendbuf, sendcount, MPI_CURRENT_TYPE, recvbuf, recvcounts->data(), disps.data(), MPI_CURRENT_TYPE2,
MPI_COMM_WORLD);
Colls::allgatherv(sendbuf, sendcount, MPI_CURRENT_TYPE, recvbuf, recvcounts->data(), disps.data(), MPI_CURRENT_TYPE2,
MPI_COMM_WORLD);
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
new simgrid::instr::VarCollTIData("allToAllV", -1, send_size, sendcounts, recv_size, recvcounts,
TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
new simgrid::instr::VarCollTIData("allToAllV", -1, send_size, sendcounts, recv_size, recvcounts,
- MPI_CURRENT_TYPE->encode(), MPI_CURRENT_TYPE2->encode()));
+ Datatype::encode(MPI_CURRENT_TYPE),
+ Datatype::encode(MPI_CURRENT_TYPE2)));
Colls::alltoallv(sendbuf, sendcounts->data(), senddisps.data(), MPI_CURRENT_TYPE, recvbuf, recvcounts->data(),
recvdisps.data(), MPI_CURRENT_TYPE, MPI_COMM_WORLD);
Colls::alltoallv(sendbuf, sendcounts->data(), senddisps.data(), MPI_CURRENT_TYPE, recvbuf, recvcounts->data(),
recvdisps.data(), MPI_CURRENT_TYPE, MPI_COMM_WORLD);
return (flags_ & DT_FLAG_BASIC);
}
return (flags_ & DT_FLAG_BASIC);
}
-const char* Datatype::encode()
+const char* Datatype::encode(MPI_Datatype dt)
- return std::to_string(id).c_str();
+ if (dt == MPI_DATATYPE_NULL)
+ return "-1";
+
+ return std::to_string(dt->id).c_str();
}
MPI_Datatype Datatype::decode(const char* const datatype_id)
}
MPI_Datatype Datatype::decode(const char* const datatype_id)