More simple code cleanup

master
Christopher J. Morrone 2011-11-11 15:11:28 -08:00
parent 240e5ce93f
commit 0072f26946
8 changed files with 152 additions and 332 deletions

View File

@ -69,7 +69,7 @@
#endif /* H5_VERS_MAJOR > 1 && H5_VERS_MINOR > 6 */
/**************************** P R O T O T Y P E S *****************************/
IOR_offset_t SeekOffset_HDF5(void *, IOR_offset_t, IOR_param_t *);
static IOR_offset_t SeekOffset_HDF5(void *, IOR_offset_t, IOR_param_t *);
void SetHints(MPI_Info *, char *);
void SetupDataSet_HDF5(void *, IOR_param_t *);
void ShowHints(MPI_Info *);
@ -111,21 +111,17 @@ int newlyOpenedFile; /* newly opened file */
/***************************** F U N C T I O N S ******************************/
/******************************************************************************/
/*
* Create and open a file through the HDF5 interface.
*/
void *IOR_Create_HDF5(char *testFileName, IOR_param_t * param)
{
return IOR_Open_HDF5(testFileName, param);
} /* IOR_Create_HDF5() */
}
/******************************************************************************/
/*
* Open a file through the HDF5 interface.
*/
void *IOR_Open_HDF5(char *testFileName, IOR_param_t * param)
{
hid_t accessPropList, createPropList;
@ -323,13 +319,11 @@ void *IOR_Open_HDF5(char *testFileName, IOR_param_t * param)
HDF5_CHECK(dataSpace, "cannot create simple data space");
return (fd);
} /* IOR_Open_HDF5() */
}
/******************************************************************************/
/*
* Write or read access to file using the HDF5 interface.
*/
IOR_offset_t
IOR_Xfer_HDF5(int access,
void *fd,
@ -404,23 +398,19 @@ IOR_Xfer_HDF5(int access,
"cannot read from data set");
}
return (length);
} /* IOR_Xfer_HDF5() */
}
/******************************************************************************/
/*
* Perform fsync().
*/
void IOR_Fsync_HDF5(void *fd, IOR_param_t * param)
{
;
} /* IOR_Fsync_HDF5() */
}
/******************************************************************************/
/*
* Close a file through the HDF5 interface.
*/
void IOR_Close_HDF5(void *fd, IOR_param_t * param)
{
if (param->fd_fppReadCheck == NULL) {
@ -435,24 +425,20 @@ void IOR_Close_HDF5(void *fd, IOR_param_t * param)
}
HDF5_CHECK(H5Fclose(*(hid_t *) fd), "cannot close file");
free(fd);
} /* IOR_Close_HDF5() */
}
/******************************************************************************/
/*
* Delete a file through the HDF5 interface.
*/
void IOR_Delete_HDF5(char *testFileName, IOR_param_t * param)
{
if (unlink(testFileName) != 0)
WARN("cannot delete file");
} /* IOR_Delete_HDF5() */
}
/******************************************************************************/
/*
* Determine api version.
*/
void IOR_SetVersion_HDF5(IOR_param_t * test)
{
unsigned major, minor, release;
@ -467,16 +453,13 @@ void IOR_SetVersion_HDF5(IOR_param_t * test)
#else /* H5_HAVE_PARALLEL */
strcat(test->apiVersion, " (Parallel)");
#endif /* not H5_HAVE_PARALLEL */
} /* IOR_SetVersion_HDF5() */
}
/************************ L O C A L F U N C T I O N S ***********************/
/******************************************************************************/
/*
* Seek to offset in file using the HDF5 interface and set up hyperslab.
*/
IOR_offset_t SeekOffset_HDF5(void *fd, IOR_offset_t offset, IOR_param_t * param)
static IOR_offset_t SeekOffset_HDF5(void *fd, IOR_offset_t offset,
IOR_param_t * param)
{
IOR_offset_t segmentSize;
hsize_t hsStride[NUM_DIMS], hsCount[NUM_DIMS], hsBlock[NUM_DIMS];
@ -512,12 +495,10 @@ IOR_offset_t SeekOffset_HDF5(void *fd, IOR_offset_t offset, IOR_param_t * param)
return (offset);
} /* SeekOffset_HDF5() */
/******************************************************************************/
/*
* Create HDF5 data set.
*/
void SetupDataSet_HDF5(void *fd, IOR_param_t * param)
static void SetupDataSet_HDF5(void *fd, IOR_param_t * param)
{
char dataSetName[MAX_STR];
hid_t dataSetPropList;
@ -573,16 +554,13 @@ void SetupDataSet_HDF5(void *fd, IOR_param_t * param)
dataSet = H5Dopen(*(hid_t *) fd, dataSetName);
HDF5_CHECK(dataSet, "cannot create data set");
}
}
} /* SetupDataSet_HDF5() */
/******************************************************************************/
/*
* Use MPIIO call to get file size.
*/
IOR_offset_t
IOR_GetFileSize_HDF5(IOR_param_t * test, MPI_Comm testComm, char *testFileName)
{
return (IOR_GetFileSize_MPIIO(test, testComm, testFileName));
} /* IOR_GetFileSize_HDF5() */
}

View File

@ -58,21 +58,17 @@ ior_aiori_t mpiio_aiori = {
/***************************** F U N C T I O N S ******************************/
/******************************************************************************/
/*
* Create and open a file through the MPIIO interface.
*/
void *IOR_Create_MPIIO(char *testFileName, IOR_param_t * param)
{
return IOR_Open_MPIIO(testFileName, param);
} /* IOR_Create_MPIIO() */
}
/******************************************************************************/
/*
* Open a file through the MPIIO interface. Setup file view.
*/
void *IOR_Open_MPIIO(char *testFileName, IOR_param_t * param)
{
int fd_mode = (int)0,
@ -211,13 +207,11 @@ void *IOR_Open_MPIIO(char *testFileName, IOR_param_t * param)
"cannot set file view");
}
return ((void *)fd);
} /* IOR_Open_MPIIO() */
}
/******************************************************************************/
/*
* Write or read access to file using the MPIIO interface.
*/
IOR_offset_t
IOR_Xfer_MPIIO(int access,
void *fd,
@ -338,23 +332,19 @@ IOR_Xfer_MPIIO(int access,
}
}
return (length);
} /* IOR_Xfer_MPIIO() */
}
/******************************************************************************/
/*
* Perform fsync().
*/
void IOR_Fsync_MPIIO(void *fd, IOR_param_t * param)
{
;
} /* IOR_Fsync_MPIIO() */
/******************************************************************************/
/*
* Close a file through the MPIIO interface.
*/
void IOR_Close_MPIIO(void *fd, IOR_param_t * param)
{
MPI_CHECK(MPI_File_close((MPI_File *) fd), "cannot close file");
@ -368,24 +358,20 @@ void IOR_Close_MPIIO(void *fd, IOR_param_t * param)
"cannot free MPI transfer datatype");
}
free(fd);
} /* IOR_Close_MPIIO() */
}
/******************************************************************************/
/*
* Delete a file through the MPIIO interface.
*/
void IOR_Delete_MPIIO(char *testFileName, IOR_param_t * param)
{
MPI_CHECK(MPI_File_delete(testFileName, (MPI_Info) MPI_INFO_NULL),
"cannot delete file");
} /* IOR_Delete_MPIIO() */
}
/******************************************************************************/
/*
* Determine api version.
*/
void IOR_SetVersion_MPIIO(IOR_param_t * test)
{
int version, subversion;
@ -393,15 +379,11 @@ void IOR_SetVersion_MPIIO(IOR_param_t * test)
"cannot get MPI version");
sprintf(test->apiVersion, "%s (version=%d, subversion=%d)",
test->api, version, subversion);
} /* IOR_SetVersion_MPIIO() */
}
/************************ L O C A L F U N C T I O N S ***********************/
/******************************************************************************/
/*
* Seek to offset in file using the MPIIO interface.
*/
static IOR_offset_t
SeekOffset_MPIIO(MPI_File fd, IOR_offset_t offset, IOR_param_t * param)
{
@ -438,13 +420,11 @@ SeekOffset_MPIIO(MPI_File fd, IOR_offset_t offset, IOR_param_t * param)
MPI_CHECK(MPI_File_seek(fd, tempOffset, MPI_SEEK_SET),
"cannot seek offset");
return (offset);
} /* SeekOffset_MPIIO() */
}
/******************************************************************************/
/*
* Use MPI_File_get_size() to return aggregate file size.
*/
IOR_offset_t
IOR_GetFileSize_MPIIO(IOR_param_t * test, MPI_Comm testComm, char *testFileName)
{
@ -481,4 +461,4 @@ IOR_GetFileSize_MPIIO(IOR_param_t * test, MPI_Comm testComm, char *testFileName)
return (aggFileSizeFromStat);
} /* IOR_GetFileSize_MPIIO() */
}

View File

@ -18,11 +18,9 @@
#define NUM_DIMS 3 /* number of dimensions to data set */
/******************************************************************************/
/*
* NCMPI_CHECK will display a custom error message and then exit the program
*/
#define NCMPI_CHECK(NCMPI_RETURN, MSG) do { \
char resultString[1024]; \
\
@ -38,7 +36,7 @@
/**************************** P R O T O T Y P E S *****************************/
int GetFileMode(IOR_param_t *);
static int GetFileMode(IOR_param_t *);
void SetHints(MPI_Info *, char *);
void ShowHints(MPI_Info *);
@ -66,16 +64,18 @@ ior_aiori_t ncmpi_aiori = {
IOR_GetFileSize_NCMPI
};
extern int errno, /* error number */
numTasksWorld, rank, rankOffset, verbose; /* verbose output */
extern int errno; /* error number */
extern int numTasksWorld;
extern int rank;
extern int rankOffset;
extern int verbose;
extern MPI_Comm testComm;
/***************************** F U N C T I O N S ******************************/
/******************************************************************************/
/*
* Create and open a file through the NCMPI interface.
*/
void *IOR_Create_NCMPI(char *testFileName, IOR_param_t * param)
{
int *fd;
@ -116,13 +116,11 @@ void *IOR_Create_NCMPI(char *testFileName, IOR_param_t * param)
*/
return (fd);
} /* IOR_Create_NCMPI() */
}
/******************************************************************************/
/*
* Open a file through the NCMPI interface.
*/
void *IOR_Open_NCMPI(char *testFileName, IOR_param_t * param)
{
int *fd;
@ -163,13 +161,11 @@ void *IOR_Open_NCMPI(char *testFileName, IOR_param_t * param)
*/
return (fd);
} /* IOR_Open_NCMPI() */
}
/******************************************************************************/
/*
* Write or read access to file using the NCMPI interface.
*/
IOR_offset_t
IOR_Xfer_NCMPI(int access,
void *fd,
@ -307,23 +303,19 @@ IOR_Xfer_NCMPI(int access,
}
return (length);
} /* IOR_Xfer_NCMPI() */
}
/******************************************************************************/
/*
* Perform fsync().
*/
void IOR_Fsync_NCMPI(void *fd, IOR_param_t * param)
{
;
} /* IOR_Fsync_NCMPI() */
}
/******************************************************************************/
/*
* Close a file through the NCMPI interface.
*/
void IOR_Close_NCMPI(void *fd, IOR_param_t * param)
{
if (param->collective == FALSE) {
@ -332,37 +324,29 @@ void IOR_Close_NCMPI(void *fd, IOR_param_t * param)
}
NCMPI_CHECK(ncmpi_close(*(int *)fd), "cannot close file");
free(fd);
} /* IOR_Close_NCMPI() */
}
/******************************************************************************/
/*
* Delete a file through the NCMPI interface.
*/
void IOR_Delete_NCMPI(char *testFileName, IOR_param_t * param)
{
if (unlink(testFileName) != 0)
WARN("unlink() failed");
} /* IOR_Delete_NCMPI() */
}
/******************************************************************************/
/*
* Determine api version.
*/
void IOR_SetVersion_NCMPI(IOR_param_t * test)
{
sprintf(test->apiVersion, "%s (%s)", test->api, ncmpi_inq_libvers());
} /* IOR_SetVersion_NCMPI() */
}
/************************ L O C A L F U N C T I O N S ***********************/
/******************************************************************************/
/*
* Return the correct file mode for NCMPI.
*/
int GetFileMode(IOR_param_t * param)
static int GetFileMode(IOR_param_t * param)
{
int fd_mode = 0;
@ -397,15 +381,13 @@ int GetFileMode(IOR_param_t * param)
fd_mode |= NC_64BIT_OFFSET;
return (fd_mode);
} /* GetFileMode() */
}
/******************************************************************************/
/*
* Use MPIIO call to get file size.
*/
IOR_offset_t
IOR_GetFileSize_NCMPI(IOR_param_t * test, MPI_Comm testComm, char *testFileName)
{
return (IOR_GetFileSize_MPIIO(test, testComm, testFileName));
} /* IOR_GetFileSize_NCMPI() */
}

View File

@ -87,11 +87,9 @@ void set_o_direct_flag(int *fd)
*fd |= O_DIRECT;
}
/******************************************************************************/
/*
* Creat and open a file through the POSIX interface.
*/
void *IOR_Create_POSIX(char *testFileName, IOR_param_t * param)
{
int fd_oflag = O_BINARY;
@ -165,13 +163,11 @@ void *IOR_Create_POSIX(char *testFileName, IOR_param_t * param)
#endif /* HAVE_LUSTRE_LUSTRE_USER_H */
return ((void *)fd);
} /* IOR_Create_POSIX() */
}
/******************************************************************************/
/*
* Open a file through the POSIX interface.
*/
void *IOR_Open_POSIX(char *testFileName, IOR_param_t * param)
{
int fd_oflag = O_BINARY;
@ -202,13 +198,11 @@ void *IOR_Open_POSIX(char *testFileName, IOR_param_t * param)
#endif /* HAVE_LUSTRE_LUSTRE_USER_H */
return ((void *)fd);
} /* IOR_Open_POSIX() */
}
/******************************************************************************/
/*
* Write or read access to file using the POSIX interface.
*/
IOR_offset_t
IOR_Xfer_POSIX(int access,
void *file,
@ -273,36 +267,30 @@ IOR_Xfer_POSIX(int access,
xferRetries++;
}
return (length);
} /* IOR_Xfer_POSIX() */
}
/******************************************************************************/
/*
* Perform fsync().
*/
void IOR_Fsync_POSIX(void *fd, IOR_param_t * param)
{
if (fsync(*(int *)fd) != 0)
WARN("fsync() failed");
} /* IOR_Fsync_POSIX() */
}
/******************************************************************************/
/*
* Close a file through the POSIX interface.
*/
void IOR_Close_POSIX(void *fd, IOR_param_t * param)
{
if (close(*(int *)fd) != 0)
ERR("close() failed");
free(fd);
} /* IOR_Close_POSIX() */
}
/******************************************************************************/
/*
* Delete a file through the POSIX interface.
*/
void IOR_Delete_POSIX(char *testFileName, IOR_param_t * param)
{
char errmsg[256];
@ -310,23 +298,19 @@ void IOR_Delete_POSIX(char *testFileName, IOR_param_t * param)
rank, testFileName);
if (unlink(testFileName) != 0)
WARN(errmsg);
} /* IOR_Delete_POSIX() */
}
/******************************************************************************/
/*
* Determine api version.
*/
void IOR_SetVersion_POSIX(IOR_param_t * test)
{
strcpy(test->apiVersion, test->api);
} /* IOR_SetVersion_POSIX() */
/******************************************************************************/
/*
* Use POSIX stat() to return aggregate file size.
*/
IOR_offset_t
IOR_GetFileSize_POSIX(IOR_param_t * test, MPI_Comm testComm, char *testFileName)
{
@ -360,4 +344,4 @@ IOR_GetFileSize_POSIX(IOR_param_t * test, MPI_Comm testComm, char *testFileName)
}
return (aggFileSizeFromStat);
} /* IOR_GetFileSize_POSIX() */
}

189
src/ior.c
View File

@ -133,8 +133,7 @@ int main(int argc, char **argv)
MPI_CHECK(MPI_Finalize(), "cannot finalize MPI");
return (totalErrorCount);
} /* main() */
}
/***************************** F U N C T I O N S ******************************/
@ -167,12 +166,10 @@ void init_IOR_Param_t(IOR_param_t * p)
p->lustre_start_ost = -1;
}
/******************************************************************************/
/*
* Bind the global "backend" pointer to the requested backend AIORI's
* function table.
*/
void AioriBind(char *api)
{
ior_aiori_t **tmp;
@ -191,11 +188,6 @@ void AioriBind(char *api)
} /* AioriBind() */
/******************************************************************************/
/*
* Display outliers found.
*/
void
DisplayOutliers(int numTasks,
double timerVal,
@ -231,11 +223,9 @@ DisplayOutliers(int numTasks,
}
} /* DisplayOutliers() */
/******************************************************************************/
/*
* Check for outliers in start/end times and elapsed create/xfer/close times.
*/
void CheckForOutliers(IOR_param_t * test, double **timer, int rep, int access)
{
int shift;
@ -263,12 +253,10 @@ void CheckForOutliers(IOR_param_t * test, double **timer, int rep, int access)
} /* CheckForOutliers() */
/******************************************************************************/
/*
* Check if actual file size equals expected size; if not use actual for
* calculating performance rate.
*/
void CheckFileSize(IOR_param_t * test, IOR_offset_t dataMoved, int rep)
{
MPI_CHECK(MPI_Allreduce(&dataMoved, &test->aggFileSizeFromXfer[rep],
@ -300,11 +288,9 @@ void CheckFileSize(IOR_param_t * test, IOR_offset_t dataMoved, int rep)
} /* CheckFileSize() */
/******************************************************************************/
/*
* Check if string is true or false.
*/
char *CheckTorF(char *string)
{
string = LowerCase(string);
@ -316,20 +302,19 @@ char *CheckTorF(char *string)
return (string);
} /* CheckTorF() */
/******************************************************************************/
/*
* Compare buffers after reading/writing each transfer. Displays only first
* difference in buffers and returns total errors counted.
*/
size_t
CompareBuffers(void *expectedBuffer,
void *unknownBuffer,
size_t size,
IOR_offset_t transferCount, IOR_param_t * test, int access)
{
char testFileName[MAXPATHLEN],
bufferLabel1[MAX_STR], bufferLabel2[MAX_STR];
char testFileName[MAXPATHLEN];
char bufferLabel1[MAX_STR];
char bufferLabel2[MAX_STR];
size_t i, j, length, first, last;
size_t errorCount = 0;
int inError = 0;
@ -422,12 +407,11 @@ CompareBuffers(void *expectedBuffer,
ERR("data check error, aborting execution");
}
return (errorCount);
} /* CompareBuffers() */
/******************************************************************************//*
* Count all errors across all tasks; report errors found.
*/
}
/*
* Count all errors across all tasks; report errors found.
*/
int CountErrors(IOR_param_t * test, int access, int errors)
{
int allErrors = 0;
@ -466,13 +450,11 @@ int CountErrors(IOR_param_t * test, int access, int errors)
}
}
return (allErrors);
} /* CountErrors() */
}
/******************************************************************************/
/*
* Compares hostnames to determine the number of tasks per node
*/
int CountTasksPerNode(int numTasks, MPI_Comm comm)
{
char localhost[MAX_STR], hostname[MAX_STR], taskOnNode[MAX_STR];
@ -513,11 +495,9 @@ int CountTasksPerNode(int numTasks, MPI_Comm comm)
return (count);
} /* CountTasksPerNode() */
/******************************************************************************/
/*
* Allocate a page-aligned (required by O_DIRECT) buffer.
*/
void *CreateBuffer(size_t size)
{
size_t pageSize;
@ -539,13 +519,11 @@ void *CreateBuffer(size_t size)
*(void **)tmp = buf;
return ((void *)aligned);
} /* CreateBuffer() */
}
/******************************************************************************/
/*
* Create new test for list of tests.
*/
IOR_queue_t *CreateNewTest(int test_num)
{
IOR_queue_t *newTest = NULL;
@ -561,13 +539,11 @@ IOR_queue_t *CreateNewTest(int test_num)
newTest->testParameters.id = test_num;
newTest->nextTest = NULL;
return (newTest);
} /* CreateNewTest() */
}
/******************************************************************************/
/*
* Sleep for 'delay' seconds.
*/
void DelaySecs(int delay)
{
if (rank == 0 && delay > 0) {
@ -577,7 +553,6 @@ void DelaySecs(int delay)
}
} /* DelaySecs() */
/******************************************************************************/
/*
* Display freespace (df).
*/
@ -615,11 +590,9 @@ void DisplayFreespace(IOR_param_t * test)
return;
} /* DisplayFreespace() */
/******************************************************************************/
/*
* Display usage of script file.
*/
void DisplayUsage(char **argv)
{
char *opts[] = {
@ -685,13 +658,11 @@ void DisplayUsage(char **argv)
fprintf(stdout, "%s\n", opts[i]);
return;
} /* DisplayUsage() */
}
/******************************************************************************/
/*
* Distribute IOR_HINTs to all tasks' environments.
*/
void DistributeHints(void)
{
char hint[MAX_HINTS][MAX_STR], fullHint[MAX_STR], hintVariable[MAX_STR];
@ -728,9 +699,8 @@ void DistributeHints(void)
WARN("cannot set environment variable");
}
}
} /* DistributeHints() */
}
/******************************************************************************/
/*
* Fill buffer, which is transfer size bytes long, with known 8-byte long long
* int values. In even-numbered 8-byte long long ints, store MPI task in high
@ -738,7 +708,6 @@ void DistributeHints(void)
* ints, store transfer offset. If storeFileOffset option is used, the file
* (not transfer) offset is stored instead.
*/
void
FillBuffer(void *buffer,
IOR_param_t * test, unsigned long long offset, int fillrank)
@ -758,12 +727,11 @@ FillBuffer(void *buffer,
buf[i] = offset + (i * sizeof(unsigned long long));
}
}
} /* FillBuffer() */
/******************************************************************************//*
* Free transfer buffers.
*/
}
/*
* Free transfer buffers.
*/
void
FreeBuffers(int access,
void *checkBuffer,
@ -781,13 +749,11 @@ FreeBuffers(int access,
/* nothing special needed to free() this unaligned buffer */
free(offsetArray);
return;
} /* FreeBuffers() */
}
/******************************************************************************/
/*
* Return string describing machine name and type.
*/
void GetPlatformName(char *platformName)
{
char nodeName[MAX_STR], *p, *start, sysName[MAX_STR];
@ -823,14 +789,12 @@ void GetPlatformName(char *platformName)
}
sprintf(platformName, "%s(%s)", nodeName, sysName);
} /* GetPlatformName() */
}
/******************************************************************************/
/*
* Return test file name to access.
* for single shared file, fileNames[0] is returned in testFileName
*/
void GetTestFileName(char *testFileName, IOR_param_t * test)
{
char **fileNames,
@ -881,14 +845,12 @@ void GetTestFileName(char *testFileName, IOR_param_t * test)
sprintf(tmpString, ".%d", test->repCounter);
strcat(testFileName, tmpString);
}
} /* GetTestFileName() */
}
/******************************************************************************/
/*
* Get time stamp. Use MPI_Timer() unless _NO_MPI_TIMER is defined,
* in which case use gettimeofday().
*/
double GetTimeStamp(void)
{
double timeVal;
@ -908,13 +870,11 @@ double GetTimeStamp(void)
timeVal -= wall_clock_delta;
return (timeVal);
} /* GetTimeStamp() */
}
/******************************************************************************/
/*
* Convert IOR_offset_t value to human readable string.
*/
char *HumanReadable(IOR_offset_t value, int base)
{
char *valueStr;
@ -957,13 +917,11 @@ char *HumanReadable(IOR_offset_t value, int base)
sprintf(valueStr, "-");
}
return valueStr;
} /* HumanReadable() */
}
/******************************************************************************/
/*
* Change string to lower case.
*/
char *LowerCase(char *string)
{
char *nextChar = string;
@ -973,13 +931,11 @@ char *LowerCase(char *string)
nextChar++;
}
return (string);
} /* LowerCase() */
}
/******************************************************************************/
/*
* Parse file name.
*/
char **ParseFileName(char *name, int *count)
{
char **fileNames, *tmp, *token;
@ -1014,15 +970,13 @@ char **ParseFileName(char *name, int *count)
i++;
}
return (fileNames);
} /* ParseFileName() */
}
/******************************************************************************/
/*
* Pretty Print a Double. The First parameter is a flag determining if left
* justification should be used. The third parameter a null-terminated string
* that should be appended to the number field.
*/
void PPDouble(int leftjustify, double number, char *append)
{
if (number < 0) {
@ -1044,15 +998,12 @@ void PPDouble(int leftjustify, double number, char *append)
fprintf(stdout, "%10.0f%s", number, append);
}
}
} /* PPDouble() */
}
/******************************************************************************/
/*
* From absolute directory, insert rank as subdirectory. Allows each task
* to write to its own directory. E.g., /dir/file => /dir/<rank>/file.
*
*/
char *PrependDir(IOR_param_t * test, char *rootDir)
{
char *dir;
@ -1107,12 +1058,11 @@ char *PrependDir(IOR_param_t * test, char *rootDir)
strcat(dir, p);
return dir;
} /* PrependDir() */
/******************************************************************************//*
* Read and then reread buffer to confirm data read twice matches.
*/
}
/*
* Read and then reread buffer to confirm data read twice matches.
*/
void
ReadCheck(void *fd,
void *buffer,
@ -1289,13 +1239,11 @@ void ReduceIterResults(IOR_param_t * test, double **timer, int rep, int access)
fflush(stdout);
}
firstIteration = FALSE; /* set to TRUE to repeat this header */
} /* ReduceIterResults() */
}
/******************************************************************************/
/*
* Check for file(s), then remove all files if file-per-proc, else single file.
*/
void RemoveFile(char *testFileName, int filePerProc, IOR_param_t * test)
{
int tmpRankOffset;
@ -1318,13 +1266,11 @@ void RemoveFile(char *testFileName, int filePerProc, IOR_param_t * test)
backend->delete(testFileName, test);
}
}
} /* RemoveFile() */
}
/******************************************************************************/
/*
* Setup tests by parsing commandline and creating test script.
*/
IOR_queue_t *SetupTests(int argc, char **argv)
{
IOR_queue_t *tests, *testsHead;
@ -1353,12 +1299,11 @@ IOR_queue_t *SetupTests(int argc, char **argv)
SeedRandGen(MPI_COMM_WORLD);
return (testsHead);
} /* SetupTests() */
/******************************************************************************//*
* Setup transfer buffers, creating and filling as needed.
*/
}
/*
* Setup transfer buffers, creating and filling as needed.
*/
void
SetupXferBuffers(void **buffer,
void **checkBuffer,
@ -1376,13 +1321,11 @@ SetupXferBuffers(void **buffer,
}
}
return;
} /* SetupXferBuffers() */
}
/******************************************************************************/
/*
* Print header information for test output.
*/
void ShowInfo(int argc, char **argv, IOR_param_t * test)
{
int i;
@ -1444,13 +1387,11 @@ void ShowInfo(int argc, char **argv, IOR_param_t * test)
fprintf(stdout, "ENDING ENVIRON LOOP\n");
}
fflush(stdout);
} /* ShowInfo() */
}
/******************************************************************************/
/*
* Show simple test output with max results for iterations.
*/
void ShowSetup(IOR_param_t * test)
{
IOR_offset_t aggFileSizeForBW;
@ -1534,13 +1475,11 @@ void ShowSetup(IOR_param_t * test)
fprintf(stdout, "\n");
/*fprintf(stdout, "\n ================================\n\n"); */
fflush(stdout);
} /* ShowSetup() */
}
/******************************************************************************/
/*
* Show test description.
*/
void ShowTest(IOR_param_t * test)
{
fprintf(stdout, "\n\n ================================\n\n");
@ -1607,21 +1546,19 @@ void ShowTest(IOR_param_t * test)
fprintf(stdout, "\n");
fprintf(stdout, "\t%s=%lld\n", "transferSize", test->transferSize);
fprintf(stdout, "\t%s=%lld\n", "blockSize", test->blockSize);
} /* ShowTest() */
}
/******************************************************************************/
/*
* Summarize results, showing max rates (and min, mean, stddev if verbose)
*/
void SummarizeResults(IOR_param_t * test)
{
int rep, ival;
double maxWrite[2], minWrite[2], maxRead[2], minRead[2],
meanWrite[2], meanRead[2],
varWrite[2], varRead[2],
sdWrite[2], sdRead[2],
sumWrite[2], sumRead[2], writeTimeSum, readTimeSum;
double maxWrite[2], minWrite[2], maxRead[2], minRead[2];
double meanWrite[2], meanRead[2];
double varWrite[2], varRead[2];
double sdWrite[2], sdRead[2];
double sumWrite[2], sumRead[2], writeTimeSum, readTimeSum;
for (ival = 0; ival < 2; ival++) {
varWrite[ival] = 0;
@ -1778,13 +1715,11 @@ void SummarizeResults(IOR_param_t * test)
}
fprintf(stdout, "\n");
}
} /* SummarizeResults() */
}
/******************************************************************************/
/*
* Using the test parameters, run iteration(s) of single test.
*/
void TestIoSys(IOR_param_t * test)
{
char testFileName[MAX_STR];
@ -2312,17 +2247,17 @@ void TestIoSys(IOR_param_t * test)
}
/* Sync with the tasks that did not participate in this test */
MPI_CHECK(MPI_Barrier(MPI_COMM_WORLD), "barrier error");
}
} /* TestIoSys() */
/******************************************************************************/
/*
* Determine any spread (range) between node times.
*/
double TimeDeviation(void)
{
double timestamp, min = 0, max = 0, roottimestamp;
double timestamp;
double min = 0;
double max = 0;
double roottimestamp;
MPI_CHECK(MPI_Barrier(MPI_COMM_WORLD), "barrier error");
timestamp = GetTimeStamp();
@ -2340,13 +2275,11 @@ double TimeDeviation(void)
wall_clock_delta = timestamp - roottimestamp;
return max - min;
} /* TimeDeviation() */
}
/******************************************************************************/
/*
* Determine if valid tests from parameters.
*/
void ValidTests(IOR_param_t * test)
{
IOR_param_t defaults;
@ -2499,7 +2432,7 @@ void ValidTests(IOR_param_t * test)
}
if (test->useExistingTestFile && test->lustre_set_striping)
ERR("Lustre stripe options are incompatible with useExistingTestFile");
} /* ValidTests() */
}
IOR_offset_t *GetOffsetArraySequential(IOR_param_t * test, int pretendRank)
{
@ -2533,14 +2466,15 @@ IOR_offset_t *GetOffsetArraySequential(IOR_param_t * test, int pretendRank)
}
return (offsetArray);
} /* GetOffsetArraySequential() */
}
IOR_offset_t *GetOffsetArrayRandom(IOR_param_t * test, int pretendRank,
int access)
{
int seed;
IOR_offset_t i, value, tmp;
IOR_offset_t offsets = 0, offsetCnt = 0;
IOR_offset_t offsets = 0;
IOR_offset_t offsetCnt = 0;
IOR_offset_t fileSize;
IOR_offset_t *offsetArray;
@ -2600,14 +2534,12 @@ IOR_offset_t *GetOffsetArrayRandom(IOR_param_t * test, int pretendRank,
SeedRandGen(test->testComm); /* synchronize seeds across tasks */
return (offsetArray);
} /* GetOffsetArrayRandom() */
}
/******************************************************************************/
/*
* Write or Read data to file(s). This loops through the strides, writing
* out the data to each block in transfer sizes, until the remainder left is 0.
*/
IOR_offset_t WriteOrRead(IOR_param_t * test, void *fd, int access)
{
int errors = 0;
@ -2692,17 +2624,16 @@ IOR_offset_t WriteOrRead(IOR_param_t * test, void *fd, int access)
backend->fsync(fd, test); /*fsync after all accesses */
}
return (dataMoved);
} /* WriteOrRead() */
}
/******************************************************************************/
/*
* Write times taken during each iteration of the test.
*/
void
WriteTimes(IOR_param_t * test, double **timer, int iteration, int writeOrRead)
{
char accessType[MAX_STR], timerName[MAX_STR];
char accessType[MAX_STR];
char timerName[MAX_STR];
int i, start, stop;
if (writeOrRead == WRITE) {
@ -2763,4 +2694,4 @@ WriteTimes(IOR_param_t * test, double **timer, int iteration, int writeOrRead)
test->id, iteration, (int)rank, timer[i][iteration],
timerName);
}
} /* WriteTimes() */
}

View File

@ -52,11 +52,10 @@
/************************** D E C L A R A T I O N S ***************************/
extern int numTasks, /* MPI variables */
rank,
rankOffset,
verbose; /* verbose output */
extern int numTasks; /* MPI variables */
extern int rank;
extern int rankOffset;
extern int verbose; /* verbose output */
/*************************** D E F I N I T I O N S ****************************/

View File

@ -18,11 +18,9 @@
IOR_param_t initialTestParams;
/******************************************************************************/
/*
* Check and correct all settings of each test in queue for correctness.
*/
void CheckRunSettings(IOR_queue_t * tests)
{
while (tests != NULL) {
@ -43,13 +41,11 @@ void CheckRunSettings(IOR_queue_t * tests)
}
tests = tests->nextTest;
}
} /* CheckRunSettings() */
}
/******************************************************************************/
/*
* Set flags from commandline string/value pairs.
*/
void DecodeDirective(char *line, IOR_param_t * test)
{
char option[MAX_STR];
@ -207,13 +203,11 @@ void DecodeDirective(char *line, IOR_param_t * test)
option);
MPI_CHECK(MPI_Abort(MPI_COMM_WORLD, -1), "MPI_Abort() error");
}
} /* DecodeDirective() */
}
/******************************************************************************/
/*
* Parse a single line, which may contain multiple comma-seperated directives
*/
void ParseLine(char *line, IOR_param_t * test)
{
char *start, *end;
@ -227,14 +221,12 @@ void ParseLine(char *line, IOR_param_t * test)
start = end + 1;
} while (end != NULL);
} /* ParseLine() */
}
/******************************************************************************/
/*
* Determines if the string "haystack" contains only the string "needle", and
* possibly whitespace before and after needle. Function is case insensitive.
*/
int contains_only(char *haystack, char *needle)
{
char *ptr, *end;
@ -255,14 +247,12 @@ int contains_only(char *haystack, char *needle)
}
return 1;
} /* contains_only() */
}
/******************************************************************************/
/*
* Read the configuration script, allocating and filling in the structure of
* global parameters.
*/
IOR_queue_t *ReadConfigScript(char *scriptName)
{
int test_num = 0;
@ -326,18 +316,15 @@ IOR_queue_t *ReadConfigScript(char *scriptName)
ERR("fclose() of script file failed");
return (head);
} /* ReadConfigScript() */
}
/******************************************************************************/
/*
* Parse Commandline.
*/
IOR_queue_t *ParseCommandLine(int argc, char **argv)
{
static const char *opts
=
"A:a:b:BcCQ:ZX:d:D:YeEf:FgG:hHi:j:J:IkKlmnN:o:O:pPqrRs:St:T:uU:vVwWxz";
static const char *opts =
"A:a:b:BcCQ:ZX:d:D:YeEf:FgG:hHi:j:J:IkKlmnN:o:O:pPqrRs:St:T:uU:vVwWxz";
int c, i;
static IOR_queue_t *tests = NULL;
@ -521,4 +508,4 @@ IOR_queue_t *ParseCommandLine(int argc, char **argv)
CheckRunSettings(tests);
return (tests);
} /* ParseCommandLine() */
}

View File

@ -32,17 +32,17 @@
/************************** D E C L A R A T I O N S ***************************/
extern int errno, /* error number */
numTasks, /* MPI variables */
rank, rankOffset, verbose; /* verbose output */
extern int errno;
extern int numTasks;
extern int rank;
extern int rankOffset;
extern int verbose;
/***************************** F U N C T I O N S ******************************/
/******************************************************************************/
/*
* Returns string containing the current time.
*/
char *CurrentTimeString(void)
{
static time_t currentTime;
@ -55,13 +55,11 @@ char *CurrentTimeString(void)
}
/* ctime string ends in \n */
return (currentTimePtr);
} /* CurrentTimeString() */
}
/******************************************************************************/
/*
* Dump transfer buffer.
*/
void DumpBuffer(void *buffer, size_t size)
{
size_t i, j;
@ -76,11 +74,9 @@ void DumpBuffer(void *buffer, size_t size)
return;
} /* DumpBuffer() */
/******************************************************************************/
/*
* Sends all strings to root nodes and displays.
*/
void OutputToRoot(int numTasks, MPI_Comm comm, char *stringToDisplay)
{
int i;
@ -148,16 +144,16 @@ void OutputToRoot(int numTasks, MPI_Comm comm, char *stringToDisplay)
free(stringArray[i]);
}
free(stringArray);
} /* OutputToRoot() */
}
/******************************************************************************/
/*
* Set hints for MPIIO, HDF5, or NCMPI.
*/
void SetHints(MPI_Info * mpiHints, char *hintsFileName)
{
char hintString[MAX_STR], settingVal[MAX_STR], valueVal[MAX_STR];
char hintString[MAX_STR];
char settingVal[MAX_STR];
char valueVal[MAX_STR];
extern char **environ;
int i;
FILE *fd;
@ -209,13 +205,11 @@ void SetHints(MPI_Info * mpiHints, char *hintsFileName)
ERR("cannot close hints file");
}
}
} /* SetHints() */
}
/******************************************************************************/
/*
* Extract key/value pair from hint string.
*/
void ExtractHint(char *settingVal, char *valueVal, char *hintString)
{
char *settingPtr, *valuePtr, *tmpPtr1, *tmpPtr2;
@ -237,16 +231,15 @@ void ExtractHint(char *settingVal, char *valueVal, char *hintString)
}
strcpy(settingVal, settingPtr);
strcpy(valueVal, valuePtr);
} /* ExtractHint() */
}
/******************************************************************************/
/*
* Show all hints (key/value pairs) in an MPI_Info object.
*/
void ShowHints(MPI_Info * mpiHints)
{
char key[MPI_MAX_INFO_VAL], value[MPI_MAX_INFO_VAL];
char key[MPI_MAX_INFO_VAL];
char value[MPI_MAX_INFO_VAL];
int flag, i, nkeys;
MPI_CHECK(MPI_Info_get_nkeys(*mpiHints, &nkeys),
@ -260,13 +253,11 @@ void ShowHints(MPI_Info * mpiHints)
"cannot get info object value");
fprintf(stdout, "\t%s = %s\n", key, value);
}
} /* ShowHints() */
}
/******************************************************************************/
/*
* Takes a string of the form 64, 8m, 128k, 4g, etc. and converts to bytes.
*/
IOR_offset_t StringToBytes(char *size_str)
{
IOR_offset_t size = 0;
@ -293,25 +284,24 @@ IOR_offset_t StringToBytes(char *size_str)
size = -1;
}
return (size);
} /* StringToBytes() */
}
/******************************************************************************/
/*
* Displays size of file system and percent of data blocks and inodes used.
*/
void ShowFileSystemSize(char *fileSystem)
{
#ifndef _WIN32 /* FIXME */
int error;
char realPath[PATH_MAX];
char *fileSystemUnitStr = "GiB";
long long int fileSystemUnitVal = 1024 * 1024 * 1024;
long long int inodeUnitVal = 1024 * 1024;
long long int totalFileSystemSize,
freeFileSystemSize, totalInodes, freeInodes;
double totalFileSystemSizeHR,
usedFileSystemPercentage, usedInodePercentage;
char *fileSystemUnitStr;
long long int totalFileSystemSize;
long long int freeFileSystemSize;
long long int totalInodes;
long long int freeInodes;
double totalFileSystemSizeHR;
double usedFileSystemPercentage;
double usedInodePercentage;
#ifdef __sun /* SunOS does not support statfs(), instead uses statvfs() */
struct statvfs statusBuffer;
#else /* !__sun */
@ -340,9 +330,10 @@ void ShowFileSystemSize(char *fileSystem)
usedFileSystemPercentage = (1 - ((double)freeFileSystemSize
/ (double)totalFileSystemSize)) * 100;
totalFileSystemSizeHR =
(double)totalFileSystemSize / (double)fileSystemUnitVal;
(double)totalFileSystemSize / (double)(1<<30);
fileSystemUnitStr = "GiB";
if (totalFileSystemSizeHR > 1024) {
totalFileSystemSizeHR = totalFileSystemSizeHR / 1024;
totalFileSystemSizeHR = (double)totalFileSystemSize / (double)(1<<40);
fileSystemUnitStr = "TiB";
}
@ -361,19 +352,17 @@ void ShowFileSystemSize(char *fileSystem)
totalFileSystemSizeHR, fileSystemUnitStr,
usedFileSystemPercentage);
fprintf(stdout, "Inodes: %.1f Mi Used Inodes: %2.1f%%\n",
(double)totalInodes / (double)inodeUnitVal,
(double)totalInodes / (double)(1<<20),
usedInodePercentage);
fflush(stdout);
#endif /* _WIN32 */
#endif /* !_WIN32 */
return;
} /* ShowFileSystemSize() */
}
/******************************************************************************/
/*
* Return match of regular expression -- 0 is failure, 1 is success.
*/
int Regex(char *string, char *pattern)
{
int retValue = 0;
@ -389,14 +378,12 @@ int Regex(char *string, char *pattern)
#endif
return (retValue);
} /* Regex() */
}
#if USE_UNDOC_OPT /* corruptFile */
/******************************************************************************/
/*
* Corrupt file to testing data checking options.
*/
void CorruptFile(char *testFileName, IOR_param_t * test, int rep, int access)
{
IOR_offset_t tmpOff, range, eof;
@ -429,13 +416,11 @@ void CorruptFile(char *testFileName, IOR_param_t * test, int rep, int access)
}
return;
} /* CorruptFile() */
}
/******************************************************************************/
/*
* Modify byte in file - used to testing write/read data checking.
*/
void ModifyByteInFile(char *fileName, IOR_offset_t offset, int byteValue)
{
int fd;
@ -466,14 +451,12 @@ void ModifyByteInFile(char *fileName, IOR_offset_t offset, int byteValue)
out:
close(fd);
return;
} /* ModifyByteInFile() */
}
#endif /* USE_UNDOC_OPT - corruptFile */
/******************************************************************************/
/*
* Seed random generator.
*/
void SeedRandGen(MPI_Comm testComm)
{
unsigned int randomSeed;
@ -490,15 +473,12 @@ void SeedRandGen(MPI_Comm testComm)
MPI_CHECK(MPI_Bcast(&randomSeed, 1, MPI_INT, 0,
testComm), "cannot broadcast random seed value");
srandom(randomSeed);
}
} /* SeedRandGen() */
/******************************************************************************/
/*
* System info for Windows.
*/
#ifdef _WIN32
int uname(struct utsname *name)
{
DWORD nodeNameSize = sizeof(name->nodename) - 1;
@ -515,5 +495,4 @@ int uname(struct utsname *name)
strncpy(name->machine, "-", sizeof(name->machine) - 1);
return 0;
}
#endif /* _WIN32 */
#endif /* _WIN32 */