|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* (C) 2003 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
#include "mpi.h"
|
|
Packit Service |
c5cf8c |
#include <stdio.h>
|
|
Packit Service |
c5cf8c |
#include <stdlib.h>
|
|
Packit Service |
c5cf8c |
#include "mpitest.h"
|
|
Packit Service |
c5cf8c |
#include "mpitestconf.h"
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_STRING_H
|
|
Packit Service |
c5cf8c |
#include <string.h>
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_MEMORY_H
|
|
Packit Service |
c5cf8c |
#include <memory.h>
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
static char MTEST_Descrip[] = "Test reading and writing zero bytes (set status correctly)";
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int main(int argc, char *argv[])
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int errs = 0;
|
|
Packit Service |
c5cf8c |
int size, rank, i, *buf, count, rc;
|
|
Packit Service |
c5cf8c |
MPI_File fh;
|
|
Packit Service |
c5cf8c |
MPI_Comm comm;
|
|
Packit Service |
c5cf8c |
MPI_Status status;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Init(&argc, &argv);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
comm = MPI_COMM_WORLD;
|
|
Packit Service |
c5cf8c |
rc = MPI_File_open(comm, (char *) "test.ord",
|
|
Packit Service |
c5cf8c |
MPI_MODE_RDWR | MPI_MODE_CREATE |
|
|
Packit Service |
c5cf8c |
MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh;;
|
|
Packit Service |
c5cf8c |
if (rc) {
|
|
Packit Service |
c5cf8c |
MTestPrintErrorMsg("File_open", rc);
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
/* If the open fails, there isn't anything else that we can do */
|
|
Packit Service |
c5cf8c |
goto fn_fail;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Comm_size(comm, &size);
|
|
Packit Service |
c5cf8c |
MPI_Comm_rank(comm, &rank;;
|
|
Packit Service |
c5cf8c |
buf = (int *) malloc(size * sizeof(int));
|
|
Packit Service |
c5cf8c |
buf[0] = rank;
|
|
Packit Service |
c5cf8c |
/* Write to file */
|
|
Packit Service |
c5cf8c |
rc = MPI_File_write_ordered(fh, buf, 1, MPI_INT, &status);
|
|
Packit Service |
c5cf8c |
if (rc) {
|
|
Packit Service |
c5cf8c |
MTestPrintErrorMsg("File_write_ordered", rc);
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
MPI_Get_count(&status, MPI_INT, &count);
|
|
Packit Service |
c5cf8c |
if (count != 1) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "Wrong count (%d) on write-ordered\n", count);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Set the individual pointer to 0, since we want to use a read_all */
|
|
Packit Service |
c5cf8c |
MPI_File_seek(fh, 0, MPI_SEEK_SET);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Read nothing (check status) */
|
|
Packit Service |
c5cf8c |
memset(&status, 0xff, sizeof(MPI_Status));
|
|
Packit Service |
c5cf8c |
MPI_File_read(fh, buf, 0, MPI_INT, &status);
|
|
Packit Service |
c5cf8c |
MPI_Get_count(&status, MPI_INT, &count);
|
|
Packit Service |
c5cf8c |
if (count != 0) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "Count not zero (%d) on read\n", count);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Write nothing (check status) */
|
|
Packit Service |
c5cf8c |
memset(&status, 0xff, sizeof(MPI_Status));
|
|
Packit Service |
c5cf8c |
MPI_File_write(fh, buf, 0, MPI_INT, &status);
|
|
Packit Service |
c5cf8c |
if (count != 0) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "Count not zero (%d) on write\n", count);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Read shared nothing (check status) */
|
|
Packit Service |
c5cf8c |
MPI_File_seek_shared(fh, 0, MPI_SEEK_SET);
|
|
Packit Service |
c5cf8c |
/* Read nothing (check status) */
|
|
Packit Service |
c5cf8c |
memset(&status, 0xff, sizeof(MPI_Status));
|
|
Packit Service |
c5cf8c |
MPI_File_read_shared(fh, buf, 0, MPI_INT, &status);
|
|
Packit Service |
c5cf8c |
MPI_Get_count(&status, MPI_INT, &count);
|
|
Packit Service |
c5cf8c |
if (count != 0) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "Count not zero (%d) on read shared\n", count);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Write nothing (check status) */
|
|
Packit Service |
c5cf8c |
memset(&status, 0xff, sizeof(MPI_Status));
|
|
Packit Service |
c5cf8c |
MPI_File_write_shared(fh, buf, 0, MPI_INT, &status);
|
|
Packit Service |
c5cf8c |
if (count != 0) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "Count not zero (%d) on write\n", count);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Barrier(comm);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_File_seek_shared(fh, 0, MPI_SEEK_SET);
|
|
Packit Service |
c5cf8c |
for (i = 0; i < size; i++)
|
|
Packit Service |
c5cf8c |
buf[i] = -1;
|
|
Packit Service |
c5cf8c |
MPI_File_read_ordered(fh, buf, 1, MPI_INT, &status);
|
|
Packit Service |
c5cf8c |
if (buf[0] != rank) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "%d: buf = %d\n", rank, buf[0]);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
free(buf);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_File_close(&fh;;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
fn_fail:
|
|
Packit Service |
c5cf8c |
MTest_Finalize(errs);
|
|
Packit Service |
c5cf8c |
return MTestReturnValue(errs);
|
|
Packit Service |
c5cf8c |
}
|