Merge pull request #83 from DDNStorage/initbackends

Initialize only the required backends
master
Julian Kunkel 2018-09-19 10:27:11 +01:00 committed by GitHub
commit e5c8a11769
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 94 additions and 34 deletions

View File

@ -12,6 +12,8 @@
*
\******************************************************************************/
#include <assert.h>
#include <stdbool.h>
#include "aiori.h"
#if defined(HAVE_SYS_STATVFS_H)
@ -131,34 +133,90 @@ char* aiori_get_version()
return "";
}
static int is_initialized = FALSE;
static bool is_initialized = false;
void aiori_initialize(){
if (is_initialized) return;
is_initialized = TRUE;
/* 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();
}
}
static void init_or_fini_internal(const ior_aiori_t *test_backend,
const bool init)
{
if (init)
{
if (test_backend->initialize)
test_backend->initialize();
}
else
{
if (test_backend->finalize)
test_backend->finalize();
}
}
void aiori_finalize(){
if (! is_initialized) return;
is_initialized = FALSE;
static void init_or_fini(IOR_test_t *tests, const bool init)
{
/* 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)->finalize){
(*tmp)->finalize();
}
}
/* Pointer to the initialize of finalize function */
/* if tests is NULL, initialize or finalize all available backends */
if (tests == NULL)
{
for (ior_aiori_t **tmp = available_aiori ; *tmp != NULL; ++tmp)
init_or_fini_internal(*tmp, init);
return;
}
for (IOR_test_t *t = tests; t != NULL; t = t->next)
{
IOR_param_t *params = &t->params;
assert(params != NULL);
const ior_aiori_t *test_backend = params->backend;
assert(test_backend != NULL);
init_or_fini_internal(test_backend, init);
}
}
/**
* Initialize IO backends.
*
* @param[in] tests Pointers to the first test
*
* This function initializes all backends which will be used. If tests is NULL
* all available backends are initialized.
*/
void aiori_initialize(IOR_test_t *tests)
{
if (is_initialized)
return;
init_or_fini(tests, true);
is_initialized = true;
}
/**
* Finalize IO backends.
*
* @param[in] tests Pointers to the first test
*
* This function finalizes all backends which were used. If tests is NULL
* all available backends are finialized.
*/
void aiori_finalize(IOR_test_t *tests)
{
if (!is_initialized)
return;
is_initialized = false;
init_or_fini(tests, false);
}
const ior_aiori_t *aiori_select (const char *api)

View File

@ -97,8 +97,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();
void aiori_initialize(IOR_test_t * tests);
void aiori_finalize(IOR_test_t * tests);
const ior_aiori_t *aiori_select (const char *api);
int aiori_count (void);
void aiori_supported_apis(char * APIs);

View File

@ -98,8 +98,6 @@ int ior_main(int argc, char **argv)
out_logfile = stdout;
out_resultfile = stdout;
aiori_initialize();
/*
* check -h option from commandline without starting MPI;
*/
@ -123,6 +121,8 @@ int ior_main(int argc, char **argv)
InitTests(tests_head, mpi_comm_world);
verbose = tests_head->params.verbose;
aiori_initialize(tests_head);
PrintHeader(argc, argv);
/* perform each test */
@ -151,11 +151,11 @@ int ior_main(int argc, char **argv)
/* display finish time */
PrintTestEnds();
DestroyTests(tests_head);
MPI_CHECK(MPI_Finalize(), "cannot finalize MPI");
aiori_finalize();
aiori_finalize(tests_head);
DestroyTests(tests_head);
return totalErrorCount;
}

View File

@ -77,9 +77,11 @@ typedef struct IO_BUFFERS
* USER_GUIDE
*/
struct ior_aiori;
typedef struct
{
const void * backend;
const struct ior_aiori * backend;
char * debug; /* debug info string */
unsigned int mode; /* file permissions */
unsigned int openFlags; /* open flags (see also <open>) */

View File

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