From 4ae5742f877e9500a5c3909dcb106dc9269fa58c Mon Sep 17 00:00:00 2001 From: "Christopher J. Morrone" Date: Wed, 9 Nov 2011 16:13:44 -0800 Subject: [PATCH] Replace defaults.h with a simple initializer function. --- doc/USER_GUIDE | 3 +- src/Makefile.am | 2 +- src/aiori.h | 6 +- src/defaults.h | 134 -------------------------------------------- src/ior.c | 74 ++++++++++++++++++------ src/iordef.h | 6 +- src/parse_options.c | 5 +- 7 files changed, 68 insertions(+), 162 deletions(-) delete mode 100644 src/defaults.h diff --git a/doc/USER_GUIDE b/doc/USER_GUIDE index ce1399f..bb265dd 100644 --- a/doc/USER_GUIDE +++ b/doc/USER_GUIDE @@ -476,8 +476,7 @@ RUN IOR STOP ===============> stop script <=============== -NOTES: * Not all test parameters need be set. The defaults can be viewed in - IOR/src/C/defaults.h. +NOTES: * Not all test parameters need be set. * White space is ignored in script, as are comments starting with '#'. diff --git a/src/Makefile.am b/src/Makefile.am index cbad09a..c6003a8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,7 @@ bin_PROGRAMS = ior ior_SOURCES = ior.c utilities.c parse_options.c -ior_SOURCES += ior.h aiori.h iordef.h defaults.h +ior_SOURCES += ior.h aiori.h iordef.h ior_LDADD = if USE_POSIX_AIORI diff --git a/src/aiori.h b/src/aiori.h index 1737787..47056a7 100644 --- a/src/aiori.h +++ b/src/aiori.h @@ -51,8 +51,8 @@ * The parameter struct holds all of the "global" data to be passed, * as well as results to be parsed. * - * NOTE: If this is changed, also change: - * defaultParameters [defaults.h] + * NOTE: If IOR_Param_t is changed, also change: + * init_IOR_Param_t() [ior.c] * DisplayUsage() [ior.c] * ShowTest() [ior.c] * DecodeDirective() [parse_options.c] @@ -182,4 +182,6 @@ typedef struct ior_aiori { IOR_offset_t (*get_file_size)(IOR_param_t *, MPI_Comm, char *); } ior_aiori_t; +void init_IOR_Param_t(IOR_param_t *p); + #endif /* not _AIORI_H */ diff --git a/src/defaults.h b/src/defaults.h deleted file mode 100644 index 2596b25..0000000 --- a/src/defaults.h +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************\ -* * -* Copyright (c) 2003, The Regents of the University of California * -* See the file COPYRIGHT for a complete copyright notice and license. * -* * -******************************************************************************** -* -* IOR's default settings -* -\******************************************************************************/ - -#ifndef _IOR_DEFAULTS_H -#define _IOR_DEFAULTS_H - -#include "aiori.h" - - -/*************************** D E F I N I T I O N S ****************************/ - -/******************************************************************************/ -/* - * Default parameter settings for a test script. This should be the minimum - * test runnable. - */ - -IOR_param_t defaultParameters = { - "", /* debug info string */ - IOR_IRUSR | /* file permissions */ - IOR_IWUSR | - IOR_IRGRP | - IOR_IWGRP, - IOR_RDWR | /* open flags POSIX/MPIIO */ - IOR_CREAT, - -1, /* test reference number */ - "POSIX", /* api */ - "", /* api version */ - "HOST(OSTYPE)", /* platform */ - "testFile", /* test file */ - "", /* filename for fpp read check */ - "", /* hints file */ - "", /* options */ - 0, /* numTasks */ - 1, /* nodes */ - 1, /* tasks per node */ - 1, /* repetitions */ - -1, /* rep counter */ - 0, /* multiple files */ - 0, /* intertest delay */ - NULL, NULL, /* write results array */ - NULL, NULL, /* read results array */ - WRITE, /* used in HDF5 for create(WRITE) and open(READ) */ - TRUE, /* read flag */ - TRUE, /* write flag */ - FALSE, /* file-per-proc flag */ - FALSE, /* reorder tasks */ - 1, /* task file offset for read */ - FALSE, /* reorder tasks random */ - 0, /* reorder tasks random seed offset value*/ - FALSE, /* check write */ - FALSE, /* check read */ - FALSE, /* keep test file on exit */ - FALSE, /* keep test file with errors */ - FALSE, /* error found in data check */ - FALSE, /* halt on error */ - FALSE, /* collective I/O */ - 1, /* segment count */ - 1048576, /* block size */ - 262144, /* transfer size */ - 0, /* offset */ - NULL, /* expected aggregate file size array */ - NULL, /* stat'ed aggregate file size array */ - NULL, /* xfered aggregate file size array */ - NULL, /* aggregate file size array used for b/w */ - FALSE, /* preallocate file size */ - FALSE, /* use file view */ - FALSE, /* use shared file pointer */ - FALSE, /* use strided datatype */ - FALSE, /* use O_DIRECT, bypassing I/O buffers */ - FALSE, /* show hints */ - FALSE, /* show help */ - FALSE, /* unique directory for each file-per-process */ - FALSE, /* do not delete test file before access */ - FALSE, /* use file offset as stored signature */ - 0, /* deadline in seconds for any test phase (0=off) */ - 0, /* max time in minutes to run tests (0=off) */ - 0, /* warn on outlier N seconds from mean (0=off) */ - 0, /* verbosity */ - 0, /* set time stamp signature */ - 0, /* time stamp signature value */ - NULL, /* additional fd for fpp read check */ - -1, /* random seed for write/read check */ - 0, /* access is to random, not sequential, offsets */ - MPI_COMM_WORLD, /* MPI communicator */ - - /* POSIX */ - FALSE, /* single transfer (no retry) */ - FALSE, /* fsync after each POSIX write */ - FALSE, /* fsync after POSIX write close */ - - /* MPI */ - 0, /* MPI transfer datatype */ - 0, /* MPI file view datatype */ - - /* HDF5 */ - FALSE, /* individual data sets */ - FALSE, /* no fill */ - 1, /* alignment */ - - /* NCMPI */ - 0, /* var_id handle for datasets */ - - /* Lustre */ - 0, /* lustre_stripe_count */ - 0, /* lustre_stripe_size */ - -1, /* lustre_start_ost */ - 0, /* lustre_set_striping */ - 0, /* lustre_ignore_locks */ - -#if USE_UNDOC_OPT - 0, /* corrupt file(s) */ - 0, /* fill the file system */ - 0, /* include delete time */ - 0, /* multiple rereads of file */ - - /* NFS */ - "", /* absolute path to NFS servers */ - "", /* prefix for NFS server name */ - 0, /* number of NFS servers to be used */ -#endif /* USE_UNDOC_OPT */ - - 0, /* test's unique ID */ - 0 /* intraTestBarriers */ -}; -#endif /* not _IOR_DEFAULTS_H */ diff --git a/src/ior.c b/src/ior.c index 1e1970a..1f7d0be 100644 --- a/src/ior.c +++ b/src/ior.c @@ -24,8 +24,7 @@ /************************** D E C L A R A T I O N S ***************************/ -extern IOR_param_t defaultParameters, - initialTestParams; +extern IOR_param_t initialTestParams; extern int errno; /* error number */ extern char ** environ; int totalErrorCount = 0; @@ -136,6 +135,34 @@ main(int argc, /***************************** F U N C T I O N S ******************************/ +/* + * Initialize an IOR_param_t structure to the defaults + */ +void init_IOR_Param_t(IOR_param_t *p) +{ + memset(p, 0, sizeof(IOR_param_t)); + + p->mode = IOR_IRUSR|IOR_IWUSR|IOR_IRGRP|IOR_IWGRP; + p->openFlags = IOR_RDWR|IOR_CREAT; + p->TestNum = -1; + strncpy(p->api, "POSIX", MAX_STR); /* FIXME - use first api in list instead */ + strncpy(p->platform, "HOST(OSTYPE)", MAX_STR); + strncpy(p->testFileName, "testFile", MAXPATHLEN); + p->nodes = 1; + p->tasksPerNode = 1; + p->repetitions = 1; + p->repCounter = -1; + p->open = WRITE; + p->taskPerNodeOffset = 1; + p->segmentCount = 1; + p->blockSize = 1048576; + p->transferSize = 262144; + p->randomSeed = -1; + p->testComm = MPI_COMM_WORLD; + p->setAlignment = 1; + p->lustre_start_ost = -1; +} + /******************************************************************************/ /* * Bind the global "backend" pointer to the requested backend AIORI's @@ -2257,18 +2284,21 @@ TimeDeviation(void) void ValidTests(IOR_param_t * test) { - /* get the version of the tests */ + IOR_param_t defaults; + init_IOR_Param_t(&defaults); + /* get the version of the tests */ AioriBind(test->api); backend->set_version(test); if (test->repetitions <= 0) - WARN_RESET("too few test repetitions", repetitions); + WARN_RESET("too few test repetitions", + test, &defaults, repetitions); if (test->numTasks <= 0) ERR("too few tasks for testing"); if (test->interTestDelay < 0) WARN_RESET("inter-test delay must be nonnegative value", - interTestDelay); + test, &defaults, interTestDelay); if (test->readFile != TRUE && test->writeFile != TRUE && test->checkRead != TRUE && test->checkWrite != TRUE) ERR("test must write, read, or check file"); @@ -2316,32 +2346,40 @@ ValidTests(IOR_param_t * test) && ((test->numTasks * test->blockSize) > (2*(IOR_offset_t)GIBIBYTE))) ERR("segment size must be < 2GiB"); if ((strcmp(test->api, "POSIX") != 0) && test->singleXferAttempt) - WARN_RESET("retry only available in POSIX", singleXferAttempt); + WARN_RESET("retry only available in POSIX", + test, &defaults, singleXferAttempt); if ((strcmp(test->api, "POSIX") != 0) && test->fsync) - WARN_RESET("fsync() only available in POSIX", fsync); + WARN_RESET("fsync() only available in POSIX", + test, &defaults, fsync); if ((strcmp(test->api, "MPIIO") != 0) && test->preallocate) - WARN_RESET("preallocation only available in MPIIO", preallocate); + WARN_RESET("preallocation only available in MPIIO", + test, &defaults, preallocate); if ((strcmp(test->api, "MPIIO") != 0) && test->useFileView) - WARN_RESET("file view only available in MPIIO", useFileView); + WARN_RESET("file view only available in MPIIO", + test, &defaults, useFileView); if ((strcmp(test->api, "MPIIO") != 0) && test->useSharedFilePointer) WARN_RESET("shared file pointer only available in MPIIO", - useSharedFilePointer); + test, &defaults, useSharedFilePointer); if ((strcmp(test->api, "MPIIO") == 0) && test->useSharedFilePointer) - WARN_RESET("shared file pointer not implemented", useSharedFilePointer); + WARN_RESET("shared file pointer not implemented", + test, &defaults, useSharedFilePointer); if ((strcmp(test->api, "MPIIO") != 0) && test->useStridedDatatype) WARN_RESET("strided datatype only available in MPIIO", - useStridedDatatype); + test, &defaults, useStridedDatatype); if ((strcmp(test->api, "MPIIO") == 0) && test->useStridedDatatype) - WARN_RESET("strided datatype not implemented", useStridedDatatype); + WARN_RESET("strided datatype not implemented", + test, &defaults, useStridedDatatype); if ((strcmp(test->api, "MPIIO") == 0) && test->useStridedDatatype && (test->blockSize < sizeof(IOR_size_t) || test->transferSize < sizeof(IOR_size_t))) ERR("need larger file size for strided datatype in MPIIO"); if ((strcmp(test->api, "POSIX") == 0) && test->showHints) - WARN_RESET("hints not available in POSIX", showHints); + WARN_RESET("hints not available in POSIX", + test, &defaults, showHints); if ((strcmp(test->api, "POSIX") == 0) && test->collective) - WARN_RESET("collective not available in POSIX", collective); + WARN_RESET("collective not available in POSIX", + test, &defaults, collective); if (test->reorderTasks == TRUE && test->reorderTasksRandom == TRUE) ERR("Both Constant and Random task re-ordering specified. Choose one and resubmit"); if (test->randomOffset && test->reorderTasksRandom && test->filePerProc == FALSE) @@ -2362,9 +2400,10 @@ ValidTests(IOR_param_t * test) ERR("random offset not available with NCMPI"); if ((strcmp(test->api, "HDF5") != 0) && test->individualDataSets) WARN_RESET("individual datasets only available in HDF5", - individualDataSets); + test, &defaults, individualDataSets); if ((strcmp(test->api, "HDF5") == 0) && test->individualDataSets) - WARN_RESET("individual data sets not implemented", individualDataSets); + WARN_RESET("individual data sets not implemented", + test, &defaults, individualDataSets); if ((strcmp(test->api, "NCMPI") == 0) && test->filePerProc) ERR("file-per-proc not available in current NCMPI"); if (test->noFill) { @@ -2635,3 +2674,4 @@ WriteTimes(IOR_param_t * test, test->id, iteration, (int)rank, timer[i][iteration], timerName); } } /* WriteTimes() */ + diff --git a/src/iordef.h b/src/iordef.h index ae2148b..747f983 100644 --- a/src/iordef.h +++ b/src/iordef.h @@ -122,11 +122,11 @@ typedef long long int IOR_size_t; /* * WARN_RESET will display a custom error message and set value to default */ -#define WARN_RESET(MSG, VAL) do { \ - test->VAL = defaultParameters.VAL; \ +#define WARN_RESET(MSG, TO_STRUCT_PTR, FROM_STRUCT_PTR, MEMBER) do { \ + (TO_STRUCT_PTR)->MEMBER = (FROM_STRUCT_PTR)->MEMBER; \ if (rank == 0) { \ fprintf(stdout, "WARNING: %s. Using value of %d.\n", \ - MSG, test->VAL); \ + MSG, (TO_STRUCT_PTR)->MEMBER); \ } \ fflush(stdout); \ } while (0) diff --git a/src/parse_options.c b/src/parse_options.c index e7fbdf1..268b8ce 100644 --- a/src/parse_options.c +++ b/src/parse_options.c @@ -10,7 +10,6 @@ \******************************************************************************/ #include "ior.h" -#include "defaults.h" /* IOR defaults */ #include #include @@ -331,7 +330,6 @@ ReadConfigScript(char * scriptName) return(head); } /* ReadConfigScript() */ - /******************************************************************************/ /* * Parse Commandline. @@ -348,7 +346,7 @@ ParseCommandLine(int argc, char ** argv) /* suppress getopt() error message when a character is unrecognized */ opterr = 0; - initialTestParams = defaultParameters; + init_IOR_Param_t(&initialTestParams); GetPlatformName(initialTestParams.platform); initialTestParams.writeFile = initialTestParams.readFile = FALSE; initialTestParams.checkWrite = initialTestParams.checkRead = FALSE; @@ -432,3 +430,4 @@ ParseCommandLine(int argc, char ** argv) return(tests); } /* ParseCommandLine() */ +