#
# Copyright (C) by Argonne National Laboratory
# See COPYRIGHT in top-level directory
#
# Definitions for various MPI I/O Read/write tests
# This is the C++ version of the Fortran I/O tests.
# We use MPI_SEEK_SET instead of MPI::SEEK_SET to avoid conflicts with the
# stdio SEEK_SET
C++
# If we want a separate step to check the file as written different
# from the read step, insert it here.
#
# Definitions for the check error blocks
try {
} catch ( MPI::Exception e ) {
errs++;
if (errs <= MAX_ERRORS) {
MTestPrintError( e.Get_error_code() );
}
}
fh = MPI::File::Open( comm, filename, MPI::MODE_RDWR + MPI::MODE_CREATE, MPI::INFO_NULL );
// If the file open failed, skip the rest of this test
if (fh == MPI::FILE_NULL) { continue; }
fh.Close();
if (status.Get_count( MPI::INT ) != n) {
cout << "Wrong value from status; expected " << n << " but got " <<
status.Get_count( MPI::INT ) << "\n";
}
comm.Barrier();
if (comm.Get_rank() == 0) {
MPI::File::Delete( filename, MPI::INFO_NULL );
}
comm.Barrier();
# Common code to initialize the buffer for contiguous writes
for (i=0; i
# This is for double buffered tests
for (i=0; i
for (i=0; i
for (i=0; i
for (i=0; i
for (i=0; i
# Common offset computation, based on the block, rank, size
offset = (r * n + k * n * s) * sizeof(int);
# Set the view of the file for this process; suitable for
# collective I/O and independent file I/O without seek
filetype = MPI::INT.Create_vector( b, n, n*s );
filetype.Commit();
offset = r * n * sizeof(int);
fh.Set_view( offset, MPI::INT, filetype, "native", MPI::INFO_NULL );
filetype.Free();
# -
# These are used to synchronize the shared file pointer tests
src = ( r + s - 1 ) % s;
dest = ( r + 1 ) % s;
if (src == dest) {
src = MPI::PROC_NULL;
dest = MPI::PROC_NULL;
}
if (r == s - 1) {
comm.Ssend( MPI::BOTTOM, 0, MPI::INT, dest, 0);
}
for (k=0; k
comm.Recv( MPI::BOTTOM, 0, MPI::INT, src, k );
if (r == s-1) {
comm.Ssend( MPI::BOTTOM, 0, MPI::INT, dest, k+1 );
}
else {
comm.Ssend( MPI::BOTTOM, 0, MPI::INT, dest, k);
}
if (r == 0) {
comm.Recv( MPI::BOTTOM, 0, MPI::INT, src, b );
}
# ----------------------------------------------------------------------------
# This test uses the individual file pointers.
# To reach the correct locations, we seek to the position
MPI::Status status;
int buf[MAX_BUFFER], ans;
MPI::Offset offset;
for (k=0; k
fh.Seek( offset, MPI_SEEK_SET );
fh.Write( buf, n, MPI::INT, status );
}
# No extra declarations are needed for the read step
for (k=0; k
fh.Seek( offset, MPI_SEEK_SET );
fh.Read( buf, n, MPI::INT, status );
}
int buf[MAX_BUFFER], ans;
MPI::Offset offset;
for (k=0; k
fh.Seek( offset, MPI_SEEK_SET );
fh.Write( buf, n, MPI::INT );
}
# No extra declarations are needed for the read step
for (k=0; k
fh.Seek( offset, MPI_SEEK_SET );
fh.Read( buf, n, MPI::INT );
}
# This test uses independent I/O with thread-safe, individual file pointers
MPI::Status status;
int buf[MAX_BUFFER], ans;
MPI::Offset offset;
for (k=0; k
fh.Write_at( offset, buf, n, MPI::INT, status );
}
# No extra declarations are needed for the read step
for (k=0; k
fh.Read_at( offset, buf, n, MPI::INT, status );
}
int buf[MAX_BUFFER], ans;
MPI::Offset offset;
for (k=0; k
fh.Write_at( offset, buf, n, MPI::INT );
}
# No extra declarations are needed for the read step
for (k=0; k
fh.Read_at( offset, buf, n, MPI::INT );
}
# This test uses collective I/O with thread-safe, individual file pointers
MPI::Status status;
int buf[MAX_BUFFER], ans ;
MPI::Offset offset;
for (k=0; k
fh.Write_at_all( offset, buf, n, MPI::INT, status );
}
# No extra declarations are needed for the read step
for (k=0; k
fh.Read_at_all( offset, buf, n, MPI::INT, status );
}
int buf[MAX_BUFFER], ans ;
MPI::Offset offset;
for (k=0; k
fh.Write_at_all( offset, buf, n, MPI::INT );
}
# No extra declarations are needed for the read step
for (k=0; k
fh.Read_at_all( offset, buf, n, MPI::INT );
}
# This test uses collective I/O with thread-safe, individual file pointers
MPI::Status status;
int buf[MAX_BUFFER], ans;
MPI::Offset offset;
for (k=0; k
fh.Write_at_all_begin( offset, buf, n, MPI::INT );
fh.Write_at_all_end( buf, status );
}
# No extra declarations are needed for the read step
for (k=0; k
fh.Read_at_all_begin( offset, buf, n, MPI::INT );
fh.Read_at_all_end( buf, status );
}
int buf[MAX_BUFFER], ans;
MPI::Offset offset;
for (k=0; k
fh.Write_at_all_begin( offset, buf, n, MPI::INT );
fh.Write_at_all_end( buf );
}
# No extra declarations are needed for the read step
for (k=0; k
fh.Read_at_all_begin( offset, buf, n, MPI::INT );
fh.Read_at_all_end( buf );
}
# This test uses nonblocking I/O with independent file pointers
MPI::Status statuses[2];
int buf[MAX_BUFFER], buf2[MAX_BUFFER], ans;
MPI::Request req[2];
int nreq;
MPI::Offset offset;
for (k=0; k
nreq = 1;
req[0] = fh.Iwrite_at( offset, buf, n, MPI::INT );
if (k+1 < b) {
offset = offset + (s * n) * sizeof(int);
nreq++;
req[1] = fh.Iwrite_at( offset, buf2, n, MPI::INT );
}
MPI::Request::Waitall( nreq, req, statuses );
}
# No extra declarations are needed for the read step
for (k=0; k
nreq = 1;
req[0] = fh.Iread_at( offset, buf, n, MPI::INT );
if (k+1 < b) {
offset = offset + (s * n) * sizeof(int);
nreq++;
req[1] = fh.Iread_at( offset, buf2, n, MPI::INT );
}
MPI::Request::Waitall( nreq, req, statuses );
if (nreq == 2) {
}
}
int buf[MAX_BUFFER], buf2[MAX_BUFFER], ans;
MPI::Request req[2];
int nreq;
MPI::Offset offset;
for (k=0; k
nreq = 1;
req[0] = fh.Iwrite_at( offset, buf, n, MPI::INT );
if (k+1 < b) {
offset = offset + (s * n) * sizeof(int);
nreq++;
req[1] = fh.Iwrite_at( offset, buf2, n, MPI::INT );
}
MPI::Request::Waitall( nreq, req );
}
# No extra declarations are needed for the read step
for (k=0; k
nreq = 1;
req[0] = fh.Iread_at( offset, buf, n, MPI::INT );
if (k+1 < b) {
offset = offset + (s * n) * sizeof(int);
nreq++;
req[1] = fh.Iread_at( offset, buf2, n, MPI::INT );
}
MPI::Request::Waitall( nreq, req );
if (nreq == 2) {
}
}
# This test uses nonblocking I/O with independent file pointers and explicit
# seeks
MPI::Status statuses[2];
int buf[MAX_BUFFER], buf2[MAX_BUFFER], ans;
MPI::Request req[2];
int nreq;
MPI::Offset offset;
for (k=0; k
nreq = 1;
fh.Seek( offset, MPI_SEEK_SET );
req[0] = fh.Iwrite( buf, n, MPI::INT);
if (k+1 < b) {
offset = offset + (s * n) * sizeof(int);
fh.Seek( offset, MPI_SEEK_SET );
nreq++;
req[1] = fh.Iwrite( buf2, n, MPI::INT );
}
MPI::Request::Waitall( nreq, req, statuses );
}
# No extra declarations are needed for the read step
for (k=0; k
nreq = 1;
fh.Seek( offset, MPI_SEEK_SET );
req[0] = fh.Iread( buf, n, MPI::INT );
if (k+1 < b) {
offset = offset + (s * n) * sizeof(int);
fh.Seek( offset, MPI_SEEK_SET );
nreq++;
req[1] = fh.Iread( buf2, n, MPI::INT );
}
MPI::Request::Waitall( nreq, req, statuses );
if (nreq == 2) {
}
}
int buf[MAX_BUFFER], buf2[MAX_BUFFER], ans;
MPI::Request req[2];
int nreq;
MPI::Offset offset;
for (k=0; k
nreq = 1;
fh.Seek( offset, MPI_SEEK_SET );
req[0] = fh.Iwrite( buf, n, MPI::INT);
if (k+1 < b) {
offset = offset + (s * n) * sizeof(int);
fh.Seek( offset, MPI_SEEK_SET );
nreq++;
req[1] = fh.Iwrite( buf2, n, MPI::INT );
}
MPI::Request::Waitall( nreq, req );
}
# No extra declarations are needed for the read step
for (k=0; k
nreq = 1;
fh.Seek( offset, MPI_SEEK_SET );
req[0] = fh.Iread( buf, n, MPI::INT );
if (k+1 < b) {
offset = offset + (s * n) * sizeof(int);
fh.Seek( offset, MPI_SEEK_SET );
nreq++;
req[1] = fh.Iread( buf2, n, MPI::INT );
}
MPI::Request::Waitall( nreq, req );
if (nreq == 2) {
}
}
# This test uses nonblocking I/O with shared file pointers
MPI::Status status;
int buf[MAX_BUFFER], ans;
int src, dest;
MPI::Request req;
for (k=0; k
req = fh.Iwrite_shared( buf, n, MPI::INT );
req.Wait( status );
}
# No extra declarations are needed for the read step
for (k=0; k
req = fh.Iread_shared( buf, n, MPI::INT );
req.Wait( status );
}
# This test uses nonblocking I/O with shared file pointers
int buf[MAX_BUFFER], ans;
int src, dest;
MPI::Request req;
for (k=0; k
req = fh.Iwrite_shared( buf, n, MPI::INT );
req.Wait( );
}
# No extra declarations are needed for the read step
for (k=0; k
req = fh.Iread_shared( buf, n, MPI::INT );
req.Wait( );
}
# This test uses collective I/O
MPI::Status status;
int buf[MAX_BUFFER], ans;
MPI::Datatype filetype;
MPI::Offset offset;
for (k=0; k
fh.Write_all( buf, n, MPI::INT, status);
}
# No extra declarations are needed for the read step
for (k=0; k
fh.Read_all( buf, n, MPI::INT, status);
}
# This test uses collective I/O
int buf[MAX_BUFFER], ans;
MPI::Datatype filetype;
MPI::Offset offset;
for (k=0; k
fh.Write_all( buf, n, MPI::INT);
}
# No extra declarations are needed for the read step
for (k=0; k
fh.Read_all( buf, n, MPI::INT);
}
# This test uses split collective I/O
MPI::Status status;
int buf[MAX_BUFFER], ans;
MPI::Datatype filetype;
MPI::Offset offset;
for (k=0; k
fh.Write_all_begin( buf, n, MPI::INT );
fh.Write_all_end( buf, status );
}
# No extra declarations are needed for the read step
for (k=0; k
fh.Read_all_begin( buf, n, MPI::INT);
fh.Read_all_end( buf, status);
}
# This test uses split collective I/O
int buf[MAX_BUFFER], ans;
MPI::Datatype filetype;
MPI::Offset offset;
for (k=0; k
fh.Write_all_begin( buf, n, MPI::INT );
fh.Write_all_end( buf );
}
# No extra declarations are needed for the read step
for (k=0; k
fh.Read_all_begin( buf, n, MPI::INT);
fh.Read_all_end( buf );
}
# This test uses the shared file pointers collectively.
MPI::Status status;
int buf[MAX_BUFFER], ans;
MPI::Offset offset;
for (k=0; k
fh.Write_ordered( buf, n, MPI::INT, status);
}
# No extra declarations are needed for the read step
for (k=0; k
fh.Read_ordered( buf, n, MPI::INT, status);
}
int buf[MAX_BUFFER], ans;
MPI::Offset offset;
for (k=0; k
fh.Write_ordered( buf, n, MPI::INT );
}
# No extra declarations are needed for the read step
for (k=0; k
fh.Read_ordered( buf, n, MPI::INT );
}
# This test uses the shared file pointers with split collectives.
MPI::Status status;
int buf[MAX_BUFFER], ans;
MPI::Offset offset;
for (k=0; k
fh.Write_ordered_begin( buf, n, MPI::INT);
fh.Write_ordered_end( buf, status);
}
# No extra declarations are needed for the read step
for (k=0; k
fh.Read_ordered_begin( buf, n, MPI::INT);
fh.Read_ordered_end( buf, status);
}
int buf[MAX_BUFFER], ans;
MPI::Offset offset;
for (k=0; k
fh.Write_ordered_begin( buf, n, MPI::INT);
fh.Write_ordered_end( buf );
}
# No extra declarations are needed for the read step
for (k=0; k
fh.Read_ordered_begin( buf, n, MPI::INT);
fh.Read_ordered_end( buf );
}
# This test uses the shared file pointers independently.
# We pass a token to control the oredering
MPI::Status status;
int buf[MAX_BUFFER], ans;
int src, dest;
for (k=0; k
fh.Write_shared( buf, n, MPI::INT, status);
}
# No extra declarations are needed for the read step
for (k=0; k
fh.Read_shared( buf, n, MPI::INT, status);
}
int buf[MAX_BUFFER], ans;
int src, dest;
for (k=0; k
fh.Write_shared( buf, n, MPI::INT );
}
# No extra declarations are needed for the read step
for (k=0; k
fh.Read_shared( buf, n, MPI::INT );
}