From 62256b5a77a259521fd868d6c5aba0cf4f3df5dc Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Wed, 1 May 2019 14:44:50 +0200 Subject: [PATCH 1/1] forgot to push test for write_at_all and read_at_all --- teshsuite/smpi/CMakeLists.txt | 6 +- teshsuite/smpi/io-all-at/io-all-at.c | 76 +++++++++++++++++++++++++ teshsuite/smpi/io-all-at/io-all-at.tesh | 60 +++++++++++++++++++ 3 files changed, 139 insertions(+), 3 deletions(-) create mode 100644 teshsuite/smpi/io-all-at/io-all-at.c create mode 100644 teshsuite/smpi/io-all-at/io-all-at.tesh diff --git a/teshsuite/smpi/CMakeLists.txt b/teshsuite/smpi/CMakeLists.txt index bd4773930b..d20871889b 100644 --- a/teshsuite/smpi/CMakeLists.txt +++ b/teshsuite/smpi/CMakeLists.txt @@ -9,7 +9,7 @@ if(enable_smpi) foreach(x coll-allgather coll-allgatherv coll-allreduce coll-alltoall coll-alltoallv coll-barrier coll-bcast coll-gather coll-reduce coll-reduce-scatter coll-scatter macro-sample pt2pt-dsend pt2pt-pingpong type-hvector type-indexed type-struct type-vector bug-17132 timers privatization - io-simple io-simple-at io-all io-shared io-ordered) + io-simple io-simple-at io-all io-all-at io-shared io-ordered) add_executable (${x} EXCLUDE_FROM_ALL ${x}/${x}.c) target_link_libraries(${x} simgrid) set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x}) @@ -38,7 +38,7 @@ foreach(x coll-allgather coll-allgatherv coll-allreduce coll-alltoall coll-allto coll-gather coll-reduce coll-reduce-scatter coll-scatter macro-sample pt2pt-dsend pt2pt-pingpong type-hvector type-indexed type-struct type-vector bug-17132 timers privatization macro-shared macro-partial-shared macro-partial-shared-communication - io-simple io-simple-at io-all io-shared io-ordered) + io-simple io-simple-at io-all io-all-at io-shared io-ordered) set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh) set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.c) endforeach() @@ -66,7 +66,7 @@ if(enable_smpi) foreach(x coll-allgather coll-allgatherv coll-allreduce coll-alltoall coll-alltoallv coll-barrier coll-bcast coll-gather coll-reduce coll-reduce-scatter coll-scatter macro-sample pt2pt-dsend pt2pt-pingpong - type-hvector type-indexed type-struct type-vector bug-17132 timers io-simple io-simple-at io-all io-shared io-ordered) + type-hvector type-indexed type-struct type-vector bug-17132 timers io-simple io-simple-at io-all io-all-at io-shared io-ordered) ADD_TESH_FACTORIES(tesh-smpi-${x} "thread;ucontext;raw;boost" --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/smpi/${x} --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/${x} ${x}.tesh) endforeach() diff --git a/teshsuite/smpi/io-all-at/io-all-at.c b/teshsuite/smpi/io-all-at/io-all-at.c new file mode 100644 index 0000000000..3c2963b1d1 --- /dev/null +++ b/teshsuite/smpi/io-all-at/io-all-at.c @@ -0,0 +1,76 @@ +#include "mpi.h" +#include +#include +#include +#include + +/* Test reading and writing zero bytes (set status correctly) */ + +int main( int argc, char *argv[] ) +{ + int errs = 0; + int size; + int rank; + int i; + int* buf; + int count; + MPI_File fh; + MPI_Comm comm; + MPI_Status status; + + MPI_Init( &argc, &argv ); + + comm = MPI_COMM_WORLD; + MPI_File_open( comm, (char*)"/scratch/testfile", MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh ); + MPI_Comm_size( comm, &size ); + MPI_Comm_rank( comm, &rank ); + buf = (int *)malloc( 10 * sizeof(int) ); + buf[0] = rank; + + /* Write to file */ + MPI_File_seek( fh, sizeof(int)*rank, MPI_SEEK_SET ); + MPI_File_write_all( fh, buf, 1, MPI_INT, &status ); + MPI_Get_count( &status, MPI_INT, &count ); + if (count != 1) { + errs++; + fprintf( stderr, "Wrong count (%d) on write\n", count );fflush(stderr); + } + /* Write to file, overlapping */ + MPI_File_write_at_all( fh, sizeof(int)*rank, buf, 10, MPI_INT, &status ); + MPI_Get_count( &status, MPI_INT, &count ); + if (count != 10) { + errs++; + fprintf( stderr, "Wrong count (%d) on write\n", count );fflush(stderr); + } + /* Read nothing (check status) */ + memset( &status, 0xff, sizeof(MPI_Status) ); + MPI_File_read_at_all( fh, 0, buf, 0, MPI_INT, &status ); + MPI_Get_count( &status, MPI_INT, &count ); + if (count != 0) { + errs++; + fprintf( stderr, "Count not zero (%d) on read\n", count );fflush(stderr); + } + + /* Write nothing (check status) */ + memset( &status, 0xff, sizeof(MPI_Status) ); + MPI_File_write_at_all( fh, 0, buf, 0, MPI_INT, &status ); + if (count != 0) { + errs++; + fprintf( stderr, "Count not zero (%d) on write\n", count );fflush(stderr); + } + + MPI_Barrier( comm ); + + for (i=0; i You requested to use 4 ranks, but there is only 2 processes in your hostfile... +> [rank 0] -> bob +> [rank 1] -> carl +> [rank 2] -> bob +> [rank 3] -> carl +> (0@bob) Seeking in MPI_File /scratch/testfile, setting offset 0 +> (2@bob) Seeking in MPI_File /scratch/testfile, setting offset 8 +> (3@carl) Seeking in MPI_File /scratch/testfile, setting offset 12 +> (1@carl) Seeking in MPI_File /scratch/testfile, setting offset 4 +> (3@carl) Write in MPI_File /scratch/testfile, 4 bytes written, readsize 4 bytes, movesize 4 +> (3@carl) Position after write in MPI_File /scratch/testfile : 16 +> (3@carl) Seeking in MPI_File /scratch/testfile, setting offset 12 +> (1@carl) Write in MPI_File /scratch/testfile, 4 bytes written, readsize 4 bytes, movesize 4 +> (1@carl) Position after write in MPI_File /scratch/testfile : 8 +> (1@carl) Seeking in MPI_File /scratch/testfile, setting offset 4 +> (2@bob) Write in MPI_File /scratch/testfile, 4 bytes written, readsize 4 bytes, movesize 4 +> (2@bob) Position after write in MPI_File /scratch/testfile : 12 +> (2@bob) Seeking in MPI_File /scratch/testfile, setting offset 8 +> (0@bob) Write in MPI_File /scratch/testfile, 4 bytes written, readsize 4 bytes, movesize 4 +> (0@bob) Position after write in MPI_File /scratch/testfile : 4 +> (0@bob) Seeking in MPI_File /scratch/testfile, setting offset 0 +> (3@carl) Seeking in MPI_File /scratch/testfile, setting offset 39 +> (2@bob) Seeking in MPI_File /scratch/testfile, setting offset 26 +> (0@bob) Seeking in MPI_File /scratch/testfile, setting offset 0 +> (1@carl) Seeking in MPI_File /scratch/testfile, setting offset 13 +> (3@carl) Write in MPI_File /scratch/testfile, 12 bytes written, readsize 12 bytes, movesize 12 +> (3@carl) Position after write in MPI_File /scratch/testfile : 51 +> (1@carl) Write in MPI_File /scratch/testfile, 12 bytes written, readsize 12 bytes, movesize 12 +> (1@carl) Position after write in MPI_File /scratch/testfile : 25 +> (0@bob) Write in MPI_File /scratch/testfile, 12 bytes written, readsize 12 bytes, movesize 12 +> (0@bob) Position after write in MPI_File /scratch/testfile : 12 +> (2@bob) Write in MPI_File /scratch/testfile, 12 bytes written, readsize 12 bytes, movesize 12 +> (2@bob) Position after write in MPI_File /scratch/testfile : 38 +> (3@carl) Seeking in MPI_File /scratch/testfile, setting offset 0 +> (1@carl) Seeking in MPI_File /scratch/testfile, setting offset 0 +> (2@bob) Seeking in MPI_File /scratch/testfile, setting offset 0 +> (0@bob) Seeking in MPI_File /scratch/testfile, setting offset 0 +> (3@carl) Seeking in MPI_File /scratch/testfile, setting offset 0 +> (2@bob) Seeking in MPI_File /scratch/testfile, setting offset 0 +> (0@bob) Seeking in MPI_File /scratch/testfile, setting offset 0 +> (1@carl) Seeking in MPI_File /scratch/testfile, setting offset 0 +> (0@bob) Seeking in MPI_File /scratch/testfile, setting offset 0 +> (2@bob) Seeking in MPI_File /scratch/testfile, setting offset 8 +> (3@carl) Seeking in MPI_File /scratch/testfile, setting offset 12 +> (1@carl) Seeking in MPI_File /scratch/testfile, setting offset 4 +> (0@bob) Seeking in MPI_File /scratch/testfile, setting offset 0 +> (2@bob) Seeking in MPI_File /scratch/testfile, setting offset 26 +> (3@carl) Seeking in MPI_File /scratch/testfile, setting offset 39 +> (1@carl) Seeking in MPI_File /scratch/testfile, setting offset 13 +> (3@carl) Read in MPI_File /scratch/testfile, 12 bytes read, readsize 12 bytes, movesize 12 +> (3@carl) Position after read in MPI_File /scratch/testfile : 51 +> (1@carl) Read in MPI_File /scratch/testfile, 12 bytes read, readsize 12 bytes, movesize 12 +> (1@carl) Position after read in MPI_File /scratch/testfile : 25 +> (2@bob) Read in MPI_File /scratch/testfile, 12 bytes read, readsize 12 bytes, movesize 12 +> (2@bob) Position after read in MPI_File /scratch/testfile : 38 +> (0@bob) Read in MPI_File /scratch/testfile, 12 bytes read, readsize 12 bytes, movesize 12 +> (0@bob) Position after read in MPI_File /scratch/testfile : 12 -- 2.20.1