1 /* Copyright (c) 2019-2023. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
12 /* Test reading and writing zero bytes (set status correctly) */
14 int main( int argc, char *argv[] )
25 MPI_Init( &argc, &argv );
27 comm = MPI_COMM_WORLD;
28 MPI_File_open( comm, (char*)"/scratch/testfile", MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh );
29 MPI_Comm_size( comm, &size );
30 MPI_Comm_rank( comm, &rank );
31 buf = (int *)malloc( 10 * sizeof(int) );
35 MPI_File_seek(fh, sizeof(int) * rank, MPI_SEEK_SET);
36 MPI_File_write_all( fh, buf, 1, MPI_INT, &status );
37 MPI_Get_count( &status, MPI_INT, &count );
40 fprintf( stderr, "Wrong count (%d) on write\n", count );fflush(stderr);
42 /* Write to file, overlapping */
43 MPI_File_seek(fh, sizeof(int) * rank, MPI_SEEK_SET);
44 MPI_File_write_all( fh, buf, 10, MPI_INT, &status );
45 MPI_Get_count( &status, MPI_INT, &count );
48 fprintf( stderr, "Wrong count (%d) on write\n", count );fflush(stderr);
50 /* Read nothing (check status) */
51 memset( &status, 0xff, sizeof(MPI_Status) );
52 MPI_File_read_all( fh, buf, 0, MPI_INT, &status );
53 MPI_Get_count( &status, MPI_INT, &count );
56 fprintf( stderr, "Count not zero (%d) on read\n", count );fflush(stderr);
59 /* Write nothing (check status) */
60 memset( &status, 0xff, sizeof(MPI_Status) );
61 MPI_File_write_all( fh, buf, 0, MPI_INT, &status );
64 fprintf( stderr, "Count not zero (%d) on write\n", count );fflush(stderr);
69 MPI_File_seek( fh, sizeof(int)*rank, MPI_SEEK_SET );
70 for (int i = 0; i < size; i++)
72 MPI_File_read_all( fh, buf, 10, MPI_INT, &status );
73 // if (buf[0] != rank) {
75 // fprintf( stderr, "%d: buf = %d\n", rank, buf[0] );fflush(stderr);
79 MPI_File_close( &fh );