AIORI initialize() and finalize() functions.

master
Julian M. Kunkel 2018-07-14 09:29:08 +01:00
parent a0b8659cc8
commit 5ef95675bf
6 changed files with 54 additions and 24 deletions

View File

@ -149,5 +149,7 @@ ior_aiori_t dummy_aiori = {
DUMMY_rmdir,
DUMMY_access,
DUMMY_stat,
NULL,
NULL,
DUMMY_options
};

View File

@ -124,6 +124,8 @@ static void EMC_Close(void*, IOR_param_t*);
static void S3_Delete(char*, IOR_param_t*);
static void S3_Fsync(void*, IOR_param_t*);
static IOR_offset_t S3_GetFileSize(IOR_param_t*, MPI_Comm, char*);
static void S3_init();
static void S3_finalize();
/************************** D E C L A R A T I O N S ***************************/
@ -140,6 +142,8 @@ ior_aiori_t s3_aiori = {
.get_version = aiori_get_version,
.fsync = S3_Fsync,
.get_file_size = S3_GetFileSize,
.initialize = S3_init,
.finalize = S3_finalize
};
// "S3", plus EMC-extensions enabled
@ -155,6 +159,8 @@ ior_aiori_t s3_plus_aiori = {
.set_version = S3_SetVersion,
.fsync = S3_Fsync,
.get_file_size = S3_GetFileSize,
.initialize = S3_init,
.finalize = S3_finalize
};
// Use EMC-extensions for N:1 write, as well
@ -170,8 +176,22 @@ ior_aiori_t s3_emc_aiori = {
.set_version = S3_SetVersion,
.fsync = S3_Fsync,
.get_file_size = S3_GetFileSize,
.initialize = S3_init,
.finalize = S3_finalize
};
static void S3_init(){
/* This is supposed to be done before *any* threads are created.
* Could MPI_Init() create threads (or call multi-threaded
* libraries)? We'll assume so. */
AWS4C_CHECK( aws_init() );
}
static void S3_finalize(){
/* done once per program, after exiting all threads.
* NOTE: This fn doesn't return a value that can be checked for success. */
aws_cleanup();
}
/* modelled on similar macros in iordef.h */
#define CURL_ERR(MSG, CURL_ERRNO, PARAM) \

View File

@ -117,6 +117,28 @@ char* aiori_get_version()
return "";
}
void aiori_initialize(){
/* Sanity check, we were compiled with SOME backend, right? */
if (0 == aiori_count ()) {
ERR("No IO backends compiled into aiori. "
"Run 'configure --with-<backend>', and recompile.");
}
for (ior_aiori_t **tmp = available_aiori ; *tmp != NULL; ++tmp) {
if((*tmp)->initialize){
(*tmp)->initialize();
}
}
}
void aiori_finalize(){
for (ior_aiori_t **tmp = available_aiori ; *tmp != NULL; ++tmp) {
if((*tmp)->finalize){
(*tmp)->finalize();
}
}
}
const ior_aiori_t *aiori_select (const char *api)
{
char warn_str[256] = {0};

View File

@ -79,6 +79,8 @@ typedef struct ior_aiori {
int (*rmdir) (const char *path, IOR_param_t * param);
int (*access) (const char *path, int mode, IOR_param_t * param);
int (*stat) (const char *path, struct stat *buf, IOR_param_t * param);
void (*initialize)(); /* called once per program before MPI is started */
void (*finalize)(); /* called once per program after MPI is shutdown */
option_help * (*get_options)();
} ior_aiori_t;
@ -94,6 +96,8 @@ extern ior_aiori_t s3_plus_aiori;
extern ior_aiori_t s3_emc_aiori;
extern ior_aiori_t rados_aiori;
void aiori_initialize();
void aiori_finalize();
const ior_aiori_t *aiori_select (const char *api);
int aiori_count (void);
const char *aiori_default (void);

View File

@ -62,12 +62,6 @@ IOR_test_t * ior_run(int argc, char **argv, MPI_Comm world_com, FILE * world_out
MPI_CHECK(MPI_Comm_rank(mpi_comm_world, &rank), "cannot get rank");
PrintEarlyHeader();
/* Sanity check, we were compiled with SOME backend, right? */
if (0 == aiori_count ()) {
ERR("No IO backends compiled into ior. "
"Run 'configure --with-<backend>', and recompile.");
}
/* setup tests, and validate parameters */
tests_head = ParseCommandLine(argc, argv);
InitTests(tests_head, world_com);
@ -105,18 +99,13 @@ int ior_main(int argc, char **argv)
out_logfile = stdout;
out_resultfile = stdout;
aiori_initialize();
/*
* check -h option from commandline without starting MPI;
*/
tests_head = ParseCommandLine(argc, argv);
#ifdef USE_S3_AIORI
/* This is supposed to be done before *any* threads are created.
* Could MPI_Init() create threads (or call multi-threaded
* libraries)? We'll assume so. */
AWS4C_CHECK( aws_init() );
#endif
/* start the MPI code */
MPI_CHECK(MPI_Init(&argc, &argv), "cannot initialize MPI");
@ -131,12 +120,6 @@ int ior_main(int argc, char **argv)
/*MPI_CHECK(MPI_Errhandler_set(mpi_comm_world, MPI_ERRORS_RETURN),
"cannot set errhandler"); */
/* Sanity check, we were compiled with SOME backend, right? */
if (0 == aiori_count ()) {
ERR("No IO backends compiled into ior. "
"Run 'configure --with-<backend>', and recompile.");
}
/* setup tests, and validate parameters */
InitTests(tests_head, mpi_comm_world);
verbose = tests_head->params.verbose;
@ -173,11 +156,7 @@ int ior_main(int argc, char **argv)
MPI_CHECK(MPI_Finalize(), "cannot finalize MPI");
#ifdef USE_S3_AIORI
/* done once per program, after exiting all threads.
* NOTE: This fn doesn't return a value that can be checked for success. */
aws_cleanup();
#endif
aiori_finalize();
return totalErrorCount;
}

View File

@ -1,10 +1,13 @@
#include "mdtest.h"
#include "aiori.h"
int main(int argc, char **argv) {
aiori_initialize();
MPI_Init(&argc, &argv);
mdtest_run(argc, argv, MPI_COMM_WORLD, stdout);
MPI_Finalize();
aiori_finalize();
return 0;
}