diff --git a/src/aiori-HDF5.c b/src/aiori-HDF5.c index 7649be0..808a7ea 100644 --- a/src/aiori-HDF5.c +++ b/src/aiori-HDF5.c @@ -98,6 +98,8 @@ static IOR_offset_t HDF5_GetFileSize(IOR_param_t *, MPI_Comm, char *); ior_aiori_t hdf5_aiori = { "HDF5", + NULL, /* no-op init, finalize */ + NULL, HDF5_Create, HDF5_Open, HDF5_Xfer, @@ -105,7 +107,9 @@ ior_aiori_t hdf5_aiori = { HDF5_Delete, HDF5_SetVersion, HDF5_Fsync, - HDF5_GetFileSize + HDF5_GetFileSize, + POSIX_Access, + POSIX_Mkdir }; static hid_t xferPropList; /* xfer property list */ diff --git a/src/aiori-MPIIO.c b/src/aiori-MPIIO.c index 4920f6d..90758a8 100644 --- a/src/aiori-MPIIO.c +++ b/src/aiori-MPIIO.c @@ -46,6 +46,8 @@ static void MPIIO_Fsync(void *, IOR_param_t *); ior_aiori_t mpiio_aiori = { "MPIIO", + NULL, /* no-op init, finalize */ + NULL, MPIIO_Create, MPIIO_Open, MPIIO_Xfer, @@ -53,7 +55,9 @@ ior_aiori_t mpiio_aiori = { MPIIO_Delete, MPIIO_SetVersion, MPIIO_Fsync, - MPIIO_GetFileSize + MPIIO_GetFileSize, + POSIX_Access, + POSIX_Mkdir }; /***************************** F U N C T I O N S ******************************/ diff --git a/src/aiori-NCMPI.c b/src/aiori-NCMPI.c index e3e678f..7614b8f 100644 --- a/src/aiori-NCMPI.c +++ b/src/aiori-NCMPI.c @@ -62,6 +62,8 @@ static IOR_offset_t NCMPI_GetFileSize(IOR_param_t *, MPI_Comm, char *); ior_aiori_t ncmpi_aiori = { "NCMPI", + NULL, /* no-op init, finalize */ + NULL, NCMPI_Create, NCMPI_Open, NCMPI_Xfer, @@ -69,7 +71,9 @@ ior_aiori_t ncmpi_aiori = { NCMPI_Delete, NCMPI_SetVersion, NCMPI_Fsync, - NCMPI_GetFileSize + NCMPI_GetFileSize, + POSIX_Access, + POSIX_Mkdir }; /***************************** F U N C T I O N S ******************************/ diff --git a/src/aiori-POSIX.c b/src/aiori-POSIX.c index ca6065e..e6bf19a 100644 --- a/src/aiori-POSIX.c +++ b/src/aiori-POSIX.c @@ -70,6 +70,8 @@ static IOR_offset_t POSIX_GetFileSize(IOR_param_t *, MPI_Comm, char *); ior_aiori_t posix_aiori = { "POSIX", + NULL, /* no-op init, finalize */ + NULL, POSIX_Create, POSIX_Open, POSIX_Xfer, @@ -77,7 +79,9 @@ ior_aiori_t posix_aiori = { POSIX_Delete, POSIX_SetVersion, POSIX_Fsync, - POSIX_GetFileSize + POSIX_GetFileSize, + POSIX_Access, + POSIX_Mkdir }; /***************************** F U N C T I O N S ******************************/ @@ -451,3 +455,11 @@ static IOR_offset_t POSIX_GetFileSize(IOR_param_t * test, MPI_Comm testComm, return (aggFileSizeFromStat); } + +int POSIX_Access(char *testFileName, int mode){ + return access(testFileName, mode); +} + +int POSIX_Mkdir(char *dir, int mode){ + return mkdir(dir, mode); +} diff --git a/src/aiori.h b/src/aiori.h index d88abbf..b2f7b52 100644 --- a/src/aiori.h +++ b/src/aiori.h @@ -51,6 +51,10 @@ typedef struct ior_aiori { char *name; + /* init and finalizes should be called exactly once during a program + * run */ + void (*init)(IOR_param_t *); + void (*finalize)(IOR_param_t *); void *(*create)(char *, IOR_param_t *); void *(*open)(char *, IOR_param_t *); IOR_offset_t (*xfer)(int, void *, IOR_size_t *, @@ -60,6 +64,10 @@ typedef struct ior_aiori { void (*set_version)(IOR_param_t *); void (*fsync)(void *, IOR_param_t *); IOR_offset_t (*get_file_size)(IOR_param_t *, MPI_Comm, char *); + /* these functions are expected to behave identically to their POSIX + * equivalents */ + int (*access)(char *, int mode); + int (*mkdir)(char *, int mode); } ior_aiori_t; ior_aiori_t posix_aiori; @@ -70,4 +78,7 @@ ior_aiori_t ncmpi_aiori; IOR_offset_t MPIIO_GetFileSize(IOR_param_t * test, MPI_Comm testComm, char *testFileName); +int POSIX_Access(char *testFileName, int mode); +int POSIX_Mkdir(char *dir, int mode); + #endif /* not _AIORI_H */ diff --git a/src/ior.c b/src/ior.c index 163a59c..de51c0e 100644 --- a/src/ior.c +++ b/src/ior.c @@ -1083,14 +1083,15 @@ static char *PrependDir(IOR_param_t * test, char *rootDir) sprintf(dir, "%s%d", dir, (rank + rankOffset) % test->numTasks); /* dir doesn't exist, so create */ - if (access(dir, F_OK) != 0) { - if (mkdir(dir, S_IRWXU) < 0) { + if (backend->access(dir, F_OK) != 0) { + if (backend->mkdir(dir, S_IRWXU) < 0) { ERR("cannot create directory"); } /* check if correct permissions */ - } else if (access(dir, R_OK) != 0 || access(dir, W_OK) != 0 || - access(dir, X_OK) != 0) { + } else if (backend->access(dir, R_OK) != 0 || + backend->access(dir, W_OK) != 0 || + backend->access(dir, X_OK) != 0) { ERR("invalid directory permissions"); } @@ -1261,7 +1262,7 @@ static void RemoveFile(char *testFileName, int filePerProc, IOR_param_t * test) rankOffset = 0; GetTestFileName(testFileName, test); } - if (access(testFileName, F_OK) == 0) { + if (backend->access(testFileName, F_OK) == 0) { backend->delete(testFileName, test); } if (test->reorderTasksRandom == TRUE) { @@ -1269,7 +1270,7 @@ static void RemoveFile(char *testFileName, int filePerProc, IOR_param_t * test) GetTestFileName(testFileName, test); } } else { - if ((rank == 0) && (access(testFileName, F_OK) == 0)) { + if ((rank == 0) && (backend->access(testFileName, F_OK) == 0)) { backend->delete(testFileName, test); } } @@ -1971,6 +1972,10 @@ static void TestIoSys(IOR_test_t *test) hog_buf = HogMemory(params); + /* do backend-specific initialization */ + if (backend->init) + backend->init(params); + startTime = GetTimeStamp(); /* loop over test iterations */ @@ -2228,6 +2233,10 @@ static void TestIoSys(IOR_test_t *test) rankOffset = 0; } + /* do backend-specific finalization */ + if (backend->finalize) + backend->finalize(params); + MPI_CHECK(MPI_Comm_free(&testComm), "MPI_Comm_free() error"); if (params->summary_every_test) {