|
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 |
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
static char MTEST_Descrip[] = "Test file_set_view";
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* access style is explicitly described as modifiable. values include
|
|
Packit Service |
c5cf8c |
* read_once, read_mostly, write_once, write_mostlye, random
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
int main(int argc, char *argv[])
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int errs = 0, err;
|
|
Packit Service |
c5cf8c |
int buf[10];
|
|
Packit Service |
c5cf8c |
int rank;
|
|
Packit Service |
c5cf8c |
MPI_Comm comm;
|
|
Packit Service |
c5cf8c |
MPI_Status status;
|
|
Packit Service |
c5cf8c |
MPI_File fh;
|
|
Packit Service |
c5cf8c |
MPI_Info infoin, infoout;
|
|
Packit Service |
c5cf8c |
char value[1024];
|
|
Packit Service |
c5cf8c |
int flag, count;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Init(&argc, &argv);
|
|
Packit Service |
c5cf8c |
comm = MPI_COMM_WORLD;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Comm_rank(comm, &rank;;
|
|
Packit Service |
c5cf8c |
MPI_Info_create(&infoin);
|
|
Packit Service |
c5cf8c |
MPI_Info_set(infoin, (char *) "access_style", (char *) "write_once,random");
|
|
Packit Service |
c5cf8c |
MPI_File_open(comm, (char *) "testfile", MPI_MODE_RDWR | MPI_MODE_CREATE, infoin, &fh;;
|
|
Packit Service |
c5cf8c |
buf[0] = rank;
|
|
Packit Service |
c5cf8c |
err = MPI_File_write_ordered(fh, buf, 1, MPI_INT, &status);
|
|
Packit Service |
c5cf8c |
if (err) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
MTestPrintError(err);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Info_set(infoin, (char *) "access_style", (char *) "read_once");
|
|
Packit Service |
c5cf8c |
err = MPI_File_seek_shared(fh, 0, MPI_SEEK_SET);
|
|
Packit Service |
c5cf8c |
if (err) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
MTestPrintError(err);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
err = MPI_File_set_info(fh, infoin);
|
|
Packit Service |
c5cf8c |
if (err) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
MTestPrintError(err);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPI_Info_free(&infoin);
|
|
Packit Service |
c5cf8c |
buf[0] = -1;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
err = MPI_File_read_ordered(fh, buf, 1, MPI_INT, &status);
|
|
Packit Service |
c5cf8c |
if (err) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
MTestPrintError(err);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPI_Get_count(&status, MPI_INT, &count);
|
|
Packit Service |
c5cf8c |
if (count != 1) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
printf("Expected to read one int, read %d\n", count);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if (buf[0] != rank) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
printf("Did not read expected value (%d)\n", buf[0]);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
err = MPI_File_get_info(fh, &infoout);
|
|
Packit Service |
c5cf8c |
if (err) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
MTestPrintError(err);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPI_Info_get(infoout, (char *) "access_style", 1024, value, &flag;;
|
|
Packit Service |
c5cf8c |
/* Note that an implementation is allowed to ignore the set_info,
|
|
Packit Service |
c5cf8c |
* so we'll accept either the original or the updated version */
|
|
Packit Service |
c5cf8c |
if (!flag) {
|
|
Packit Service |
c5cf8c |
;
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* errs++;
|
|
Packit Service |
c5cf8c |
* printf("Access style hint not saved\n");
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
if (strcmp(value, "read_once") != 0 && strcmp(value, "write_once,random") != 0) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
printf("value for access_style unexpected; is %s\n", value);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPI_Info_free(&infoout);
|
|
Packit Service |
c5cf8c |
err = MPI_File_close(&fh;;
|
|
Packit Service |
c5cf8c |
if (err) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
MTestPrintError(err);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPI_Barrier(comm);
|
|
Packit Service |
c5cf8c |
MPI_Comm_rank(comm, &rank;;
|
|
Packit Service |
c5cf8c |
if (rank == 0) {
|
|
Packit Service |
c5cf8c |
err = MPI_File_delete((char *) "testfile", MPI_INFO_NULL);
|
|
Packit Service |
c5cf8c |
if (err) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
MTestPrintError(err);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Finalize(errs);
|
|
Packit Service |
c5cf8c |
return MTestReturnValue(errs);
|
|
Packit Service |
c5cf8c |
}
|