From: Frederic Suter Date: Mon, 6 Nov 2017 13:41:41 +0000 (+0100) Subject: a bit of unperfect simplification in this SMPI+TI TRacing mess X-Git-Tag: v3.18~242^2~88 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/0676fa9a7d79726e2c829ed4dc31b886c7d46f4e a bit of unperfect simplification in this SMPI+TI TRacing mess --- diff --git a/src/instr/instr_smpi.hpp b/src/instr/instr_smpi.hpp index 6d62b457dc..cb43e4e631 100644 --- a/src/instr/instr_smpi.hpp +++ b/src/instr/instr_smpi.hpp @@ -35,7 +35,7 @@ XBT_PRIVATE void TRACE_smpi_recv(int src, int dst, int tag); XBT_PRIVATE void TRACE_smpi_init(int rank); XBT_PRIVATE void TRACE_smpi_finalize(int rank); -XBT_PRIVATE const char* encode_datatype(MPI_Datatype datatype, int* known); +XBT_PRIVATE const char* encode_datatype(MPI_Datatype datatype); class smpi_trace_call_location_t { public: diff --git a/src/smpi/bindings/smpi_pmpi_coll.cpp b/src/smpi/bindings/smpi_pmpi_coll.cpp index 978985c798..0e59749084 100644 --- a/src/smpi/bindings/smpi_pmpi_coll.cpp +++ b/src/smpi/bindings/smpi_pmpi_coll.cpp @@ -12,7 +12,6 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi); - /* PMPI User level calls */ extern "C" { // Obviously, the C MPI interface should use the C linkage @@ -33,12 +32,8 @@ int PMPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm c instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1); extra->type = TRACING_BCAST; extra->root = root_traced; - int known = 0; - extra->datatype1 = encode_datatype(datatype, &known); - int dt_size_send = 1; - if (known == 0) - dt_size_send = datatype->size(); - extra->send_size = count * dt_size_send; + extra->datatype1 = encode_datatype(datatype); + extra->send_size = datatype->is_basic() ? count : count * datatype->size(); TRACE_smpi_collective_in(rank, __FUNCTION__, extra); if (comm->size() > 1) simgrid::smpi::Colls::bcast(buf, count, datatype, root, comm); @@ -106,17 +101,11 @@ int PMPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,void *recvbu instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1); extra->type = TRACING_GATHER; extra->root = root_traced; - int known = 0; - extra->datatype1 = encode_datatype(sendtmptype, &known); - int dt_size_send = 1; - if (known == 0) - dt_size_send = sendtmptype->size(); - extra->send_size = sendtmpcount * dt_size_send; - extra->datatype2 = encode_datatype(recvtype, &known); - int dt_size_recv = 1; - if ((comm->rank() == root) && known == 0) - dt_size_recv = recvtype->size(); - extra->recv_size = recvcount * dt_size_recv; + + extra->datatype1 = encode_datatype(sendtmptype); + extra->send_size = sendtmptype->is_basic() ? sendtmpcount : sendtmpcount * sendtmptype->size(); + extra->datatype2 = encode_datatype(recvtype); + extra->recv_size = recvtype->is_basic() ? recvcount : recvcount * recvtype->size(); TRACE_smpi_collective_in(rank, __FUNCTION__, extra); @@ -156,29 +145,23 @@ int PMPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recv } int rank = smpi_process()->index(); - int root_traced = comm->group()->index(root); - int size = comm->size(); instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1); extra->type = TRACING_GATHERV; - extra->num_processes = size; - extra->root = root_traced; - int known = 0; - extra->datatype1 = encode_datatype(sendtmptype, &known); - int dt_size_send = 1; - if (known == 0) - dt_size_send = sendtype->size(); - extra->send_size = sendtmpcount * dt_size_send; - extra->datatype2 = encode_datatype(recvtype, &known); - int dt_size_recv = 1; - if (known == 0) - dt_size_recv = recvtype->size(); + extra->num_processes = comm->size(); + extra->root = comm->group()->index(root); + + extra->datatype1 = encode_datatype(sendtmptype); + extra->send_size = sendtmptype->is_basic() ? sendtmpcount : sendtmpcount * sendtmptype->size(); + extra->datatype2 = encode_datatype(recvtype); + int dt_size_recv = recvtype->is_basic() ? 1 : recvtype->size(); + if (comm->rank() == root) { - extra->recvcounts = xbt_new(int, size); - for (int i = 0; i < size; i++) // copy data to avoid bad free + extra->recvcounts = new int[extra->num_processes]; + for (int i = 0; i < extra->num_processes; i++) // copy data to avoid bad free extra->recvcounts[i] = recvcounts[i] * dt_size_recv; } - TRACE_smpi_collective_in(rank, __FUNCTION__, extra); + TRACE_smpi_collective_in(rank, __FUNCTION__, extra); retval = simgrid::smpi::Colls::gatherv(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcounts, displs, recvtype, root, comm); TRACE_smpi_collective_out(rank); } @@ -211,17 +194,11 @@ int PMPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype, int rank = smpi_process()->index(); instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1); extra->type = TRACING_ALLGATHER; - int known = 0; - extra->datatype1 = encode_datatype(sendtype, &known); - int dt_size_send = 1; - if (known == 0) - dt_size_send = sendtype->size(); - extra->send_size = sendcount * dt_size_send; - extra->datatype2 = encode_datatype(recvtype, &known); - int dt_size_recv = 1; - if (known == 0) - dt_size_recv = recvtype->size(); - extra->recv_size = recvcount * dt_size_recv; + + extra->datatype1 = encode_datatype(sendtype); + extra->send_size = sendtype->is_basic() ? sendcount : sendcount * sendtype->size(); + extra->datatype2 = encode_datatype(recvtype); + extra->recv_size = recvtype->is_basic() ? recvcount : recvcount * recvtype->size(); TRACE_smpi_collective_in(rank, __FUNCTION__, extra); @@ -256,23 +233,16 @@ int PMPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, sendtype=recvtype; } int rank = smpi_process()->index(); - int i = 0; - int size = comm->size(); instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1); extra->type = TRACING_ALLGATHERV; - extra->num_processes = size; - int known = 0; - extra->datatype1 = encode_datatype(sendtype, &known); - int dt_size_send = 1; - if (known == 0) - dt_size_send = sendtype->size(); - extra->send_size = sendcount * dt_size_send; - extra->datatype2 = encode_datatype(recvtype, &known); - int dt_size_recv = 1; - if (known == 0) - dt_size_recv = recvtype->size(); - extra->recvcounts = xbt_new(int, size); - for (i = 0; i < size; i++) // copy data to avoid bad free + extra->num_processes = comm->size(); + extra->datatype1 = encode_datatype(sendtype); + extra->send_size = sendtype->is_basic() ? sendcount : sendcount * sendtype->size(); + extra->datatype2 = encode_datatype(recvtype); + int dt_size_recv = recvtype->is_basic() ? 1 : recvtype->size(); + + extra->recvcounts = new int[extra->num_processes]; + for (int i = 0; i < extra->num_processes; i++) // copy data to avoid bad free extra->recvcounts[i] = recvcounts[i] * dt_size_recv; TRACE_smpi_collective_in(rank, __FUNCTION__, extra); @@ -312,17 +282,12 @@ int PMPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype, instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1); extra->type = TRACING_SCATTER; extra->root = root_traced; - int known = 0; - extra->datatype1 = encode_datatype(sendtype, &known); - int dt_size_send = 1; - if ((comm->rank() == root) && known == 0) - dt_size_send = sendtype->size(); - extra->send_size = sendcount * dt_size_send; - extra->datatype2 = encode_datatype(recvtype, &known); - int dt_size_recv = 1; - if (known == 0) - dt_size_recv = recvtype->size(); - extra->recv_size = recvcount * dt_size_recv; + + extra->datatype1 = encode_datatype(sendtype); + extra->send_size = sendtype->is_basic() ? sendcount : sendcount * sendtype->size(); + extra->datatype2 = encode_datatype(recvtype); + extra->recv_size = recvtype->is_basic() ? recvcount : recvcount * recvtype->size(); + TRACE_smpi_collective_in(rank, __FUNCTION__, extra); simgrid::smpi::Colls::scatter(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm); @@ -354,27 +319,20 @@ int PMPI_Scatterv(void *sendbuf, int *sendcounts, int *displs, recvcount = sendcounts[comm->rank()]; } int rank = smpi_process()->index(); - int root_traced = comm->group()->index(root); - int size = comm->size(); instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1); extra->type = TRACING_SCATTERV; - extra->num_processes = size; - extra->root = root_traced; - int known = 0; - extra->datatype1 = encode_datatype(sendtype, &known); - int dt_size_send = 1; - if (known == 0) - dt_size_send = sendtype->size(); + extra->num_processes = comm->size(); + extra->root = comm->group()->index(root); + extra->datatype1 = encode_datatype(sendtype); + extra->datatype2 = encode_datatype(recvtype); + int dt_size_send = sendtype->is_basic() ? 1 : sendtype->size(); + extra->recv_size = recvtype->is_basic() ? recvcount : recvcount * recvtype->size(); if (comm->rank() == root) { - extra->sendcounts = xbt_new(int, size); - for (int i = 0; i < size; i++) // copy data to avoid bad free + extra->sendcounts = new int[extra->num_processes]; + for (int i = 0; i < extra->num_processes; i++) // copy data to avoid bad free extra->sendcounts[i] = sendcounts[i] * dt_size_send; } - extra->datatype2 = encode_datatype(recvtype, &known); - int dt_size_recv = 1; - if (known == 0) - dt_size_recv = recvtype->size(); - extra->recv_size = recvcount * dt_size_recv; + TRACE_smpi_collective_in(rank, __FUNCTION__, extra); retval = simgrid::smpi::Colls::scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf, recvcount, recvtype, root, comm); @@ -398,16 +356,12 @@ int PMPI_Reduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, retval = MPI_ERR_ARG; } else { int rank = smpi_process()->index(); - int root_traced = comm->group()->index(root); + instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1); + extra->root = comm->group()->index(root); extra->type = TRACING_REDUCE; - int known = 0; - extra->datatype1 = encode_datatype(datatype, &known); - int dt_size_send = 1; - if (known == 0) - dt_size_send = datatype->size(); - extra->send_size = count * dt_size_send; - extra->root = root_traced; + extra->datatype1 = encode_datatype(datatype); + extra->send_size = datatype->is_basic() ? count : count * datatype->size(); TRACE_smpi_collective_in(rank, __FUNCTION__, extra); @@ -457,12 +411,9 @@ int PMPI_Allreduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatyp int rank = smpi_process()->index(); instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1); extra->type = TRACING_ALLREDUCE; - int known = 0; - extra->datatype1 = encode_datatype(datatype, &known); - int dt_size_send = 1; - if (known == 0) - dt_size_send = datatype->size(); - extra->send_size = count * dt_size_send; + + extra->datatype1 = encode_datatype(datatype); + extra->send_size = datatype->is_basic() ? count : count * datatype->size(); TRACE_smpi_collective_in(rank, __FUNCTION__, extra); @@ -495,12 +446,9 @@ int PMPI_Scan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MP int rank = smpi_process()->index(); instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1); extra->type = TRACING_SCAN; - int known = 0; - extra->datatype1 = encode_datatype(datatype, &known); - int dt_size_send = 1; - if (known == 0) - dt_size_send = datatype->size(); - extra->send_size = count * dt_size_send; + + extra->datatype1 = encode_datatype(datatype); + extra->send_size = datatype->is_basic() ? count : count * datatype->size(); TRACE_smpi_collective_in(rank, __FUNCTION__, extra); @@ -528,16 +476,12 @@ int PMPI_Exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, int rank = smpi_process()->index(); instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1); extra->type = TRACING_EXSCAN; - int known = 0; - extra->datatype1 = encode_datatype(datatype, &known); - int dt_size_send = 1; - if (known == 0) - dt_size_send = datatype->size(); - extra->send_size = count * dt_size_send; + extra->datatype1 = encode_datatype(datatype); + extra->send_size = datatype->is_basic() ? count : count * datatype->size(); void* sendtmpbuf = sendbuf; if (sendbuf == MPI_IN_PLACE) { - sendtmpbuf = static_cast(xbt_malloc(count * datatype->size())); - memcpy(sendtmpbuf, recvbuf, count * datatype->size()); + sendtmpbuf = static_cast(xbt_malloc(extra->send_size)); + memcpy(sendtmpbuf, recvbuf, extra->send_size); } TRACE_smpi_collective_in(rank, __FUNCTION__, extra); @@ -567,21 +511,18 @@ int PMPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts, MPI_Datat retval = MPI_ERR_ARG; } else { int rank = smpi_process()->index(); - int i = 0; - int size = comm->size(); instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1); extra->type = TRACING_REDUCE_SCATTER; - extra->num_processes = size; - int known = 0; - extra->datatype1 = encode_datatype(datatype, &known); - int dt_size_send = 1; - if (known == 0) - dt_size_send = datatype->size(); - extra->send_size = 0; - extra->recvcounts = xbt_new(int, size); + extra->num_processes = comm->size(); + ; + extra->type = TRACING_EXSCAN; + extra->datatype1 = encode_datatype(datatype); + extra->send_size = datatype->is_basic() ? 1 : datatype->size(); + + extra->recvcounts = new int[extra->num_processes]; int totalcount = 0; - for (i = 0; i < size; i++) { // copy data to avoid bad free - extra->recvcounts[i] = recvcounts[i] * dt_size_send; + for (int i = 0; i < extra->num_processes; i++) { // copy data to avoid bad free + extra->recvcounts[i] = recvcounts[i] * extra->send_size; totalcount += recvcounts[i]; } void* sendtmpbuf = sendbuf; @@ -625,14 +566,11 @@ int PMPI_Reduce_scatter_block(void *sendbuf, void *recvbuf, int recvcount, instr_extra_data extra = xbt_new0(s_instr_extra_data_t, 1); extra->type = TRACING_REDUCE_SCATTER; extra->num_processes = count; - int known = 0; - extra->datatype1 = encode_datatype(datatype, &known); - int dt_size_send = 1; - if (known == 0) - dt_size_send = datatype->size(); - extra->send_size = 0; - extra->recvcounts = xbt_new(int, count); - for (int i = 0; i < count; i++) // copy data to avoid bad free + extra->datatype1 = encode_datatype(datatype); + int dt_size_send = datatype->is_basic() ? 1 : datatype->size(); + extra->send_size = 0; + extra->recvcounts = new int[extra->num_processes]; + for (int i = 0; i < extra->num_processes; i++) // copy data to avoid bad free extra->recvcounts[i] = recvcount * dt_size_send; void* sendtmpbuf = sendbuf; if (sendbuf == MPI_IN_PLACE) { @@ -642,11 +580,11 @@ int PMPI_Reduce_scatter_block(void *sendbuf, void *recvbuf, int recvcount, TRACE_smpi_collective_in(rank, __FUNCTION__, extra); - int* recvcounts = static_cast(xbt_malloc(count * sizeof(int))); + int* recvcounts = new int[count]; for (int i = 0; i < count; i++) recvcounts[i] = recvcount; simgrid::smpi::Colls::reduce_scatter(sendtmpbuf, recvbuf, recvcounts, datatype, op, comm); - xbt_free(recvcounts); + delete[] recvcounts; retval = MPI_SUCCESS; TRACE_smpi_collective_out(rank); @@ -684,17 +622,10 @@ int PMPI_Alltoall(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* rec sendtmptype = recvtype; } - int known = 0; - extra->datatype1 = encode_datatype(sendtmptype, &known); - if (known == 0) - extra->send_size = sendtmpcount * sendtmptype->size(); - else - extra->send_size = sendtmpcount; - extra->datatype2 = encode_datatype(recvtype, &known); - if (known == 0) - extra->recv_size = recvcount * recvtype->size(); - else - extra->recv_size = recvcount; + extra->datatype1 = encode_datatype(sendtmptype); + extra->send_size = sendtmptype->is_basic() ? sendtmpcount : sendtmpcount * sendtmptype->size(); + extra->datatype2 = encode_datatype(recvtype); + extra->recv_size = recvtype->is_basic() ? recvcount : recvcount * recvtype->size(); TRACE_smpi_collective_in(rank, __FUNCTION__, extra); @@ -732,11 +663,10 @@ int PMPI_Alltoallv(void* sendbuf, int* sendcounts, int* senddisps, MPI_Datatype extra->type = TRACING_ALLTOALLV; extra->send_size = 0; extra->recv_size = 0; - extra->recvcounts = xbt_new(int, size); - extra->sendcounts = xbt_new(int, size); - int known = 0; - extra->datatype2 = encode_datatype(recvtype, &known); - int dt_size_recv = recvtype->size(); + extra->recvcounts = new int[size]; + extra->sendcounts = new int[size]; + extra->datatype2 = encode_datatype(recvtype); + int dt_size_recv = recvtype->is_basic() ? 1 : recvtype->size(); void* sendtmpbuf = static_cast(sendbuf); int* sendtmpcounts = sendcounts; @@ -760,8 +690,8 @@ int PMPI_Alltoallv(void* sendbuf, int* sendcounts, int* senddisps, MPI_Datatype sendtmptype = recvtype; } - extra->datatype1 = encode_datatype(sendtmptype, &known); - int dt_size_send = sendtmptype->size(); + extra->datatype1 = encode_datatype(sendtmptype); + int dt_size_send = sendtmptype->is_basic() ? 1 : sendtmptype->size(); for (i = 0; i < size; i++) { // copy data to avoid bad free extra->send_size += sendtmpcounts[i] * dt_size_send; diff --git a/src/smpi/bindings/smpi_pmpi_request.cpp b/src/smpi/bindings/smpi_pmpi_request.cpp index aa9064e1d9..86c4ffe7d0 100644 --- a/src/smpi/bindings/smpi_pmpi_request.cpp +++ b/src/smpi/bindings/smpi_pmpi_request.cpp @@ -164,12 +164,8 @@ int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MP extra->type = TRACING_IRECV; extra->src = src_traced; extra->dst = rank; - int known=0; - extra->datatype1 = encode_datatype(datatype, &known); - int dt_size_send = 1; - if(known==0) - dt_size_send = datatype->size(); - extra->send_size = count*dt_size_send; + extra->datatype1 = encode_datatype(datatype); + extra->send_size = datatype->is_basic() ? count : count * datatype->size(); TRACE_smpi_ptp_in(rank, __FUNCTION__, extra); *request = simgrid::smpi::Request::irecv(buf, count, datatype, src, tag, comm); @@ -212,12 +208,8 @@ int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MP extra->type = TRACING_ISEND; extra->src = rank; extra->dst = dst_traced; - int known=0; - extra->datatype1 = encode_datatype(datatype, &known); - int dt_size_send = 1; - if(known==0) - dt_size_send = datatype->size(); - extra->send_size = count*dt_size_send; + extra->datatype1 = encode_datatype(datatype); + extra->send_size = datatype->is_basic() ? count : count * datatype->size(); TRACE_smpi_ptp_in(rank, __FUNCTION__, extra); TRACE_smpi_send(rank, rank, dst_traced, tag, count*datatype->size()); @@ -260,12 +252,8 @@ int PMPI_Issend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, M extra->type = TRACING_ISSEND; extra->src = rank; extra->dst = dst_traced; - int known=0; - extra->datatype1 = encode_datatype(datatype, &known); - int dt_size_send = 1; - if(known==0) - dt_size_send = datatype->size(); - extra->send_size = count*dt_size_send; + extra->datatype1 = encode_datatype(datatype); + extra->send_size = datatype->is_basic() ? count : count * datatype->size(); TRACE_smpi_ptp_in(rank, __FUNCTION__, extra); TRACE_smpi_send(rank, rank, dst_traced, tag, count*datatype->size()); @@ -307,12 +295,8 @@ int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI extra->type = TRACING_RECV; extra->src = src_traced; extra->dst = rank; - int known = 0; - extra->datatype1 = encode_datatype(datatype, &known); - int dt_size_send = 1; - if (known == 0) - dt_size_send = datatype->size(); - extra->send_size = count * dt_size_send; + extra->datatype1 = encode_datatype(datatype); + extra->send_size = datatype->is_basic() ? count : count * datatype->size(); TRACE_smpi_ptp_in(rank, __FUNCTION__, extra); simgrid::smpi::Request::recv(buf, count, datatype, src, tag, comm, status); @@ -357,13 +341,8 @@ int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI extra->type = TRACING_SEND; extra->src = rank; extra->dst = dst_traced; - int known = 0; - extra->datatype1 = encode_datatype(datatype, &known); - int dt_size_send = 1; - if (known == 0) { - dt_size_send = datatype->size(); - } - extra->send_size = count*dt_size_send; + extra->datatype1 = encode_datatype(datatype); + extra->send_size = datatype->is_basic() ? count : count * datatype->size(); TRACE_smpi_ptp_in(rank, __FUNCTION__, extra); if (not TRACE_smpi_view_internals()) { TRACE_smpi_send(rank, rank, dst_traced, tag,count*datatype->size()); @@ -403,13 +382,9 @@ int PMPI_Ssend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MP extra->type = TRACING_SSEND; extra->src = rank; extra->dst = dst_traced; - int known = 0; - extra->datatype1 = encode_datatype(datatype, &known); - int dt_size_send = 1; - if(known == 0) { - dt_size_send = datatype->size(); - } - extra->send_size = count*dt_size_send; + extra->datatype1 = encode_datatype(datatype); + extra->send_size = datatype->is_basic() ? count : count * datatype->size(); + TRACE_smpi_ptp_in(rank, __FUNCTION__, extra); TRACE_smpi_send(rank, rank, dst_traced, tag,count*datatype->size()); @@ -447,7 +422,6 @@ int PMPI_Sendrecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, int dst, } else if((sendtag<0 && sendtag != MPI_ANY_TAG)||(recvtag<0 && recvtag != MPI_ANY_TAG)){ retval = MPI_ERR_TAG; } else { - int rank = smpi_process()->index(); int dst_traced = comm->group()->index(dst); int src_traced = comm->group()->index(src); @@ -455,17 +429,10 @@ int PMPI_Sendrecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, int dst, extra->type = TRACING_SENDRECV; extra->src = src_traced; extra->dst = dst_traced; - int known = 0; - extra->datatype1 = encode_datatype(sendtype, &known); - int dt_size_send = 1; - if (known == 0) - dt_size_send = sendtype->size(); - extra->send_size = sendcount * dt_size_send; - extra->datatype2 = encode_datatype(recvtype, &known); - int dt_size_recv = 1; - if (known == 0) - dt_size_recv = recvtype->size(); - extra->recv_size = recvcount * dt_size_recv; + extra->datatype1 = encode_datatype(sendtype); + extra->send_size = sendtype->is_basic() ? sendcount : sendcount * sendtype->size(); + extra->datatype2 = encode_datatype(recvtype); + extra->recv_size = recvtype->is_basic() ? recvcount : recvcount * recvtype->size(); TRACE_smpi_ptp_in(rank, __FUNCTION__, extra); TRACE_smpi_send(rank, rank, dst_traced, sendtag, sendcount * sendtype->size()); diff --git a/src/smpi/bindings/smpi_pmpi_win.cpp b/src/smpi/bindings/smpi_pmpi_win.cpp index f7320c0170..4fa328dfc2 100644 --- a/src/smpi/bindings/smpi_pmpi_win.cpp +++ b/src/smpi/bindings/smpi_pmpi_win.cpp @@ -77,7 +77,8 @@ int PMPI_Win_attach(MPI_Win win, void *base, MPI_Aint size){ return retval; } -int PMPI_Win_detach(MPI_Win win, void *base){ +int PMPI_Win_detach(MPI_Win win, void* base) +{ int retval = 0; smpi_bench_end(); if(win == MPI_WIN_NULL){ @@ -480,9 +481,9 @@ int PMPI_Fetch_and_op(void *origin_addr, void *result_addr, MPI_Datatype dtype, return PMPI_Get_accumulate(origin_addr, origin_addr==nullptr?0:1, dtype, result_addr, 1, dtype, target_rank, target_disp, 1, dtype, op, win); } -int PMPI_Compare_and_swap(void *origin_addr, void *compare_addr, - void *result_addr, MPI_Datatype datatype, int target_rank, - MPI_Aint target_disp, MPI_Win win){ +int PMPI_Compare_and_swap(void* origin_addr, void* compare_addr, void* result_addr, MPI_Datatype datatype, + int target_rank, MPI_Aint target_disp, MPI_Win win) +{ int retval = 0; smpi_bench_end(); if (win == MPI_WIN_NULL) { @@ -504,8 +505,7 @@ int PMPI_Compare_and_swap(void *origin_addr, void *compare_addr, win->get_group(&group); TRACE_smpi_ptp_in(rank, __FUNCTION__, nullptr); - retval = win->compare_and_swap( origin_addr, compare_addr, result_addr, datatype, - target_rank, target_disp); + retval = win->compare_and_swap(origin_addr, compare_addr, result_addr, datatype, target_rank, target_disp); TRACE_smpi_ptp_out(rank); } diff --git a/src/smpi/include/smpi_datatype.hpp b/src/smpi/include/smpi_datatype.hpp index 97beb461c1..2453f1017b 100644 --- a/src/smpi/include/smpi_datatype.hpp +++ b/src/smpi/include/smpi_datatype.hpp @@ -102,6 +102,7 @@ public: static void unref(MPI_Datatype datatype); void commit(); bool is_valid(); + bool is_basic(); void addflag(int flag); int extent(MPI_Aint* lb, MPI_Aint* extent); MPI_Aint get_extent(); diff --git a/src/smpi/internals/smpi_replay.cpp b/src/smpi/internals/smpi_replay.cpp index 7cba3e078d..60cedeff88 100644 --- a/src/smpi/internals/smpi_replay.cpp +++ b/src/smpi/internals/smpi_replay.cpp @@ -118,12 +118,8 @@ static MPI_Datatype decode_datatype(const char *const action) return MPI_CURRENT_TYPE; } -const char* encode_datatype(MPI_Datatype datatype, int* known) +const char* encode_datatype(MPI_Datatype datatype) { - //default type for output is set to MPI_BYTE - // MPI_DEFAULT_TYPE is not set for output, use directly MPI_BYTE - if(known!=nullptr) - *known=1; if (datatype==MPI_BYTE) return ""; if(datatype==MPI_DOUBLE) @@ -138,9 +134,6 @@ const char* encode_datatype(MPI_Datatype datatype, int* known) return "4"; if(datatype==MPI_FLOAT) return "5"; - //tell that the datatype is not handled by replay, and that its size should be measured and replayed as size*MPI_BYTE - if(known!=nullptr) - *known=0; // default - not implemented. // do not warn here as we pass in this function even for other trace formats return "-1"; @@ -165,8 +158,9 @@ static void action_init(const char *const *action) XBT_DEBUG("Initialize the counters"); CHECK_ACTION_PARAMS(action, 0, 1) if(action[2]) - MPI_DEFAULT_TYPE=MPI_DOUBLE; // default MPE dataype - else MPI_DEFAULT_TYPE= MPI_BYTE; // default TAU datatype + MPI_DEFAULT_TYPE = MPI_DOUBLE; // default MPE datatype + else + MPI_DEFAULT_TYPE = MPI_BYTE; // default TAU datatype /* start a simulated timer */ smpi_process()->simulated_start(); @@ -234,7 +228,7 @@ static void action_send(const char *const *action) extra->send_size = size; extra->src = rank; extra->dst = dst_traced; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); TRACE_smpi_ptp_in(rank, __FUNCTION__, extra); if (not TRACE_smpi_view_internals()) TRACE_smpi_send(rank, rank, dst_traced, 0, size*MPI_CURRENT_TYPE->size()); @@ -265,12 +259,12 @@ static void action_Isend(const char *const *action) extra->send_size = size; extra->src = rank; extra->dst = dst_traced; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); TRACE_smpi_ptp_in(rank, __FUNCTION__, extra); if (not TRACE_smpi_view_internals()) TRACE_smpi_send(rank, rank, dst_traced, 0, size*MPI_CURRENT_TYPE->size()); - MPI_Request request = Request::isend(nullptr, size, MPI_CURRENT_TYPE, to, 0,MPI_COMM_WORLD); + MPI_Request request = Request::isend(nullptr, size, MPI_CURRENT_TYPE, to, 0, MPI_COMM_WORLD); TRACE_smpi_ptp_out(rank); @@ -299,7 +293,7 @@ static void action_recv(const char *const *action) { extra->send_size = size; extra->src = src_traced; extra->dst = rank; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); TRACE_smpi_ptp_in(rank, __FUNCTION__, extra); //unknown size from the receiver point of view @@ -337,7 +331,7 @@ static void action_Irecv(const char *const *action) extra->send_size = size; extra->src = src_traced; extra->dst = rank; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); TRACE_smpi_ptp_in(rank, __FUNCTION__, extra); MPI_Status status; //unknow size from the receiver pov @@ -483,7 +477,7 @@ static void action_bcast(const char *const *action) extra->type = TRACING_BCAST; extra->send_size = size; extra->root = root_traced; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); TRACE_smpi_collective_in(rank, __FUNCTION__, extra); void *sendbuf = smpi_get_tmp_sendbuffer(size* MPI_CURRENT_TYPE->size()); @@ -514,7 +508,7 @@ static void action_reduce(const char *const *action) extra->type = TRACING_REDUCE; extra->send_size = comm_size; extra->comp_size = comp_size; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); extra->root = root_traced; TRACE_smpi_collective_in(rank, __FUNCTION__,extra); @@ -544,7 +538,7 @@ static void action_allReduce(const char *const *action) { extra->type = TRACING_ALLREDUCE; extra->send_size = comm_size; extra->comp_size = comp_size; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); TRACE_smpi_collective_in(rank, __FUNCTION__,extra); void *recvbuf = smpi_get_tmp_sendbuffer(comm_size* MPI_CURRENT_TYPE->size()); @@ -579,8 +573,8 @@ static void action_allToAll(const char *const *action) { extra->type = TRACING_ALLTOALL; extra->send_size = send_size; extra->recv_size = recv_size; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); - extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, nullptr); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); + extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2); TRACE_smpi_collective_in(rank, __FUNCTION__,extra); @@ -627,8 +621,8 @@ static void action_gather(const char *const *action) { extra->send_size = send_size; extra->recv_size = recv_size; extra->root = root; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); - extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, nullptr); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); + extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2); TRACE_smpi_collective_in(smpi_process()->index(), __FUNCTION__, extra); @@ -685,8 +679,8 @@ static void action_gatherv(const char *const *action) { extra->recvcounts[i] = recvcounts[i]; extra->root = root; extra->num_processes = comm_size; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); - extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, nullptr); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); + extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2); TRACE_smpi_collective_in(smpi_process()->index(), __FUNCTION__, extra); @@ -727,7 +721,7 @@ static void action_reducescatter(const char *const *action) { extra->recvcounts= xbt_new(int, comm_size); for(int i=0; i< comm_size; i++)//copy data to avoid bad free extra->recvcounts[i] = recvcounts[i]; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); extra->comp_size = comp_size; extra->num_processes = comm_size; @@ -773,8 +767,8 @@ static void action_allgather(const char *const *action) { extra->type = TRACING_ALLGATHER; extra->send_size = sendcount; extra->recv_size= recvcount; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); - extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, nullptr); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); + extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2); extra->num_processes = MPI_COMM_WORLD->size(); TRACE_smpi_collective_in(rank, __FUNCTION__,extra); @@ -825,8 +819,8 @@ static void action_allgatherv(const char *const *action) { extra->recvcounts= xbt_new(int, comm_size); for(int i=0; i< comm_size; i++)//copy data to avoid bad free extra->recvcounts[i] = recvcounts[i]; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); - extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, nullptr); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); + extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2); extra->num_processes = comm_size; TRACE_smpi_collective_in(rank, __FUNCTION__,extra); @@ -890,8 +884,8 @@ static void action_allToAllv(const char *const *action) { extra->recv_size += recvcounts[i]; extra->recvcounts[i] = recvcounts[i]; } - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); - extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, nullptr); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); + extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2); TRACE_smpi_collective_in(rank, __FUNCTION__,extra); diff --git a/src/smpi/mpi/smpi_datatype.cpp b/src/smpi/mpi/smpi_datatype.cpp index b738b7ba33..4db6870198 100644 --- a/src/smpi/mpi/smpi_datatype.cpp +++ b/src/smpi/mpi/smpi_datatype.cpp @@ -193,6 +193,11 @@ bool Datatype::is_valid(){ return (flags_ & DT_FLAG_COMMITED); } +bool Datatype::is_basic() +{ + return (flags_ & DT_FLAG_BASIC); +} + size_t Datatype::size(){ return size_; }