From 228a62c400df7da0b1b48186949e078af7a532ab Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Thu, 28 Nov 2019 10:28:39 +0100 Subject: [PATCH] enhance shared tests to validate comms are skipped --- src/smpi/internals/smpi_global.cpp | 4 ++-- src/smpi/mpi/smpi_datatype.cpp | 2 ++ teshsuite/smpi/macro-shared/macro-shared.c | 11 +++++++++++ teshsuite/smpi/macro-shared/macro-shared.tesh | 7 ++++++- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index 59e5c6a693..5325b9df67 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -180,7 +180,7 @@ void smpi_comm_copy_buffer_callback(simgrid::kernel::activity::CommImpl* comm, v if(smpi_is_shared(buff, src_private_blocks, &src_offset)) { src_private_blocks = shift_and_frame_private_blocks(src_private_blocks, src_offset, buff_size); if (src_private_blocks.size()==1 && (src_private_blocks[0].second - src_private_blocks[0].first)==buff_size){//simple shared malloc ... return. - XBT_DEBUG("Sender %p is shared. Let's ignore it.", buff); + XBT_VERB("Sender is shared. Let's ignore it."); smpi_cleanup_comm_after_copy(comm, buff); return; } @@ -192,7 +192,7 @@ void smpi_comm_copy_buffer_callback(simgrid::kernel::activity::CommImpl* comm, v if (smpi_is_shared((char*)comm->dst_buff_, dst_private_blocks, &dst_offset)) { dst_private_blocks = shift_and_frame_private_blocks(dst_private_blocks, dst_offset, buff_size); if (src_private_blocks.size()==1 && (src_private_blocks[0].second - src_private_blocks[0].first)==buff_size){//simple shared malloc ... return. - XBT_DEBUG("Receiver %p is shared. Let's ignore it.", (char*)comm->dst_buff_); + XBT_VERB("Receiver is shared. Let's ignore it."); smpi_cleanup_comm_after_copy(comm, buff); return; } diff --git a/src/smpi/mpi/smpi_datatype.cpp b/src/smpi/mpi/smpi_datatype.cpp index 074c15891a..b82b801426 100644 --- a/src/smpi/mpi/smpi_datatype.cpp +++ b/src/smpi/mpi/smpi_datatype.cpp @@ -284,11 +284,13 @@ int Datatype::copy(const void *sendbuf, int sendcount, MPI_Datatype sendtype, if(smpi_is_shared(sendbuf,private_blocks,&offset) && (private_blocks.size()==1 && (private_blocks[0].second - private_blocks[0].first)==(unsigned long)(sendcount * sendtype->get_extent()))){ + XBT_VERB("sendbuf is shared. Ignoring copies"); return 0; } if(smpi_is_shared(recvbuf,private_blocks,&offset) && (private_blocks.size()==1 && (private_blocks[0].second - private_blocks[0].first)==(unsigned long)(recvcount * recvtype->get_extent()))){ + XBT_VERB("recvbuf is shared. Ignoring copies"); return 0; } diff --git a/teshsuite/smpi/macro-shared/macro-shared.c b/teshsuite/smpi/macro-shared/macro-shared.c index 7ce48e7843..6e739ad2d8 100644 --- a/teshsuite/smpi/macro-shared/macro-shared.c +++ b/teshsuite/smpi/macro-shared/macro-shared.c @@ -54,6 +54,17 @@ int main(int argc, char *argv[]) printf("[%d] After change, the value in the shared buffer is: %" PRIu64"\n", rank, *buf); + //try to send/receive shared data, to check if we skip the copies correctly. + if(rank==0) + MPI_Send(buf, 1, MPI_AINT, 1, 100, MPI_COMM_WORLD); + else if (rank ==1) + MPI_Recv(buf, 1, MPI_AINT, 0, 100, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + + //same thing with an MPI_IN_PLACE collective (no) + if (rank == 0) + MPI_Scatter(buf, 1, MPI_AINT, MPI_IN_PLACE, -1, MPI_DATATYPE_NULL, 0, MPI_COMM_WORLD); + else + MPI_Scatter(NULL, -1, MPI_DATATYPE_NULL, buf, 1, MPI_AINT, 0, MPI_COMM_WORLD); SMPI_SHARED_FREE(buf); MPI_Finalize(); diff --git a/teshsuite/smpi/macro-shared/macro-shared.tesh b/teshsuite/smpi/macro-shared/macro-shared.tesh index 6eb375a4b8..38b20ab2c0 100644 --- a/teshsuite/smpi/macro-shared/macro-shared.tesh +++ b/teshsuite/smpi/macro-shared/macro-shared.tesh @@ -1,7 +1,12 @@ p Test compute ! output sort ! timeout 5 -$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/macro-shared --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning +$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/macro-shared --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning --log=smpi_kernel.thres:verbose "--log=root.fmt:(%P@%h)%e%m%n" +> (maestro@) You did not set the power of the host running the simulation. The timings will certainly not be accurate. Use the option "--cfg=smpi/host-speed:" to set its value. Check https://simgrid.org/doc/latest/Configuring_SimGrid.html#automatic-benchmarking-of-smpi-code for more information. +> (maestro@) Receiver is shared. Let's ignore it. +> (maestro@) Receiver is shared. Let's ignore it. +> (maestro@) Receiver is shared. Let's ignore it. +> (maestro@) Receiver is shared. Let's ignore it. > [0] After change, the value in the shared buffer is: 16053117601147974045 > [0] The value in the shared buffer is: 4 > [1] After change, the value in the shared buffer is: 16053117601147974045 -- 2.20.1