Commit 96d8f4e9 authored by Sangmin Seo's avatar Sangmin Seo Committed by Rob Latham
Browse files

Add tests for nonblocking collective I/O.



Added nonblocking version of bigtype, hindexed_io, rdwrord, and setviewcur
for testing nonblocking collective I/O functions.
Signed-off-by: Rob Latham's avatarRob Latham <robl@mcs.anl.gov>
parent c26c6627
......@@ -1521,6 +1521,7 @@ AC_OUTPUT(maint/testmerge \
spawn/Makefile \
topo/Makefile \
io/Makefile \
io/testlist \
f77/Makefile \
f77/attr/Makefile \
f77/attr/attraints.h \
......
......@@ -27,5 +27,13 @@ noinst_PROGRAMS = \
bigtype \
hindexed_io
if BUILD_MPIX_TESTS
noinst_PROGRAMS += \
i_bigtype \
i_hindexed_io \
i_rdwrord \
i_setviewcur
endif
clean-local:
-rm -f testfile testfile.*
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/*
* (C) 2014 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
#include <mpi.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
//#define NUM_X 536870911
#define NUM_X 536870912
#define NUM_Y 1
//#define BIGDT 2147483643
#define BIGDT 2147483647
/*
static char MTEST_Descrip[] = "Nonblocking file read/write for bigtype";
*/
int main(int argc, char **argv)
{
MPI_File fh;
int i, j;
size_t k;
MPI_Datatype inner_type, rem_type, mem_type;
MPI_Datatype int_type, file_type;
int *buf_write, *buf_read;
int rc;
MPI_Aint disp[2];
int block_len[2];
MPI_Datatype type[2];
MPI_Status status;
MPI_Request request;
MPI_Init(&argc, &argv);
if (sizeof(MPI_Aint) <= sizeof(int)) {
/* can't test on this platform... */
goto exit;
}
k = 0;
/* create a large buffer 2 */
buf_write = malloc(NUM_X * NUM_Y * sizeof(int));
buf_read = malloc(NUM_X * NUM_Y * sizeof(int));
memset(buf_read, 0, NUM_X * NUM_Y * sizeof(int));
for (i = 0; i < NUM_X; i++) {
for (j = 0; j < NUM_Y; j++) {
buf_write[k] = k;
k++;
}
}
/* Big Datatype (2^31 - 1 bytes) */
MPI_Type_contiguous(BIGDT, MPI_BYTE, &inner_type);
/* Small Datatype (1 byte) */
MPI_Type_contiguous(1, MPI_BYTE, &rem_type);
type[0] = inner_type;
type[1] = rem_type;
block_len[0] = 1;
block_len[1] = 1;
disp[0] = 0;
disp[1] = BIGDT;
/* combine both types */
MPI_Type_struct(2, block_len, disp, type, &mem_type);
MPI_Type_commit(&mem_type);
MPI_Type_free(&rem_type);
MPI_Type_free(&inner_type);
MPI_Type_contiguous(4, MPI_BYTE, &int_type);
{
/* This creates a big type that is actually contituous, touching an
* optimization that was at one point buggy */
MPI_Type_vector(1, NUM_X, 1, int_type, &file_type);
}
MPI_Type_commit(&file_type);
MPI_Type_free(&int_type);
rc = MPI_File_open(MPI_COMM_WORLD, "testfile",
MPI_MODE_RDWR | MPI_MODE_CREATE, MPI_INFO_NULL, &fh);
if (rc != MPI_SUCCESS) {
printf("Can't open file: %s\n", "testfile");
exit(1);
}
rc = MPI_File_set_view(fh, 2144, MPI_BYTE, file_type, "native",
MPI_INFO_NULL);
if (rc != MPI_SUCCESS) {
printf("ERROR SET VIEW\n");
exit(1);
}
/* write everything */
rc = MPIX_File_iwrite_at_all(fh, 0, buf_write, 1, mem_type, &request);
if (rc != MPI_SUCCESS) {
printf("%d ERROR IWRITE AT ALL\n", rc);
exit(1);
}
MPI_Wait(&request, &status);
rc = MPI_File_set_view(fh, 2144, MPI_BYTE, file_type, "native",
MPI_INFO_NULL);
if (rc != MPI_SUCCESS) {
printf("ERROR SET VIEW\n");
exit(1);
}
/* read everything */
rc = MPIX_File_iread_at_all(fh, 0, buf_read, 1, mem_type, &request);
if (rc != MPI_SUCCESS) {
printf("%d ERROR IREAD AT ALL\n", rc);
exit(1);
}
MPI_Wait(&request, &status);
for (k = 0; k < NUM_X * NUM_Y; k++) {
if (buf_read[k] != buf_write[k]) {
fprintf(stderr, "Verfiy Failed index %zu: expected %d found %d\n",
k, buf_write[k], buf_read[k]);
assert(0);
}
}
free(buf_write);
free(buf_read);
MPI_File_close(&fh);
MPI_Type_free(&mem_type);
MPI_Type_free(&file_type);
exit:
MPI_Finalize();
printf(" No Errors\n");
return 0;
}
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/*
* (C) 2014 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
#include <mpi.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#define DATA_SIZE 324*4
#define PAD 256
#define HEADER 144
#define BLK_COUNT 3
static void handle_error(int errcode, char *str)
{
char msg[MPI_MAX_ERROR_STRING];
int resultlen;
MPI_Error_string(errcode, msg, &resultlen);
fprintf(stderr, "%s: %s\n", str, msg);
MPI_Abort(MPI_COMM_WORLD, 1);
}
#define CHECK(fn) { int errcode; errcode = (fn); if (errcode != MPI_SUCCESS) handle_error(errcode, #fn); }
int main(int argc, char **argv)
{
MPI_File fh;
MPI_Datatype file_type, mem_type;
int *data = NULL;
int *verify = NULL;
int data_size = DATA_SIZE;
int i, j, k, nr_errors = 0;
MPI_Aint disp[BLK_COUNT];
int block_lens[BLK_COUNT];
char *filename = "unnamed.dat";
MPI_Status status;
MPI_Request request;
MPI_Init(&argc, &argv);
disp[0] = (MPI_Aint) (PAD);
disp[1] = (MPI_Aint) (data_size * 1 + PAD);
disp[2] = (MPI_Aint) (data_size * 2 + PAD);
block_lens[0] = data_size;
block_lens[1] = data_size;
block_lens[2] = data_size;
data = malloc(data_size);
verify = malloc(data_size * BLK_COUNT + HEADER + PAD);
for (i = 0; i < data_size / sizeof(int); i++)
data[i] = i;
MPI_Type_create_hindexed_block(BLK_COUNT, data_size, disp, MPI_BYTE,
&file_type);
MPI_Type_commit(&file_type);
MPI_Type_create_hvector(BLK_COUNT, data_size, 0, MPI_BYTE, &mem_type);
MPI_Type_commit(&mem_type);
if (1 < argc)
filename = argv[1];
CHECK(MPI_File_open(MPI_COMM_WORLD, filename,
MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE,
MPI_INFO_NULL, &fh) != 0);
CHECK(MPI_File_set_view(fh, HEADER, MPI_BYTE, file_type, "native",
MPI_INFO_NULL));
/* write everything */
CHECK(MPIX_File_iwrite_at_all(fh, 0, data, 1, mem_type, &request));
MPI_Wait(&request, &status);
/* verify */
CHECK(MPI_File_set_view(fh, 0, MPI_BYTE, MPI_BYTE, "native",
MPI_INFO_NULL));
CHECK(MPIX_File_iread_at_all(fh, 0,
verify, (HEADER + PAD + BLK_COUNT * DATA_SIZE) / sizeof(int),
MPI_INT, &request));
MPI_Wait(&request, &status);
/* header and block padding should have no data */
for (i = 0; i < (HEADER + PAD) / sizeof(int); i++) {
if (verify[i] != 0) {
nr_errors++;
fprintf(stderr, "expected 0, read %d\n", verify[i]);
}
}
/* blocks are replicated */
for (j = 0; j < BLK_COUNT; j++) {
for (k = 0; k < (DATA_SIZE / sizeof(int)); k++) {
if (verify[(HEADER+PAD)/sizeof(int) + k + j*(DATA_SIZE/sizeof(int))]
!= data[k]) {
nr_errors++;
fprintf(stderr, "expcted %d, read %d\n", data[k],
verify[(HEADER+PAD)/sizeof(int) + k +
j*(DATA_SIZE/sizeof(int))]);
}
i++;
}
}
MPI_File_close(&fh);
MPI_Type_free(&mem_type);
MPI_Type_free(&file_type);
if (nr_errors == 0)
printf(" No Errors\n");
MPI_Finalize();
free(data);
return 0;
}
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/*
* (C) 2014 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
#include "mpi.h"
#include <stdio.h>
#include <stdlib.h>
#include "mpitest.h"
/*
static char MTEST_Descrip[] = "Test reading and writing ordered output";
*/
int main(int argc, char *argv[])
{
int errs = 0;
int size, rank, i, *buf, rc;
MPI_File fh;
MPI_Comm comm;
MPI_Status status;
MPI_Request request;
MTest_Init(&argc, &argv);
comm = MPI_COMM_WORLD;
MPI_File_open(comm, (char *)"test.ord",
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(size * sizeof(int));
buf[0] = rank;
rc = MPI_File_write_ordered(fh, buf, 1, MPI_INT, &status);
if (rc != MPI_SUCCESS) {
MTestPrintErrorMsg("File_write_ordered", rc);
errs++;
}
/* make sure all writes finish before we seek/read */
MPI_Barrier(comm);
/* Set the individual pointer to 0, since we want to use a iread_all */
MPI_File_seek(fh, 0, MPI_SEEK_SET);
rc = MPIX_File_iread_all(fh, buf, size, MPI_INT, &request);
if (rc != MPI_SUCCESS) {
MTestPrintErrorMsg("File_iread_all", rc);
errs++;
}
MPI_Wait(&request, &status);
for (i = 0; i < size; i++) {
if (buf[i] != i) {
errs++;
fprintf(stderr, "%d: buf[%d] = %d\n", rank, i, buf[i]);
}
}
MPI_File_seek_shared(fh, 0, MPI_SEEK_SET);
for (i = 0; i < size; i++) buf[i] = -1;
MPI_File_read_ordered(fh, buf, 1, MPI_INT, &status);
if (buf[0] != rank) {
errs++;
fprintf(stderr, "%d: buf[0] = %d\n", rank, buf[0]);
}
free(buf);
MPI_File_close(&fh);
MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/*
* (C) 2014 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
#include "mpi.h"
#include <stdio.h>
#include <stdlib.h>
#include "mpitest.h"
/*
static char MTEST_Descrip[] = "Test set_view with DISPLACEMENT_CURRENT";
*/
int main(int argc, char *argv[])
{
int errs = 0, err;
int size, rank, *buf;
MPI_Offset offset;
MPI_File fh;
MPI_Comm comm;
MPI_Status status;
MPI_Request request;
MTest_Init(&argc, &argv);
/* This test reads a header then sets the view to every "size" int,
* using set view and current displacement. The file is first written
* using a combination of collective and ordered writes */
comm = MPI_COMM_WORLD;
err = MPI_File_open(comm, (char *) "test.ord",
MPI_MODE_WRONLY | MPI_MODE_CREATE, MPI_INFO_NULL, &fh);
if (err) {
errs++;
MTestPrintErrorMsg("Open(1)", err);
}
MPI_Comm_size(comm, &size);
MPI_Comm_rank(comm, &rank);
buf = (int *) malloc(size * sizeof(int));
buf[0] = size;
err = MPIX_File_iwrite_all(fh, buf, 1, MPI_INT, &request);
if (err) {
errs++;
MTestPrintErrorMsg("Iwrite_all", err);
}
err = MPI_Wait(&request, &status);
if (err) {
errs++;
MTestPrintErrorMsg("Wait", err);
}
err = MPI_File_get_position(fh, &offset);
if (err) {
errs++;
MTestPrintErrorMsg("Get_position", err);
}
err = MPI_File_seek_shared(fh, offset, MPI_SEEK_SET);
if (err) {
errs++;
MTestPrintErrorMsg("Seek_shared", err);
}
buf[0] = rank;
err = MPI_File_write_ordered(fh, buf, 1, MPI_INT, &status);
if (err) {
errs++;
MTestPrintErrorMsg("Write_ordered", err);
}
err = MPI_File_close(&fh);
if (err) {
errs++;
MTestPrintErrorMsg("Close(1)", err);
}
/* Reopen the file as sequential */
err = MPI_File_open(comm, (char *) "test.ord",
MPI_MODE_RDONLY | MPI_MODE_SEQUENTIAL |
MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh);
if (err) {
errs++;
MTestPrintErrorMsg("Open(Read)", err);
}
if (rank == 0) {
err = MPI_File_read_shared(fh, buf, 1, MPI_INT, &status);
if (err) {
errs++;
MTestPrintErrorMsg("Read_all", err);
}
if (buf[0] != size) {
errs++;
fprintf(stderr, "Unexpected value for the header = %d, should be %d\n",
buf[0], size);
fflush(stderr);
}
}
MPI_Barrier(comm);
/* All processes must provide the same file view for MODE_SEQUENTIAL */
/* See MPI 2.1, 13.3 - DISPLACEMENT_CURRENT is *required* for
* MODE_SEQUENTIAL files */
err = MPI_File_set_view(fh, MPI_DISPLACEMENT_CURRENT, MPI_INT,
MPI_INT, (char *) "native", MPI_INFO_NULL);
if (err) {
errs++;
MTestPrintErrorMsg("Set_view (DISPLACEMENT_CURRENT)", err);
}
buf[0] = -1;
err = MPI_File_read_ordered(fh, buf, 1, MPI_INT, &status);
if (err) {
errs++;
MTestPrintErrorMsg("Read_all", err);
}
if (buf[0] != rank) {
errs++;
fprintf(stderr, "%d: buf[0] = %d\n", rank, buf[0]);
fflush(stderr);
}
free(buf);
err = MPI_File_close(&fh);
if (err) {
errs++;
MTestPrintErrorMsg("Close(2)", err);
}
MTest_Finalize(errs);
MPI_Finalize();
return 0;
}
......@@ -11,3 +11,7 @@ resized 1
resized2 1 xfail=ticket2088
bigtype 1
hindexed_io 1
@mpix@ i_bigtype 1
@mpix@ i_hindexed_io 1
@mpix@ i_rdwrord 4
@mpix@ i_setviewcur 4
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment