From 321837d16f970b51f77cb415c85c89d77c0f874d Mon Sep 17 00:00:00 2001 From: John Jenkins Date: Fri, 19 Sep 2014 08:39:25 -0500 Subject: [PATCH 1/4] refactor access to the backend For "non-traditional" backends that expose a different namespace than that directly accessible by straight POSIX calls, the access() call shouldn't be directly used by the benchmark. POSIX calls can still occur as a result in the current iteration of the code (e.g., uniqueDir option resulting in calling mkdir), but for the moment I assume that backends will exit if an incompatible option is selected. --- src/aiori-HDF5.c | 3 ++- src/aiori-MPIIO.c | 3 ++- src/aiori-NCMPI.c | 3 ++- src/aiori-POSIX.c | 7 ++++++- src/aiori.h | 3 +++ src/ior.c | 11 ++++++----- 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/aiori-HDF5.c b/src/aiori-HDF5.c index 7649be0..816d1d2 100644 --- a/src/aiori-HDF5.c +++ b/src/aiori-HDF5.c @@ -105,7 +105,8 @@ ior_aiori_t hdf5_aiori = { HDF5_Delete, HDF5_SetVersion, HDF5_Fsync, - HDF5_GetFileSize + HDF5_GetFileSize, + POSIX_Access }; static hid_t xferPropList; /* xfer property list */ diff --git a/src/aiori-MPIIO.c b/src/aiori-MPIIO.c index 4920f6d..555c552 100644 --- a/src/aiori-MPIIO.c +++ b/src/aiori-MPIIO.c @@ -53,7 +53,8 @@ ior_aiori_t mpiio_aiori = { MPIIO_Delete, MPIIO_SetVersion, MPIIO_Fsync, - MPIIO_GetFileSize + MPIIO_GetFileSize, + POSIX_Access }; /***************************** F U N C T I O N S ******************************/ diff --git a/src/aiori-NCMPI.c b/src/aiori-NCMPI.c index e3e678f..57d326b 100644 --- a/src/aiori-NCMPI.c +++ b/src/aiori-NCMPI.c @@ -69,7 +69,8 @@ ior_aiori_t ncmpi_aiori = { NCMPI_Delete, NCMPI_SetVersion, NCMPI_Fsync, - NCMPI_GetFileSize + NCMPI_GetFileSize, + POSIX_Access }; /***************************** F U N C T I O N S ******************************/ diff --git a/src/aiori-POSIX.c b/src/aiori-POSIX.c index ca6065e..b110aea 100644 --- a/src/aiori-POSIX.c +++ b/src/aiori-POSIX.c @@ -77,7 +77,8 @@ ior_aiori_t posix_aiori = { POSIX_Delete, POSIX_SetVersion, POSIX_Fsync, - POSIX_GetFileSize + POSIX_GetFileSize, + POSIX_Access }; /***************************** F U N C T I O N S ******************************/ @@ -451,3 +452,7 @@ 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); +} diff --git a/src/aiori.h b/src/aiori.h index d88abbf..e4fa644 100644 --- a/src/aiori.h +++ b/src/aiori.h @@ -60,6 +60,7 @@ 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 *); + int (*access)(char *, int mode); } ior_aiori_t; ior_aiori_t posix_aiori; @@ -70,4 +71,6 @@ 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); + #endif /* not _AIORI_H */ diff --git a/src/ior.c b/src/ior.c index 163a59c..7fbad80 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 (backend->access(dir, F_OK) != 0) { if (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); } } From 68139504b21fcce0730165101ec07fc832bbaac9 Mon Sep 17 00:00:00 2001 From: John Jenkins Date: Fri, 19 Sep 2014 11:29:38 -0500 Subject: [PATCH 2/4] init/finalize support Non-POSIX systems may need special initialization/finalization code to e.g., set up network contexts, ping servers for storage system view, etc. --- src/aiori-HDF5.c | 2 ++ src/aiori-MPIIO.c | 2 ++ src/aiori-NCMPI.c | 2 ++ src/aiori-POSIX.c | 14 ++++++++++++++ src/aiori.h | 9 +++++++++ src/ior.c | 6 ++++++ 6 files changed, 35 insertions(+) diff --git a/src/aiori-HDF5.c b/src/aiori-HDF5.c index 816d1d2..f99dcd7 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", + POSIX_Init, + POSIX_Finalize, HDF5_Create, HDF5_Open, HDF5_Xfer, diff --git a/src/aiori-MPIIO.c b/src/aiori-MPIIO.c index 555c552..d67dd09 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", + POSIX_Init, + POSIX_Finalize, MPIIO_Create, MPIIO_Open, MPIIO_Xfer, diff --git a/src/aiori-NCMPI.c b/src/aiori-NCMPI.c index 57d326b..eca586c 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", + POSIX_Init, + POSIX_Finalize, NCMPI_Create, NCMPI_Open, NCMPI_Xfer, diff --git a/src/aiori-POSIX.c b/src/aiori-POSIX.c index b110aea..1ce5dc3 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", + POSIX_Init, + POSIX_Finalize, POSIX_Create, POSIX_Open, POSIX_Xfer, @@ -456,3 +458,15 @@ static IOR_offset_t POSIX_GetFileSize(IOR_param_t * test, MPI_Comm testComm, int POSIX_Access(char *testFileName, int mode){ return access(testFileName, mode); } + +void POSIX_Init(IOR_param_t *test) { + /* no-op at the moment, though perhaps some of the POSIX-related setup + * code (such as mkdir's for the uniqueDir option) can go here in the + * future */ +} + +void POSIX_Finalize(IOR_param_t *test) { + /* no-op at the moment, though perhaps some of the POSIX-related + * teardown code (deleting test files/directories) can go here in the + * future */ +} diff --git a/src/aiori.h b/src/aiori.h index e4fa644..27ec848 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,8 @@ 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); } ior_aiori_t; @@ -73,4 +79,7 @@ IOR_offset_t MPIIO_GetFileSize(IOR_param_t * test, MPI_Comm testComm, int POSIX_Access(char *testFileName, int mode); +void POSIX_Init(IOR_param_t *test); +void POSIX_Finalize(IOR_param_t *test); + #endif /* not _AIORI_H */ diff --git a/src/ior.c b/src/ior.c index 7fbad80..46329e4 100644 --- a/src/ior.c +++ b/src/ior.c @@ -1972,6 +1972,9 @@ static void TestIoSys(IOR_test_t *test) hog_buf = HogMemory(params); + /* do backend-specific initialization */ + backend->init(params); + startTime = GetTimeStamp(); /* loop over test iterations */ @@ -2229,6 +2232,9 @@ static void TestIoSys(IOR_test_t *test) rankOffset = 0; } + /* do backend-specific finalization */ + backend->finalize(params); + MPI_CHECK(MPI_Comm_free(&testComm), "MPI_Comm_free() error"); if (params->summary_every_test) { From 94584733c2ebe8c04e33dd90bce7100ca48ec1ff Mon Sep 17 00:00:00 2001 From: John Jenkins Date: Fri, 19 Sep 2014 11:40:12 -0500 Subject: [PATCH 3/4] put mkdir into the backend The notion of a "directory" may not be valid with a non-POSIX namespace (e.g., an object store), so put the mkdir down a level. Ideally, creating directories should be relegated to the *_init functions so that the logic is not happening at the "top-level" (PrependDir), but that's a little too much code churn for now, so going with the easier option. Backends without a notion of directories should simply spit out a warning or error. --- src/aiori-HDF5.c | 3 ++- src/aiori-MPIIO.c | 3 ++- src/aiori-NCMPI.c | 3 ++- src/aiori-POSIX.c | 15 ++++++++++----- src/aiori.h | 6 ++++-- src/ior.c | 2 +- 6 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/aiori-HDF5.c b/src/aiori-HDF5.c index f99dcd7..89b3b1d 100644 --- a/src/aiori-HDF5.c +++ b/src/aiori-HDF5.c @@ -108,7 +108,8 @@ ior_aiori_t hdf5_aiori = { HDF5_SetVersion, HDF5_Fsync, HDF5_GetFileSize, - POSIX_Access + POSIX_Access, + POSIX_Mkdir }; static hid_t xferPropList; /* xfer property list */ diff --git a/src/aiori-MPIIO.c b/src/aiori-MPIIO.c index d67dd09..555e4f7 100644 --- a/src/aiori-MPIIO.c +++ b/src/aiori-MPIIO.c @@ -56,7 +56,8 @@ ior_aiori_t mpiio_aiori = { MPIIO_SetVersion, MPIIO_Fsync, MPIIO_GetFileSize, - POSIX_Access + 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 eca586c..a7d63fe 100644 --- a/src/aiori-NCMPI.c +++ b/src/aiori-NCMPI.c @@ -72,7 +72,8 @@ ior_aiori_t ncmpi_aiori = { NCMPI_SetVersion, NCMPI_Fsync, NCMPI_GetFileSize, - POSIX_Access + 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 1ce5dc3..78b1dcd 100644 --- a/src/aiori-POSIX.c +++ b/src/aiori-POSIX.c @@ -80,7 +80,8 @@ ior_aiori_t posix_aiori = { POSIX_SetVersion, POSIX_Fsync, POSIX_GetFileSize, - POSIX_Access + POSIX_Access, + POSIX_Mkdir }; /***************************** F U N C T I O N S ******************************/ @@ -455,10 +456,6 @@ 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); -} - void POSIX_Init(IOR_param_t *test) { /* no-op at the moment, though perhaps some of the POSIX-related setup * code (such as mkdir's for the uniqueDir option) can go here in the @@ -470,3 +467,11 @@ void POSIX_Finalize(IOR_param_t *test) { * teardown code (deleting test files/directories) can go here in the * future */ } + +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 27ec848..7030315 100644 --- a/src/aiori.h +++ b/src/aiori.h @@ -67,6 +67,7 @@ typedef struct ior_aiori { /* 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; @@ -77,9 +78,10 @@ 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); - void POSIX_Init(IOR_param_t *test); void POSIX_Finalize(IOR_param_t *test); +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 46329e4..bb39195 100644 --- a/src/ior.c +++ b/src/ior.c @@ -1084,7 +1084,7 @@ static char *PrependDir(IOR_param_t * test, char *rootDir) /* dir doesn't exist, so create */ if (backend->access(dir, F_OK) != 0) { - if (mkdir(dir, S_IRWXU) < 0) { + if (backend->mkdir(dir, S_IRWXU) < 0) { ERR("cannot create directory"); } From 095ab6e25c09a536f4e44ff8e0a098420487c22e Mon Sep 17 00:00:00 2001 From: John Jenkins Date: Fri, 19 Sep 2014 14:55:04 -0500 Subject: [PATCH 4/4] removed POSIX_Init and POSIX_Finalize if init/fini are going to be no-ops, have explicit no-op support --- src/aiori-HDF5.c | 4 ++-- src/aiori-MPIIO.c | 4 ++-- src/aiori-NCMPI.c | 4 ++-- src/aiori-POSIX.c | 16 ++-------------- src/aiori.h | 3 --- src/ior.c | 6 ++++-- 6 files changed, 12 insertions(+), 25 deletions(-) diff --git a/src/aiori-HDF5.c b/src/aiori-HDF5.c index 89b3b1d..808a7ea 100644 --- a/src/aiori-HDF5.c +++ b/src/aiori-HDF5.c @@ -98,8 +98,8 @@ static IOR_offset_t HDF5_GetFileSize(IOR_param_t *, MPI_Comm, char *); ior_aiori_t hdf5_aiori = { "HDF5", - POSIX_Init, - POSIX_Finalize, + NULL, /* no-op init, finalize */ + NULL, HDF5_Create, HDF5_Open, HDF5_Xfer, diff --git a/src/aiori-MPIIO.c b/src/aiori-MPIIO.c index 555e4f7..90758a8 100644 --- a/src/aiori-MPIIO.c +++ b/src/aiori-MPIIO.c @@ -46,8 +46,8 @@ static void MPIIO_Fsync(void *, IOR_param_t *); ior_aiori_t mpiio_aiori = { "MPIIO", - POSIX_Init, - POSIX_Finalize, + NULL, /* no-op init, finalize */ + NULL, MPIIO_Create, MPIIO_Open, MPIIO_Xfer, diff --git a/src/aiori-NCMPI.c b/src/aiori-NCMPI.c index a7d63fe..7614b8f 100644 --- a/src/aiori-NCMPI.c +++ b/src/aiori-NCMPI.c @@ -62,8 +62,8 @@ static IOR_offset_t NCMPI_GetFileSize(IOR_param_t *, MPI_Comm, char *); ior_aiori_t ncmpi_aiori = { "NCMPI", - POSIX_Init, - POSIX_Finalize, + NULL, /* no-op init, finalize */ + NULL, NCMPI_Create, NCMPI_Open, NCMPI_Xfer, diff --git a/src/aiori-POSIX.c b/src/aiori-POSIX.c index 78b1dcd..e6bf19a 100644 --- a/src/aiori-POSIX.c +++ b/src/aiori-POSIX.c @@ -70,8 +70,8 @@ static IOR_offset_t POSIX_GetFileSize(IOR_param_t *, MPI_Comm, char *); ior_aiori_t posix_aiori = { "POSIX", - POSIX_Init, - POSIX_Finalize, + NULL, /* no-op init, finalize */ + NULL, POSIX_Create, POSIX_Open, POSIX_Xfer, @@ -456,18 +456,6 @@ static IOR_offset_t POSIX_GetFileSize(IOR_param_t * test, MPI_Comm testComm, return (aggFileSizeFromStat); } -void POSIX_Init(IOR_param_t *test) { - /* no-op at the moment, though perhaps some of the POSIX-related setup - * code (such as mkdir's for the uniqueDir option) can go here in the - * future */ -} - -void POSIX_Finalize(IOR_param_t *test) { - /* no-op at the moment, though perhaps some of the POSIX-related - * teardown code (deleting test files/directories) can go here in the - * future */ -} - int POSIX_Access(char *testFileName, int mode){ return access(testFileName, mode); } diff --git a/src/aiori.h b/src/aiori.h index 7030315..b2f7b52 100644 --- a/src/aiori.h +++ b/src/aiori.h @@ -78,9 +78,6 @@ ior_aiori_t ncmpi_aiori; IOR_offset_t MPIIO_GetFileSize(IOR_param_t * test, MPI_Comm testComm, char *testFileName); -void POSIX_Init(IOR_param_t *test); -void POSIX_Finalize(IOR_param_t *test); - int POSIX_Access(char *testFileName, int mode); int POSIX_Mkdir(char *dir, int mode); diff --git a/src/ior.c b/src/ior.c index bb39195..de51c0e 100644 --- a/src/ior.c +++ b/src/ior.c @@ -1973,7 +1973,8 @@ static void TestIoSys(IOR_test_t *test) hog_buf = HogMemory(params); /* do backend-specific initialization */ - backend->init(params); + if (backend->init) + backend->init(params); startTime = GetTimeStamp(); @@ -2233,7 +2234,8 @@ static void TestIoSys(IOR_test_t *test) } /* do backend-specific finalization */ - backend->finalize(params); + if (backend->finalize) + backend->finalize(params); MPI_CHECK(MPI_Comm_free(&testComm), "MPI_Comm_free() error");