Change the the One True Formatting (Linux style)

Ran the main ior code through "indent -linux --no-tabs".
master
Christopher J. Morrone 2011-11-11 14:22:17 -08:00
parent 3ff7a4a4ae
commit 240e5ce93f
7 changed files with 4276 additions and 4149 deletions

View File

@ -99,9 +99,7 @@ ior_aiori_t hdf5_aiori = {
};
extern int errno, /* error number */
rank,
rankOffset,
verbose; /* verbose output */
rank, rankOffset, verbose; /* verbose output */
extern MPI_Comm testComm;
static hid_t xferPropList; /* xfer property list */
@ -113,37 +111,28 @@ 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)
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)
void *IOR_Open_HDF5(char *testFileName, IOR_param_t * param)
{
hid_t accessPropList,
createPropList;
hid_t accessPropList, createPropList;
hsize_t memStart[NUM_DIMS],
dataSetDims[NUM_DIMS],
memStride[NUM_DIMS],
memCount[NUM_DIMS],
memBlock[NUM_DIMS],
memDataSpaceDims[NUM_DIMS];
memCount[NUM_DIMS], memBlock[NUM_DIMS], memDataSpaceDims[NUM_DIMS];
int tasksPerDataSet;
unsigned fd_mode = (unsigned)0;
hid_t *fd;
@ -164,17 +153,27 @@ IOR_Open_HDF5(char * testFileName,
/* set IOR file flags to HDF5 flags */
/* -- file open flags -- */
if (param->openFlags & IOR_RDONLY) {fd_mode |= H5F_ACC_RDONLY;}
if (param->openFlags & IOR_RDONLY) {
fd_mode |= H5F_ACC_RDONLY;
}
if (param->openFlags & IOR_WRONLY) {
fprintf(stdout, "File write only not implemented in HDF5\n");
}
if (param->openFlags & IOR_RDWR) {fd_mode |= H5F_ACC_RDWR;}
if (param->openFlags & IOR_RDWR) {
fd_mode |= H5F_ACC_RDWR;
}
if (param->openFlags & IOR_APPEND) {
fprintf(stdout, "File append not implemented in HDF5\n");
}
if (param->openFlags & IOR_CREAT) {fd_mode |= H5F_ACC_CREAT;}
if (param->openFlags & IOR_EXCL) {fd_mode |= H5F_ACC_EXCL;}
if (param->openFlags & IOR_TRUNC) {fd_mode |= H5F_ACC_TRUNC;}
if (param->openFlags & IOR_CREAT) {
fd_mode |= H5F_ACC_CREAT;
}
if (param->openFlags & IOR_EXCL) {
fd_mode |= H5F_ACC_EXCL;
}
if (param->openFlags & IOR_TRUNC) {
fd_mode |= H5F_ACC_TRUNC;
}
if (param->openFlags & IOR_DIRECT) {
fprintf(stdout, "O_DIRECT not implemented in HDF5\n");
}
@ -183,7 +182,8 @@ IOR_Open_HDF5(char * testFileName,
createPropList = H5Pcreate(H5P_FILE_CREATE);
HDF5_CHECK(createPropList, "cannot create file creation property list");
/* set size of offset and length used to address HDF5 objects */
HDF5_CHECK(H5Pset_sizes(createPropList, sizeof(hsize_t), sizeof(hsize_t)),
HDF5_CHECK(H5Pset_sizes
(createPropList, sizeof(hsize_t), sizeof(hsize_t)),
"cannot set property list properly");
/* set up file access property list */
@ -218,7 +218,8 @@ IOR_Open_HDF5(char * testFileName,
/* set alignment */
HDF5_CHECK(H5Pset_alignment(accessPropList, param->setAlignment,
param->setAlignment), "cannot set alignment");
param->setAlignment),
"cannot set alignment");
/* open file */
if (param->open == WRITE) { /* WRITE */
@ -232,7 +233,8 @@ IOR_Open_HDF5(char * testFileName,
/* show hints actually attached to file handle */
if (param->showHints || (1) /* WEL - this needs fixing */ ) {
if (rank == 0 && (param->showHints) /* WEL - this needs fixing */) {
if (rank == 0
&& (param->showHints) /* WEL - this needs fixing */ ) {
WARN("showHints not working for HDF5");
}
} else {
@ -248,9 +250,11 @@ IOR_Open_HDF5(char * testFileName,
fprintf(stdout, "}\n");
if (1 == 1) { /* request the MPIIO file handle and its hints */
MPI_File *fd_mpiio;
HDF5_CHECK(H5Fget_vfd_handle(*fd, apl, (void **)&fd_mpiio),
HDF5_CHECK(H5Fget_vfd_handle
(*fd, apl, (void **)&fd_mpiio),
"cannot get MPIIO file handle");
MPI_CHECK(MPI_File_get_info(*fd_mpiio, &mpiHintsCheck),
MPI_CHECK(MPI_File_get_info
(*fd_mpiio, &mpiHintsCheck),
"cannot get info object through MPIIO");
fprintf(stdout,
"\nhints returned from opened file (MPIIO) {\n");
@ -265,8 +269,10 @@ IOR_Open_HDF5(char * testFileName,
needed for reopening and checking the file */
newlyOpenedFile = TRUE;
HDF5_CHECK(H5Pclose(createPropList), "cannot close creation property list");
HDF5_CHECK(H5Pclose(accessPropList), "cannot close access property list");
HDF5_CHECK(H5Pclose(createPropList),
"cannot close creation property list");
HDF5_CHECK(H5Pclose(accessPropList),
"cannot close access property list");
/* create property list for serial/parallel access */
xferPropList = H5Pcreate(H5P_DATASET_XFER);
@ -277,7 +283,8 @@ IOR_Open_HDF5(char * testFileName,
HDF5_CHECK(H5Pset_dxpl_mpio(xferPropList, H5FD_MPIO_COLLECTIVE),
"cannot set collective data transfer mode");
} else {
HDF5_CHECK(H5Pset_dxpl_mpio(xferPropList, H5FD_MPIO_INDEPENDENT),
HDF5_CHECK(H5Pset_dxpl_mpio
(xferPropList, H5FD_MPIO_INDEPENDENT),
"cannot set independent data transfer mode");
}
@ -292,8 +299,8 @@ IOR_Open_HDF5(char * testFileName,
/* define hyperslab for memory data space */
HDF5_CHECK(H5Sselect_hyperslab(memDataSpace, H5S_SELECT_SET,
memStart, memStride, memCount, memBlock),
"cannot create hyperslab");
memStart, memStride, memCount,
memBlock), "cannot create hyperslab");
/* set up parameters for fpp or different dataset count */
if (param->filePerProc) {
@ -318,7 +325,6 @@ IOR_Open_HDF5(char * testFileName,
return (fd);
} /* IOR_Open_HDF5() */
/******************************************************************************/
/*
* Write or read access to file using the HDF5 interface.
@ -327,14 +333,10 @@ IOR_Open_HDF5(char * testFileName,
IOR_offset_t
IOR_Xfer_HDF5(int access,
void *fd,
IOR_size_t * buffer,
IOR_offset_t length,
IOR_param_t * param)
IOR_size_t * buffer, IOR_offset_t length, IOR_param_t * param)
{
static int firstReadCheck = FALSE,
startNewDataSet;
IOR_offset_t segmentPosition,
segmentSize;
static int firstReadCheck = FALSE, startNewDataSet;
IOR_offset_t segmentPosition, segmentSize;
/*
* this toggle is for the read check operation, which passes through
@ -354,11 +356,14 @@ IOR_Xfer_HDF5(int access,
segmentPosition = (IOR_offset_t) 0;
segmentSize = param->blockSize;
} else {
segmentPosition = (IOR_offset_t)((rank + rankOffset) % param->numTasks)
segmentPosition =
(IOR_offset_t) ((rank + rankOffset) % param->numTasks)
* param->blockSize;
segmentSize = (IOR_offset_t)(param->numTasks) * param->blockSize;
segmentSize =
(IOR_offset_t) (param->numTasks) * param->blockSize;
}
if ((IOR_offset_t)((param->offset - segmentPosition) % segmentSize) == 0) {
if ((IOR_offset_t) ((param->offset - segmentPosition) % segmentSize) ==
0) {
/*
* ordinarily start a new data set, unless this is the
* second pass through during a read check
@ -401,33 +406,30 @@ IOR_Xfer_HDF5(int access,
return (length);
} /* IOR_Xfer_HDF5() */
/******************************************************************************/
/*
* Perform fsync().
*/
void
IOR_Fsync_HDF5(void * fd, IOR_param_t * param)
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)
void IOR_Close_HDF5(void *fd, IOR_param_t * param)
{
if (param->fd_fppReadCheck == NULL) {
HDF5_CHECK(H5Dclose(dataSet), "cannot close data set");
HDF5_CHECK(H5Sclose(dataSpace), "cannot close data space");
HDF5_CHECK(H5Sclose(fileDataSpace), "cannot close file data space");
HDF5_CHECK(H5Sclose(memDataSpace), "cannot close memory data space");
HDF5_CHECK(H5Sclose(fileDataSpace),
"cannot close file data space");
HDF5_CHECK(H5Sclose(memDataSpace),
"cannot close memory data space");
HDF5_CHECK(H5Pclose(xferPropList),
" cannot close transfer property list");
}
@ -435,26 +437,23 @@ IOR_Close_HDF5(void * fd,
free(fd);
} /* IOR_Close_HDF5() */
/******************************************************************************/
/*
* Delete a file through the HDF5 interface.
*/
void
IOR_Delete_HDF5(char * testFileName, IOR_param_t * param)
void IOR_Delete_HDF5(char *testFileName, IOR_param_t * param)
{
if (unlink(testFileName) != 0) WARN("cannot delete file");
if (unlink(testFileName) != 0)
WARN("cannot delete file");
} /* IOR_Delete_HDF5() */
/******************************************************************************/
/*
* Determine api version.
*/
void
IOR_SetVersion_HDF5(IOR_param_t *test)
void IOR_SetVersion_HDF5(IOR_param_t * test)
{
unsigned major, minor, release;
if (H5get_libversion(&major, &minor, &release) < 0) {
@ -470,7 +469,6 @@ IOR_SetVersion_HDF5(IOR_param_t *test)
#endif /* not H5_HAVE_PARALLEL */
} /* IOR_SetVersion_HDF5() */
/************************ L O C A L F U N C T I O N S ***********************/
/******************************************************************************/
@ -478,21 +476,17 @@ IOR_SetVersion_HDF5(IOR_param_t *test)
* 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)
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];
hsize_t hsStride[NUM_DIMS], hsCount[NUM_DIMS], hsBlock[NUM_DIMS];
hsize_t hsStart[NUM_DIMS];
if (param->filePerProc == TRUE) {
segmentSize = (IOR_offset_t) param->blockSize;
} else {
segmentSize = (IOR_offset_t)(param->numTasks) * param->blockSize;
segmentSize =
(IOR_offset_t) (param->numTasks) * param->blockSize;
}
/* create a hyperslab representing the file data space */
@ -502,7 +496,8 @@ SeekOffset_HDF5(void *fd,
/ sizeof(IOR_size_t));
} else {
/* start at a unique offset if shared */
hsStart[0] = (hsize_t)((offset % segmentSize) / sizeof(IOR_size_t));
hsStart[0] =
(hsize_t) ((offset % segmentSize) / sizeof(IOR_size_t));
}
hsCount[0] = (hsize_t) 1;
hsStride[0] = (hsize_t) (param->transferSize / sizeof(IOR_size_t));
@ -517,15 +512,12 @@ SeekOffset_HDF5(void *fd,
return (offset);
} /* SeekOffset_HDF5() */
/******************************************************************************/
/*
* Create HDF5 data set.
*/
void
SetupDataSet_HDF5(void * fd,
IOR_param_t * param)
void SetupDataSet_HDF5(void *fd, IOR_param_t * param)
{
char dataSetName[MAX_STR];
hid_t dataSetPropList;
@ -536,7 +528,8 @@ SetupDataSet_HDF5(void * fd,
/* may want to use a chunked dataset (H5S_CHUNKED) someday */
/* need to reset suffix counter if newly-opened file */
if (newlyOpenedFile) dataSetSuffix = 0;
if (newlyOpenedFile)
dataSetSuffix = 0;
/* may want to use individual access to each data set someday */
if (param->individualDataSets) {
@ -545,7 +538,8 @@ SetupDataSet_HDF5(void * fd,
dataSetID = 0;
}
sprintf(dataSetName, "%s-%04d.%04d", "Dataset", dataSetID, dataSetSuffix++);
sprintf(dataSetName, "%s-%04d.%04d", "Dataset", dataSetID,
dataSetSuffix++);
if (param->open == WRITE) { /* WRITE */
/* create data set */
@ -571,7 +565,8 @@ SetupDataSet_HDF5(void * fd,
#else
WARN("unable to determine HDF5 version for 'no fill' usage");
#endif
dataSet = H5Dcreate(*(hid_t *)fd, dataSetName, H5T_NATIVE_LLONG,
dataSet =
H5Dcreate(*(hid_t *) fd, dataSetName, H5T_NATIVE_LLONG,
dataSpace, dataSetPropList);
HDF5_CHECK(dataSet, "cannot create data set");
} else { /* READ or CHECK */
@ -581,16 +576,13 @@ SetupDataSet_HDF5(void * fd,
} /* SetupDataSet_HDF5() */
/******************************************************************************/
/*
* Use MPIIO call to get file size.
*/
IOR_offset_t
IOR_GetFileSize_HDF5(IOR_param_t * test,
MPI_Comm testComm,
char * testFileName)
IOR_GetFileSize_HDF5(IOR_param_t * test, MPI_Comm testComm, char *testFileName)
{
return (IOR_GetFileSize_MPIIO(test, testComm, testFileName));
} /* IOR_GetFileSize_HDF5() */

View File

@ -20,11 +20,9 @@
#define MPIAPI /* defined as __stdcall on Windows */
#endif
/**************************** P R O T O T Y P E S *****************************/
static IOR_offset_t SeekOffset_MPIIO (MPI_File, IOR_offset_t,
IOR_param_t *);
static IOR_offset_t SeekOffset_MPIIO(MPI_File, IOR_offset_t, IOR_param_t *);
void SetHints(MPI_Info *, char *);
void ShowHints(MPI_Info *);
@ -65,32 +63,24 @@ ior_aiori_t mpiio_aiori = {
* Create and open a file through the MPIIO interface.
*/
void *
IOR_Create_MPIIO(char * testFileName,
IOR_param_t * param)
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)
void *IOR_Open_MPIIO(char *testFileName, IOR_param_t * param)
{
int fd_mode = (int)0,
offsetFactor,
tasksPerFile,
transfersPerBlock = param->blockSize
/ param->transferSize;
transfersPerBlock = param->blockSize / param->transferSize;
struct fileTypeStruct {
int globalSizes[2],
localSizes[2],
startIndices[2];
int globalSizes[2], localSizes[2], startIndices[2];
} fileTypeStruct;
MPI_File *fd;
MPI_Comm comm;
@ -104,12 +94,24 @@ IOR_Open_MPIIO(char * testFileName,
/* set IOR file flags to MPIIO flags */
/* -- file open flags -- */
if (param->openFlags & IOR_RDONLY) {fd_mode |= MPI_MODE_RDONLY;}
if (param->openFlags & IOR_WRONLY) {fd_mode |= MPI_MODE_WRONLY;}
if (param->openFlags & IOR_RDWR) {fd_mode |= MPI_MODE_RDWR;}
if (param->openFlags & IOR_APPEND) {fd_mode |= MPI_MODE_APPEND;}
if (param->openFlags & IOR_CREAT) {fd_mode |= MPI_MODE_CREATE;}
if (param->openFlags & IOR_EXCL) {fd_mode |= MPI_MODE_EXCL;}
if (param->openFlags & IOR_RDONLY) {
fd_mode |= MPI_MODE_RDONLY;
}
if (param->openFlags & IOR_WRONLY) {
fd_mode |= MPI_MODE_WRONLY;
}
if (param->openFlags & IOR_RDWR) {
fd_mode |= MPI_MODE_RDWR;
}
if (param->openFlags & IOR_APPEND) {
fd_mode |= MPI_MODE_APPEND;
}
if (param->openFlags & IOR_CREAT) {
fd_mode |= MPI_MODE_CREATE;
}
if (param->openFlags & IOR_EXCL) {
fd_mode |= MPI_MODE_EXCL;
}
if (param->openFlags & IOR_TRUNC) {
fprintf(stdout, "File truncation not implemented in MPIIO\n");
}
@ -158,13 +160,17 @@ IOR_Open_MPIIO(char * testFileName,
/* preallocate space for file */
if (param->preallocate && param->open == WRITE) {
MPI_CHECK(MPI_File_preallocate(*fd,
(MPI_Offset)(param->segmentCount*param->blockSize*param->numTasks)),
(MPI_Offset) (param->segmentCount
*
param->blockSize *
param->numTasks)),
"cannot preallocate file");
}
/* create file view */
if (param->useFileView) {
/* create contiguous transfer datatype */
MPI_CHECK(MPI_Type_contiguous(param->transferSize / sizeof(IOR_size_t),
MPI_CHECK(MPI_Type_contiguous
(param->transferSize / sizeof(IOR_size_t),
MPI_LONG_LONG_INT, &param->transferType),
"cannot create contiguous datatype");
MPI_CHECK(MPI_Type_commit(&param->transferType),
@ -181,29 +187,32 @@ IOR_Open_MPIIO(char * testFileName,
* create file type using subarray
*/
fileTypeStruct.globalSizes[0] = 1;
fileTypeStruct.globalSizes[1] = transfersPerBlock * tasksPerFile;
fileTypeStruct.globalSizes[1] =
transfersPerBlock * tasksPerFile;
fileTypeStruct.localSizes[0] = 1;
fileTypeStruct.localSizes[1] = transfersPerBlock;
fileTypeStruct.startIndices[0] = 0;
fileTypeStruct.startIndices[1] = transfersPerBlock * offsetFactor;
fileTypeStruct.startIndices[1] =
transfersPerBlock * offsetFactor;
MPI_CHECK(MPI_Type_create_subarray(2, fileTypeStruct.globalSizes,
MPI_CHECK(MPI_Type_create_subarray
(2, fileTypeStruct.globalSizes,
fileTypeStruct.localSizes,
fileTypeStruct.startIndices,
MPI_ORDER_C, param->transferType,
&param->fileType),
fileTypeStruct.startIndices, MPI_ORDER_C,
param->transferType, &param->fileType),
"cannot create subarray");
MPI_CHECK(MPI_Type_commit(&param->fileType), "cannot commit datatype");
MPI_CHECK(MPI_Type_commit(&param->fileType),
"cannot commit datatype");
MPI_CHECK(MPI_File_set_view(*fd, (MPI_Offset) 0,
param->transferType, param->fileType,
"native", (MPI_Info)MPI_INFO_NULL),
param->transferType,
param->fileType, "native",
(MPI_Info) MPI_INFO_NULL),
"cannot set file view");
}
return ((void *)fd);
} /* IOR_Open_MPIIO() */
/******************************************************************************/
/*
* Write or read access to file using the MPIIO interface.
@ -212,9 +221,7 @@ IOR_Open_MPIIO(char * testFileName,
IOR_offset_t
IOR_Xfer_MPIIO(int access,
void *fd,
IOR_size_t * buffer,
IOR_offset_t length,
IOR_param_t * param)
IOR_size_t * buffer, IOR_offset_t length, IOR_param_t * param)
{
int (MPIAPI * Access) (MPI_File, void *, int,
MPI_Datatype, MPI_Status *);
@ -260,7 +267,8 @@ IOR_Xfer_MPIIO(int access,
*/
if (param->useFileView) {
/* find offset in file */
if (SeekOffset_MPIIO(*(MPI_File *)fd, param->offset, param) < 0) {
if (SeekOffset_MPIIO(*(MPI_File *) fd, param->offset, param) <
0) {
/* if unsuccessful */
length = -1;
} else {
@ -277,12 +285,14 @@ IOR_Xfer_MPIIO(int access,
}
if (param->collective) {
/* individual, collective call */
MPI_CHECK(Access_all(*(MPI_File *)fd, buffer, length,
MPI_CHECK(Access_all
(*(MPI_File *) fd, buffer, length,
param->transferType, &status),
"cannot access collective");
} else {
/* individual, noncollective call */
MPI_CHECK(Access(*(MPI_File *)fd, buffer, length,
MPI_CHECK(Access
(*(MPI_File *) fd, buffer, length,
param->transferType, &status),
"cannot access noncollective");
}
@ -295,7 +305,8 @@ IOR_Xfer_MPIIO(int access,
*/
if (param->useSharedFilePointer) {
/* find offset in file */
if (SeekOffset_MPIIO(*(MPI_File *)fd, param->offset, param) < 0) {
if (SeekOffset_MPIIO
(*(MPI_File *) fd, param->offset, param) < 0) {
/* if unsuccessful */
length = -1;
} else {
@ -307,18 +318,21 @@ IOR_Xfer_MPIIO(int access,
* MPI_BYTE, &status),
* "cannot access shared, collective");
*/
fprintf(stdout, "useSharedFilePointer not implemented\n");
fprintf(stdout,
"useSharedFilePointer not implemented\n");
}
} else {
if (param->collective) {
/* explicit, collective call */
MPI_CHECK(Access_at_all(*(MPI_File *)fd, param->offset,
MPI_CHECK(Access_at_all
(*(MPI_File *) fd, param->offset,
buffer, length, MPI_BYTE, &status),
"cannot access explicit, collective");
} else {
/* explicit, noncollective call */
MPI_CHECK(Access_at(*(MPI_File *)fd, param->offset, buffer,
length, MPI_BYTE, &status),
MPI_CHECK(Access_at
(*(MPI_File *) fd, param->offset,
buffer, length, MPI_BYTE, &status),
"cannot access explicit, noncollective");
}
}
@ -326,27 +340,22 @@ IOR_Xfer_MPIIO(int access,
return (length);
} /* IOR_Xfer_MPIIO() */
/******************************************************************************/
/*
* Perform fsync().
*/
void
IOR_Fsync_MPIIO(void * fd, IOR_param_t * param)
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)
void IOR_Close_MPIIO(void *fd, IOR_param_t * param)
{
MPI_CHECK(MPI_File_close((MPI_File *) fd), "cannot close file");
if ((param->useFileView == TRUE) && (param->fd_fppReadCheck == NULL)) {
@ -361,27 +370,23 @@ IOR_Close_MPIIO(void * fd,
free(fd);
} /* IOR_Close_MPIIO() */
/******************************************************************************/
/*
* Delete a file through the MPIIO interface.
*/
void
IOR_Delete_MPIIO(char * testFileName, IOR_param_t * param)
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)
void IOR_SetVersion_MPIIO(IOR_param_t * test)
{
int version, subversion;
MPI_CHECK(MPI_Get_version(&version, &subversion),
@ -390,7 +395,6 @@ IOR_SetVersion_MPIIO(IOR_param_t *test)
test->api, version, subversion);
} /* IOR_SetVersion_MPIIO() */
/************************ L O C A L F U N C T I O N S ***********************/
/******************************************************************************/
@ -399,12 +403,9 @@ IOR_SetVersion_MPIIO(IOR_param_t *test)
*/
static IOR_offset_t
SeekOffset_MPIIO(MPI_File fd,
IOR_offset_t offset,
IOR_param_t * param)
SeekOffset_MPIIO(MPI_File fd, IOR_offset_t offset, IOR_param_t * param)
{
int offsetFactor,
tasksPerFile;
int offsetFactor, tasksPerFile;
IOR_offset_t tempOffset;
tempOffset = offset;
@ -427,7 +428,8 @@ SeekOffset_MPIIO(MPI_File fd,
* from an absolute offset
*/
tempOffset = ((param->blockSize / param->transferSize)
* (tempOffset / (param->blockSize * tasksPerFile)))
* (tempOffset /
(param->blockSize * tasksPerFile)))
+ (((tempOffset % (param->blockSize * tasksPerFile))
- (offsetFactor * param->blockSize))
/ param->transferSize);
@ -438,19 +440,15 @@ SeekOffset_MPIIO(MPI_File fd,
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)
IOR_GetFileSize_MPIIO(IOR_param_t * test, MPI_Comm testComm, char *testFileName)
{
IOR_offset_t aggFileSizeFromStat,
tmpMin, tmpMax, tmpSum;
IOR_offset_t aggFileSizeFromStat, tmpMin, tmpMax, tmpSum;
MPI_File fd;
MPI_CHECK(MPI_File_open(testComm, testFileName, MPI_MODE_RDONLY,

View File

@ -67,10 +67,7 @@ ior_aiori_t ncmpi_aiori = {
};
extern int errno, /* error number */
numTasksWorld,
rank,
rankOffset,
verbose; /* verbose output */
numTasksWorld, rank, rankOffset, verbose; /* verbose output */
extern MPI_Comm testComm;
/***************************** F U N C T I O N S ******************************/
@ -79,9 +76,7 @@ extern MPI_Comm testComm;
* Create and open a file through the NCMPI interface.
*/
void *
IOR_Create_NCMPI(char * testFileName,
IOR_param_t * param)
void *IOR_Create_NCMPI(char *testFileName, IOR_param_t * param)
{
int *fd;
int fd_mode;
@ -123,15 +118,12 @@ IOR_Create_NCMPI(char * testFileName,
return (fd);
} /* IOR_Create_NCMPI() */
/******************************************************************************/
/*
* Open a file through the NCMPI interface.
*/
void *
IOR_Open_NCMPI(char * testFileName,
IOR_param_t * param)
void *IOR_Open_NCMPI(char *testFileName, IOR_param_t * param)
{
int *fd;
int fd_mode;
@ -173,7 +165,6 @@ IOR_Open_NCMPI(char * testFileName,
return (fd);
} /* IOR_Open_NCMPI() */
/******************************************************************************/
/*
* Write or read access to file using the NCMPI interface.
@ -182,20 +173,14 @@ IOR_Open_NCMPI(char * testFileName,
IOR_offset_t
IOR_Xfer_NCMPI(int access,
void *fd,
IOR_size_t * buffer,
IOR_offset_t length,
IOR_param_t * param)
IOR_size_t * buffer, IOR_offset_t length, IOR_param_t * param)
{
char *bufferPtr = (char *)buffer;
static int firstReadCheck = FALSE,
startDataSet;
int var_id,
dim_id[NUM_DIMS];
MPI_Offset bufSize[NUM_DIMS],
offset[NUM_DIMS];
static int firstReadCheck = FALSE, startDataSet;
int var_id, dim_id[NUM_DIMS];
MPI_Offset bufSize[NUM_DIMS], offset[NUM_DIMS];
IOR_offset_t segmentPosition;
int segmentNum,
transferNum;
int segmentNum, transferNum;
/* Wei-keng Liao: In ior.c line 1979 says "block size must be a multiple
of transfer size." Hence, length should always == param->transferSize
@ -212,7 +197,8 @@ IOR_Xfer_NCMPI(int access,
if (param->filePerProc == TRUE) {
segmentPosition = (IOR_offset_t) 0;
} else {
segmentPosition = (IOR_offset_t)((rank + rankOffset) % param->numTasks)
segmentPosition =
(IOR_offset_t) ((rank + rankOffset) % param->numTasks)
* param->blockSize;
}
if ((int)(param->offset - segmentPosition) == 0) {
@ -234,29 +220,35 @@ IOR_Xfer_NCMPI(int access,
if (startDataSet == TRUE &&
(access != READCHECK || firstReadCheck == TRUE)) {
if (access == WRITE) {
int numTransfers = param->blockSize / param->transferSize;
int numTransfers =
param->blockSize / param->transferSize;
/* Wei-keng Liao: change 1D array to 3D array of dimensions:
[segmentCount*numTasksWorld][numTransfers][transferSize]
Requirement: none of these dimensions should be > 4G,
*/
NCMPI_CHECK(ncmpi_def_dim(*(int *)fd, "segments_times_np",
NCMPI_CHECK(ncmpi_def_dim
(*(int *)fd, "segments_times_np",
NC_UNLIMITED, &dim_id[0]),
"cannot define data set dimensions");
NCMPI_CHECK(ncmpi_def_dim(*(int *)fd, "number_of_transfers",
NCMPI_CHECK(ncmpi_def_dim
(*(int *)fd, "number_of_transfers",
numTransfers, &dim_id[1]),
"cannot define data set dimensions");
NCMPI_CHECK(ncmpi_def_dim(*(int *)fd, "transfer_size",
NCMPI_CHECK(ncmpi_def_dim
(*(int *)fd, "transfer_size",
param->transferSize, &dim_id[2]),
"cannot define data set dimensions");
NCMPI_CHECK(ncmpi_def_var(*(int *)fd, "data_var", NC_BYTE,
NUM_DIMS, dim_id, &var_id),
NCMPI_CHECK(ncmpi_def_var
(*(int *)fd, "data_var", NC_BYTE, NUM_DIMS,
dim_id, &var_id),
"cannot define data set variables");
NCMPI_CHECK(ncmpi_enddef(*(int *)fd),
"cannot close data set define mode");
} else {
NCMPI_CHECK(ncmpi_inq_varid(*(int *)fd, "data_var", &var_id),
NCMPI_CHECK(ncmpi_inq_varid
(*(int *)fd, "data_var", &var_id),
"cannot retrieve data set variable");
}
@ -290,21 +282,25 @@ IOR_Xfer_NCMPI(int access,
/* access the file */
if (access == WRITE) { /* WRITE */
if (param->collective) {
NCMPI_CHECK(ncmpi_put_vara_all(*(int *)fd, var_id, offset, bufSize,
NCMPI_CHECK(ncmpi_put_vara_all
(*(int *)fd, var_id, offset, bufSize,
bufferPtr, length, MPI_BYTE),
"cannot write to data set");
} else {
NCMPI_CHECK(ncmpi_put_vara(*(int *)fd, var_id, offset, bufSize,
NCMPI_CHECK(ncmpi_put_vara
(*(int *)fd, var_id, offset, bufSize,
bufferPtr, length, MPI_BYTE),
"cannot write to data set");
}
} else { /* READ or CHECK */
if (param->collective == TRUE) {
NCMPI_CHECK(ncmpi_get_vara_all(*(int *)fd, var_id, offset, bufSize,
NCMPI_CHECK(ncmpi_get_vara_all
(*(int *)fd, var_id, offset, bufSize,
bufferPtr, length, MPI_BYTE),
"cannot read from data set");
} else {
NCMPI_CHECK(ncmpi_get_vara(*(int *)fd, var_id, offset, bufSize,
NCMPI_CHECK(ncmpi_get_vara
(*(int *)fd, var_id, offset, bufSize,
bufferPtr, length, MPI_BYTE),
"cannot read from data set");
}
@ -313,27 +309,22 @@ IOR_Xfer_NCMPI(int access,
return (length);
} /* IOR_Xfer_NCMPI() */
/******************************************************************************/
/*
* Perform fsync().
*/
void
IOR_Fsync_NCMPI(void * fd, IOR_param_t * param)
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)
void IOR_Close_NCMPI(void *fd, IOR_param_t * param)
{
if (param->collective == FALSE) {
NCMPI_CHECK(ncmpi_end_indep_data(*(int *)fd),
@ -343,33 +334,27 @@ IOR_Close_NCMPI(void * fd,
free(fd);
} /* IOR_Close_NCMPI() */
/******************************************************************************/
/*
* Delete a file through the NCMPI interface.
*/
void
IOR_Delete_NCMPI(char * testFileName, IOR_param_t * param)
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)
void IOR_SetVersion_NCMPI(IOR_param_t * test)
{
sprintf(test->apiVersion, "%s (%s)",
test->api, ncmpi_inq_libvers());
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 ***********************/
/******************************************************************************/
@ -377,22 +362,27 @@ IOR_SetVersion_NCMPI(IOR_param_t * test)
* Return the correct file mode for NCMPI.
*/
int
GetFileMode(IOR_param_t * param)
int GetFileMode(IOR_param_t * param)
{
int fd_mode = 0;
/* set IOR file flags to NCMPI flags */
/* -- file open flags -- */
if (param->openFlags & IOR_RDONLY) {fd_mode |= NC_NOWRITE;}
if (param->openFlags & IOR_RDONLY) {
fd_mode |= NC_NOWRITE;
}
if (param->openFlags & IOR_WRONLY) {
fprintf(stdout, "File write only not implemented in NCMPI\n");
}
if (param->openFlags & IOR_RDWR) {fd_mode |= NC_WRITE;}
if (param->openFlags & IOR_RDWR) {
fd_mode |= NC_WRITE;
}
if (param->openFlags & IOR_APPEND) {
fprintf(stdout, "File append not implemented in NCMPI\n");
}
if (param->openFlags & IOR_CREAT) {fd_mode |= NC_CLOBBER;}
if (param->openFlags & IOR_CREAT) {
fd_mode |= NC_CLOBBER;
}
if (param->openFlags & IOR_EXCL) {
fprintf(stdout, "Exclusive access not implemented in NCMPI\n");
}
@ -409,16 +399,13 @@ GetFileMode(IOR_param_t * param)
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)
IOR_GetFileSize_NCMPI(IOR_param_t * test, MPI_Comm testComm, char *testFileName)
{
return (IOR_GetFileSize_MPIIO(test, testComm, testFileName));
} /* IOR_GetFileSize_NCMPI() */

View File

@ -38,7 +38,6 @@
#define O_BINARY 0
#endif
/**************************** P R O T O T Y P E S *****************************/
void *IOR_Create_POSIX(char *, IOR_param_t *);
void *IOR_Open_POSIX(char *, IOR_param_t *);
@ -93,15 +92,14 @@ void set_o_direct_flag(int *fd)
* Creat and open a file through the POSIX interface.
*/
void *
IOR_Create_POSIX(char * testFileName,
IOR_param_t * param)
void *IOR_Create_POSIX(char *testFileName, IOR_param_t * param)
{
int fd_oflag = O_BINARY;
int *fd;
fd = (int *)malloc(sizeof(int));
if (fd == NULL) ERR("Unable to malloc file descriptor");
if (fd == NULL)
ERR("Unable to malloc file descriptor");
if (param->useO_DIRECT == TRUE)
set_o_direct_flag(&fd_oflag);
@ -115,7 +113,8 @@ IOR_Create_POSIX(char * testFileName,
MPI_CHECK(MPI_Barrier(testComm), "barrier error");
fd_oflag |= O_RDWR;
*fd = open64(testFileName, fd_oflag, 0664);
if (*fd < 0) ERR("open64() failed");
if (*fd < 0)
ERR("open64() failed");
} else {
struct lov_user_md opts = { 0 };
@ -127,28 +126,34 @@ IOR_Create_POSIX(char * testFileName,
/* File needs to be opened O_EXCL because we cannot set
Lustre striping information on a pre-existing file. */
fd_oflag |= O_CREAT | O_EXCL | O_RDWR | O_LOV_DELAY_CREATE;
fd_oflag |=
O_CREAT | O_EXCL | O_RDWR | O_LOV_DELAY_CREATE;
*fd = open64(testFileName, fd_oflag, 0664);
if (*fd < 0) {
fprintf(stdout, "\nUnable to open '%s': %s\n",
testFileName, strerror(errno));
MPI_CHECK(MPI_Abort(MPI_COMM_WORLD, -1), "MPI_Abort() error");
MPI_CHECK(MPI_Abort(MPI_COMM_WORLD, -1),
"MPI_Abort() error");
} else if (ioctl(*fd, LL_IOC_LOV_SETSTRIPE, &opts)) {
char *errmsg = "stripe already set";
if (errno != EEXIST && errno != EALREADY)
errmsg = strerror(errno);
fprintf(stdout, "\nError on ioctl for '%s' (%d): %s\n",
fprintf(stdout,
"\nError on ioctl for '%s' (%d): %s\n",
testFileName, *fd, errmsg);
MPI_CHECK(MPI_Abort(MPI_COMM_WORLD, -1), "MPI_Abort() error");
MPI_CHECK(MPI_Abort(MPI_COMM_WORLD, -1),
"MPI_Abort() error");
}
if (!param->filePerProc)
MPI_CHECK(MPI_Barrier(testComm), "barrier error");
MPI_CHECK(MPI_Barrier(testComm),
"barrier error");
}
} else {
#endif /* HAVE_LUSTRE_LUSTRE_USER_H */
fd_oflag |= O_CREAT | O_RDWR;
*fd = open64(testFileName, fd_oflag, 0664);
if (*fd < 0) ERR("open64() failed");
if (*fd < 0)
ERR("open64() failed");
#ifdef HAVE_LUSTRE_LUSTRE_USER_H
}
@ -162,34 +167,34 @@ IOR_Create_POSIX(char * testFileName,
return ((void *)fd);
} /* IOR_Create_POSIX() */
/******************************************************************************/
/*
* Open a file through the POSIX interface.
*/
void *
IOR_Open_POSIX(char * testFileName,
IOR_param_t * param)
void *IOR_Open_POSIX(char *testFileName, IOR_param_t * param)
{
int fd_oflag = O_BINARY;
int *fd;
fd = (int *)malloc(sizeof(int));
if (fd == NULL) ERR("Unable to malloc file descriptor");
if (fd == NULL)
ERR("Unable to malloc file descriptor");
if (param->useO_DIRECT == TRUE)
set_o_direct_flag(&fd_oflag);
fd_oflag |= O_RDWR;
*fd = open64(testFileName, fd_oflag);
if (*fd < 0) ERR("open64 failed");
if (*fd < 0)
ERR("open64 failed");
#ifdef HAVE_LUSTRE_LUSTRE_USER_H
if (param->lustre_ignore_locks) {
int lustre_ioctl_flags = LL_FILE_IGNORE_LOCK;
if (verbose >= VERBOSE_1) {
fprintf(stdout, "** Disabling lustre range locking **\n");
fprintf(stdout,
"** Disabling lustre range locking **\n");
}
if (ioctl(*fd, LL_IOC_SETFLAGS, &lustre_ioctl_flags) == -1)
ERR("ioctl(LL_IOC_SETFLAGS) failed");
@ -199,7 +204,6 @@ IOR_Open_POSIX(char * testFileName,
return ((void *)fd);
} /* IOR_Open_POSIX() */
/******************************************************************************/
/*
* Write or read access to file using the POSIX interface.
@ -208,9 +212,7 @@ IOR_Open_POSIX(char * testFileName,
IOR_offset_t
IOR_Xfer_POSIX(int access,
void *file,
IOR_size_t * buffer,
IOR_offset_t length,
IOR_param_t * param)
IOR_size_t * buffer, IOR_offset_t length, IOR_param_t * param)
{
int xferRetries = 0;
long long remaining = (long long)length;
@ -228,8 +230,10 @@ IOR_Xfer_POSIX(int access,
/* write/read file */
if (access == WRITE) { /* WRITE */
if (verbose >= VERBOSE_4) {
fprintf(stdout, "task %d writing to offset %lld\n",
rank, param->offset + length - remaining);
fprintf(stdout,
"task %d writing to offset %lld\n",
rank,
param->offset + length - remaining);
}
rc = write(fd, ptr, remaining);
if (param->fsyncPerWrite == TRUE)
@ -238,8 +242,10 @@ IOR_Xfer_POSIX(int access,
ERR("write() failed");
} else { /* READ or CHECK */
if (verbose >= VERBOSE_4) {
fprintf(stdout, "task %d reading from offset %lld\n",
rank, param->offset + length - remaining);
fprintf(stdout,
"task %d reading from offset %lld\n",
rank,
param->offset + length - remaining);
}
rc = read(fd, ptr, remaining);
if (rc == 0)
@ -255,7 +261,8 @@ IOR_Xfer_POSIX(int access,
rc, remaining,
param->offset + length - remaining);
if (param->singleXferAttempt == TRUE)
MPI_CHECK(MPI_Abort(MPI_COMM_WORLD, -1), "barrier error");
MPI_CHECK(MPI_Abort(MPI_COMM_WORLD, -1),
"barrier error");
if (xferRetries > MAX_RETRY)
ERR("too many retries -- aborting");
}
@ -268,75 +275,63 @@ IOR_Xfer_POSIX(int access,
return (length);
} /* IOR_Xfer_POSIX() */
/******************************************************************************/
/*
* Perform fsync().
*/
void
IOR_Fsync_POSIX(void * fd, IOR_param_t * param)
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)
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)
void IOR_Delete_POSIX(char *testFileName, IOR_param_t * param)
{
char errmsg[256];
sprintf(errmsg, "[RANK %03d]: unlink() of file \"%s\" failed\n",
rank, testFileName);
if (unlink(testFileName) != 0) WARN(errmsg);
if (unlink(testFileName) != 0)
WARN(errmsg);
} /* IOR_Delete_POSIX() */
/******************************************************************************/
/*
* Determine api version.
*/
void
IOR_SetVersion_POSIX(IOR_param_t *test)
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)
IOR_GetFileSize_POSIX(IOR_param_t * test, MPI_Comm testComm, char *testFileName)
{
struct stat stat_buf;
IOR_offset_t aggFileSizeFromStat,
tmpMin, tmpMax, tmpSum;
IOR_offset_t aggFileSizeFromStat, tmpMin, tmpMax, tmpSum;
if (stat(testFileName, &stat_buf) != 0) {
ERR("stat() failed");

953
src/ior.c

File diff suppressed because it is too large Load Diff

View File

@ -23,7 +23,8 @@ IOR_param_t initialTestParams;
* Check and correct all settings of each test in queue for correctness.
*/
void CheckRunSettings(IOR_queue_t *tests) {
void CheckRunSettings(IOR_queue_t * tests)
{
while (tests != NULL) {
/* If no write/read/check action requested, set both write and read */
if (tests->testParameters.writeFile == FALSE
@ -36,14 +37,14 @@ void CheckRunSettings(IOR_queue_t *tests) {
/* If numTasks set to 0, use all tasks */
if (tests->testParameters.numTasks == 0) {
MPI_CHECK(MPI_Comm_size(MPI_COMM_WORLD,
&tests->testParameters.numTasks),
&tests->
testParameters.numTasks),
"MPI_Comm_size() error");
}
tests = tests->nextTest;
}
} /* CheckRunSettings() */
/******************************************************************************/
/*
* Set flags from commandline string/value pairs.
@ -57,7 +58,8 @@ void DecodeDirective(char *line, IOR_param_t *test)
rc = sscanf(line, " %[^=# \t\r\n] = %[^# \t\r\n] ", option, value);
if (rc != 2 && rank == 0) {
fprintf(stdout, "Syntax error in configuration options: %s\n", line);
fprintf(stdout, "Syntax error in configuration options: %s\n",
line);
MPI_CHECK(MPI_Abort(MPI_COMM_WORLD, -1), "MPI_Abort() error");
}
if (strcasecmp(option, "api") == 0) {
@ -201,19 +203,18 @@ void DecodeDirective(char *line, IOR_param_t *test)
test->numTasks = atoi(value);
} else {
if (rank == 0)
fprintf(stdout, "Unrecognized parameter \"%s\"\n", option);
fprintf(stdout, "Unrecognized parameter \"%s\"\n",
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)
void ParseLine(char *line, IOR_param_t * test)
{
char *start, *end;
@ -228,15 +229,13 @@ ParseLine(char *line, IOR_param_t *test)
} /* 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)
int contains_only(char *haystack, char *needle)
{
char *ptr, *end;
@ -258,15 +257,13 @@ 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)
IOR_queue_t *ReadConfigScript(char *scriptName)
{
int test_num = 0;
int runflag = 0;
@ -309,7 +306,8 @@ ReadConfigScript(char * scriptName)
/* If this directive was preceded by a "run" line, then
create and initialize a new test structure */
if (runflag) {
newTest = (IOR_queue_t *)malloc(sizeof(IOR_queue_t));
newTest =
(IOR_queue_t *) malloc(sizeof(IOR_queue_t));
if (newTest == NULL)
ERR("malloc() failed");
newTest->testParameters = tail->testParameters;
@ -335,11 +333,11 @@ ReadConfigScript(char * scriptName)
* Parse Commandline.
*/
IOR_queue_t *
ParseCommandLine(int argc, char ** argv)
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";
=
"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;
@ -353,64 +351,158 @@ ParseCommandLine(int argc, char ** argv)
while ((c = getopt(argc, argv, opts)) != -1) {
switch (c) {
case 'A': initialTestParams.TestNum = atoi(optarg); break;
case 'a': strcpy(initialTestParams.api, optarg); break;
case 'b': initialTestParams.blockSize =
StringToBytes(optarg); break;
case 'B': initialTestParams.useO_DIRECT = TRUE; break;
case 'c': initialTestParams.collective = TRUE; break;
case 'C': initialTestParams.reorderTasks = TRUE; break;
case 'Q': initialTestParams.taskPerNodeOffset =
atoi(optarg); break;
case 'Z': initialTestParams.reorderTasksRandom = TRUE; break;
case 'X': initialTestParams.reorderTasksRandomSeed =
atoi(optarg); break;
case 'd': initialTestParams.interTestDelay = atoi(optarg); break;
case 'D': initialTestParams.deadlineForStonewalling =
atoi(optarg); break;
case 'Y': initialTestParams.fsyncPerWrite = TRUE; break;
case 'e': initialTestParams.fsync = TRUE; break;
case 'E': initialTestParams.useExistingTestFile = TRUE; break;
case 'f': tests = ReadConfigScript(optarg); break;
case 'F': initialTestParams.filePerProc = TRUE; break;
case 'g': initialTestParams.intraTestBarriers = TRUE; break;
case 'G': initialTestParams.setTimeStampSignature =
atoi(optarg); break;
case 'h': initialTestParams.showHelp = TRUE; break;
case 'H': initialTestParams.showHints = TRUE; break;
case 'i': initialTestParams.repetitions = atoi(optarg); break;
case 'I': initialTestParams.individualDataSets = TRUE; break;
case 'j': initialTestParams.outlierThreshold =
atoi(optarg); break;
case 'J': initialTestParams.setAlignment =
StringToBytes(optarg); break;
case 'k': initialTestParams.keepFile = TRUE; break;
case 'K': initialTestParams.keepFileWithError = TRUE; break;
case 'l': initialTestParams.storeFileOffset = TRUE; break;
case 'm': initialTestParams.multiFile = TRUE; break;
case 'n': initialTestParams.noFill = TRUE; break;
case 'N': initialTestParams.numTasks = atoi(optarg); break;
case 'o': strcpy(initialTestParams.testFileName, optarg); break;
case 'O': ParseLine(optarg, &initialTestParams); break;
case 'p': initialTestParams.preallocate = TRUE; break;
case 'P': initialTestParams.useSharedFilePointer = TRUE; break;
case 'q': initialTestParams.quitOnError = TRUE; break;
case 'r': initialTestParams.readFile = TRUE; break;
case 'R': initialTestParams.checkRead = TRUE; break;
case 's': initialTestParams.segmentCount = atoi(optarg); break;
case 'S': initialTestParams.useStridedDatatype = TRUE; break;
case 't': initialTestParams.transferSize =
StringToBytes(optarg); break;
case 'T': initialTestParams.maxTimeDuration = atoi(optarg);break;
case 'u': initialTestParams.uniqueDir = TRUE; break;
case 'U': strcpy(initialTestParams.hintsFileName, optarg); break;
case 'v': initialTestParams.verbose++; break;
case 'V': initialTestParams.useFileView = TRUE; break;
case 'w': initialTestParams.writeFile = TRUE; break;
case 'W': initialTestParams.checkWrite = TRUE; break;
case 'x': initialTestParams.singleXferAttempt = TRUE; break;
case 'z': initialTestParams.randomOffset = TRUE; break;
default: fprintf (stdout, "ParseCommandLine: unknown option `-%c'.\n", optopt);
case 'A':
initialTestParams.TestNum = atoi(optarg);
break;
case 'a':
strcpy(initialTestParams.api, optarg);
break;
case 'b':
initialTestParams.blockSize = StringToBytes(optarg);
break;
case 'B':
initialTestParams.useO_DIRECT = TRUE;
break;
case 'c':
initialTestParams.collective = TRUE;
break;
case 'C':
initialTestParams.reorderTasks = TRUE;
break;
case 'Q':
initialTestParams.taskPerNodeOffset = atoi(optarg);
break;
case 'Z':
initialTestParams.reorderTasksRandom = TRUE;
break;
case 'X':
initialTestParams.reorderTasksRandomSeed = atoi(optarg);
break;
case 'd':
initialTestParams.interTestDelay = atoi(optarg);
break;
case 'D':
initialTestParams.deadlineForStonewalling =
atoi(optarg);
break;
case 'Y':
initialTestParams.fsyncPerWrite = TRUE;
break;
case 'e':
initialTestParams.fsync = TRUE;
break;
case 'E':
initialTestParams.useExistingTestFile = TRUE;
break;
case 'f':
tests = ReadConfigScript(optarg);
break;
case 'F':
initialTestParams.filePerProc = TRUE;
break;
case 'g':
initialTestParams.intraTestBarriers = TRUE;
break;
case 'G':
initialTestParams.setTimeStampSignature = atoi(optarg);
break;
case 'h':
initialTestParams.showHelp = TRUE;
break;
case 'H':
initialTestParams.showHints = TRUE;
break;
case 'i':
initialTestParams.repetitions = atoi(optarg);
break;
case 'I':
initialTestParams.individualDataSets = TRUE;
break;
case 'j':
initialTestParams.outlierThreshold = atoi(optarg);
break;
case 'J':
initialTestParams.setAlignment = StringToBytes(optarg);
break;
case 'k':
initialTestParams.keepFile = TRUE;
break;
case 'K':
initialTestParams.keepFileWithError = TRUE;
break;
case 'l':
initialTestParams.storeFileOffset = TRUE;
break;
case 'm':
initialTestParams.multiFile = TRUE;
break;
case 'n':
initialTestParams.noFill = TRUE;
break;
case 'N':
initialTestParams.numTasks = atoi(optarg);
break;
case 'o':
strcpy(initialTestParams.testFileName, optarg);
break;
case 'O':
ParseLine(optarg, &initialTestParams);
break;
case 'p':
initialTestParams.preallocate = TRUE;
break;
case 'P':
initialTestParams.useSharedFilePointer = TRUE;
break;
case 'q':
initialTestParams.quitOnError = TRUE;
break;
case 'r':
initialTestParams.readFile = TRUE;
break;
case 'R':
initialTestParams.checkRead = TRUE;
break;
case 's':
initialTestParams.segmentCount = atoi(optarg);
break;
case 'S':
initialTestParams.useStridedDatatype = TRUE;
break;
case 't':
initialTestParams.transferSize = StringToBytes(optarg);
break;
case 'T':
initialTestParams.maxTimeDuration = atoi(optarg);
break;
case 'u':
initialTestParams.uniqueDir = TRUE;
break;
case 'U':
strcpy(initialTestParams.hintsFileName, optarg);
break;
case 'v':
initialTestParams.verbose++;
break;
case 'V':
initialTestParams.useFileView = TRUE;
break;
case 'w':
initialTestParams.writeFile = TRUE;
break;
case 'W':
initialTestParams.checkWrite = TRUE;
break;
case 'x':
initialTestParams.singleXferAttempt = TRUE;
break;
case 'z':
initialTestParams.randomOffset = TRUE;
break;
default:
fprintf(stdout,
"ParseCommandLine: unknown option `-%c'.\n",
optopt);
}
}
@ -430,4 +522,3 @@ ParseCommandLine(int argc, char ** argv)
return (tests);
} /* ParseCommandLine() */

View File

@ -34,10 +34,7 @@
extern int errno, /* error number */
numTasks, /* MPI variables */
rank,
rankOffset,
verbose; /* verbose output */
rank, rankOffset, verbose; /* verbose output */
/***************************** F U N C T I O N S ******************************/
@ -46,13 +43,13 @@ extern int errno, /* error number */
* Returns string containing the current time.
*/
char *
CurrentTimeString(void)
char *CurrentTimeString(void)
{
static time_t currentTime;
char *currentTimePtr;
if ((currentTime = time(NULL)) == -1) ERR("cannot get current time");
if ((currentTime = time(NULL)) == -1)
ERR("cannot get current time");
if ((currentTimePtr = ctime(&currentTime)) == NULL) {
ERR("cannot read current time");
}
@ -60,15 +57,12 @@ CurrentTimeString(void)
return (currentTimePtr);
} /* CurrentTimeString() */
/******************************************************************************/
/*
* Dump transfer buffer.
*/
void
DumpBuffer(void *buffer,
size_t size)
void DumpBuffer(void *buffer, size_t size)
{
size_t i, j;
unsigned long long *dumpBuf = (unsigned long long *)buffer;
@ -82,14 +76,12 @@ DumpBuffer(void *buffer,
return;
} /* DumpBuffer() */
/******************************************************************************/
/*
* Sends all strings to root nodes and displays.
*/
void
OutputToRoot(int numTasks, MPI_Comm comm, char * stringToDisplay)
void OutputToRoot(int numTasks, MPI_Comm comm, char *stringToDisplay)
{
int i;
int swapNeeded = TRUE;
@ -100,10 +92,12 @@ OutputToRoot(int numTasks, MPI_Comm comm, char * stringToDisplay)
/* malloc string array */
stringArray = (char **)malloc(sizeof(char *) * numTasks);
if (stringArray == NULL) ERR("out of memory");
if (stringArray == NULL)
ERR("out of memory");
for (i = 0; i < numTasks; i++) {
stringArray[i] = (char *)malloc(sizeof(char) * MAX_STR);
if (stringArray[i] == NULL) ERR("out of memory");
if (stringArray[i] == NULL)
ERR("out of memory");
}
strcpy(stringArray[rank], stringToDisplay);
@ -112,12 +106,13 @@ OutputToRoot(int numTasks, MPI_Comm comm, char * stringToDisplay)
/* MPI_receive all strings */
for (i = 1; i < numTasks; i++) {
MPI_CHECK(MPI_Recv(stringArray[i], MAX_STR, MPI_CHAR,
MPI_ANY_SOURCE, MPI_ANY_TAG, comm, &status),
"MPI_Recv() error");
MPI_ANY_SOURCE, MPI_ANY_TAG, comm,
&status), "MPI_Recv() error");
}
} else {
/* MPI_send string to root node */
MPI_CHECK(MPI_Send(stringArray[rank], MAX_STR, MPI_CHAR, 0, 0, comm),
MPI_CHECK(MPI_Send
(stringArray[rank], MAX_STR, MPI_CHAR, 0, 0, comm),
"MPI_Send() error");
}
MPI_CHECK(MPI_Barrier(comm), "barrier error");
@ -128,9 +123,11 @@ OutputToRoot(int numTasks, MPI_Comm comm, char * stringToDisplay)
while (swapNeeded) {
swapNeeded = FALSE;
for (i = 0; i < pairsToSwap; i++) {
if (strcmp(stringArray[i], stringArray[i+1]) > 0) {
if (strcmp(stringArray[i], stringArray[i + 1]) >
0) {
strcpy(tmpString, stringArray[i]);
strcpy(stringArray[i], stringArray[i+1]);
strcpy(stringArray[i],
stringArray[i + 1]);
strcpy(stringArray[i + 1], tmpString);
swapNeeded = TRUE;
}
@ -153,18 +150,14 @@ OutputToRoot(int numTasks, MPI_Comm comm, char * stringToDisplay)
free(stringArray);
} /* OutputToRoot() */
/******************************************************************************/
/*
* Set hints for MPIIO, HDF5, or NCMPI.
*/
void
SetHints(MPI_Info * mpiHints, char * hintsFileName)
void SetHints(MPI_Info * mpiHints, char *hintsFileName)
{
char hintString[MAX_STR],
settingVal[MAX_STR],
valueVal[MAX_STR];
char hintString[MAX_STR], settingVal[MAX_STR], valueVal[MAX_STR];
extern char **environ;
int i;
FILE *fd;
@ -200,33 +193,32 @@ SetHints(MPI_Info * mpiHints, char * hintsFileName)
} else {
/* iterate over hints file */
while (fgets(hintString, MAX_STR, fd) != NULL) {
if (strncmp(hintString, "IOR_HINT", strlen("IOR_HINT")) == 0) {
ExtractHint(settingVal, valueVal, hintString);
MPI_CHECK(MPI_Info_set(*mpiHints, settingVal, valueVal),
if (strncmp
(hintString, "IOR_HINT",
strlen("IOR_HINT")) == 0) {
ExtractHint(settingVal, valueVal,
hintString);
MPI_CHECK(MPI_Info_set
(*mpiHints, settingVal,
valueVal),
"cannot set info object");
}
}
/* close the hints files */
if (fclose(fd) != 0) ERR("cannot close hints file");
if (fclose(fd) != 0)
ERR("cannot close hints file");
}
}
} /* SetHints() */
/******************************************************************************/
/*
* Extract key/value pair from hint string.
*/
void
ExtractHint(char * settingVal,
char * valueVal,
char * hintString)
void ExtractHint(char *settingVal, char *valueVal, char *hintString)
{
char * settingPtr,
* valuePtr,
* tmpPtr1,
* tmpPtr2;
char *settingPtr, *valuePtr, *tmpPtr1, *tmpPtr2;
settingPtr = (char *)strtok(hintString, "=");
valuePtr = (char *)strtok(NULL, " \t\r\n");
@ -247,7 +239,6 @@ ExtractHint(char * settingVal,
strcpy(valueVal, valuePtr);
} /* ExtractHint() */
/******************************************************************************/
/*
* Show all hints (key/value pairs) in an MPI_Info object.
@ -255,11 +246,8 @@ ExtractHint(char * settingVal,
void ShowHints(MPI_Info * mpiHints)
{
char key[MPI_MAX_INFO_VAL],
value[MPI_MAX_INFO_VAL];
int flag,
i,
nkeys;
char key[MPI_MAX_INFO_VAL], value[MPI_MAX_INFO_VAL];
int flag, i, nkeys;
MPI_CHECK(MPI_Info_get_nkeys(*mpiHints, &nkeys),
"cannot get info object keys");
@ -274,14 +262,12 @@ void ShowHints(MPI_Info * mpiHints)
}
} /* 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 StringToBytes(char *size_str)
{
IOR_offset_t size = 0;
char range;
@ -290,9 +276,18 @@ StringToBytes(char * size_str)
rc = sscanf(size_str, "%lld%c", &size, &range);
if (rc == 2) {
switch ((int)range) {
case 'k': case 'K': size <<= 10; break;
case 'm': case 'M': size <<= 20; break;
case 'g': case 'G': size <<= 30; break;
case 'k':
case 'K':
size <<= 10;
break;
case 'm':
case 'M':
size <<= 20;
break;
case 'g':
case 'G':
size <<= 30;
break;
}
} else if (rc == 0) {
size = -1;
@ -300,14 +295,12 @@ StringToBytes(char * size_str)
return (size);
} /* StringToBytes() */
/******************************************************************************/
/*
* Displays size of file system and percent of data blocks and inodes used.
*/
void
ShowFileSystemSize(char *fileSystem)
void ShowFileSystemSize(char *fileSystem)
{
#ifndef _WIN32 /* FIXME */
int error;
@ -316,12 +309,9 @@ ShowFileSystemSize(char *fileSystem)
long long int fileSystemUnitVal = 1024 * 1024 * 1024;
long long int inodeUnitVal = 1024 * 1024;
long long int totalFileSystemSize,
freeFileSystemSize,
totalInodes,
freeInodes;
freeFileSystemSize, totalInodes, freeInodes;
double totalFileSystemSizeHR,
usedFileSystemPercentage,
usedInodePercentage;
usedFileSystemPercentage, usedInodePercentage;
#ifdef __sun /* SunOS does not support statfs(), instead uses statvfs() */
struct statvfs statusBuffer;
#else /* !__sun */
@ -349,8 +339,8 @@ ShowFileSystemSize(char *fileSystem)
usedFileSystemPercentage = (1 - ((double)freeFileSystemSize
/ (double)totalFileSystemSize)) * 100;
totalFileSystemSizeHR = (double)totalFileSystemSize
/ (double)fileSystemUnitVal;
totalFileSystemSizeHR =
(double)totalFileSystemSize / (double)fileSystemUnitVal;
if (totalFileSystemSizeHR > 1024) {
totalFileSystemSizeHR = totalFileSystemSizeHR / 1024;
fileSystemUnitStr = "TiB";
@ -359,31 +349,32 @@ ShowFileSystemSize(char *fileSystem)
/* inodes */
totalInodes = statusBuffer.f_files;
freeInodes = statusBuffer.f_ffree;
usedInodePercentage = (1 - ((double)freeInodes/(double)totalInodes)) * 100;
usedInodePercentage =
(1 - ((double)freeInodes / (double)totalInodes)) * 100;
/* show results */
if (realpath(fileSystem, realPath) == NULL) {
ERR("unable to use realpath()");
}
fprintf(stdout, "Path: %s\n", realPath);
fprintf(stdout, "FS: %.1f %s Used FS: %2.1f%% ", totalFileSystemSizeHR,
fileSystemUnitStr, usedFileSystemPercentage);
fprintf(stdout, "FS: %.1f %s Used FS: %2.1f%% ",
totalFileSystemSizeHR, fileSystemUnitStr,
usedFileSystemPercentage);
fprintf(stdout, "Inodes: %.1f Mi Used Inodes: %2.1f%%\n",
(double)totalInodes / (double)inodeUnitVal, usedInodePercentage);
(double)totalInodes / (double)inodeUnitVal,
usedInodePercentage);
fflush(stdout);
#endif /* _WIN32 */
return;
} /* ShowFileSystemSize() */
/******************************************************************************/
/*
* Return match of regular expression -- 0 is failure, 1 is success.
*/
int
Regex(char *string, char *pattern)
int Regex(char *string, char *pattern)
{
int retValue = 0;
#ifndef _WIN32 /* Okay to always not match */
@ -400,17 +391,13 @@ Regex(char *string, char *pattern)
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)
void CorruptFile(char *testFileName, IOR_param_t * test, int rep, int access)
{
IOR_offset_t tmpOff, range, eof;
char fileName[MAX_STR];
@ -430,9 +417,11 @@ void CorruptFile(char *testFileName,
} else { /* READCHECK */
range = test->transferSize;
}
tmpOff = (IOR_offset_t)((rand()/(float)RAND_MAX) * range) + test->offset;
tmpOff =
(IOR_offset_t) ((rand() / (float)RAND_MAX) * range) + test->offset;
if (tmpOff >= eof) tmpOff = tmpOff / 2;
if (tmpOff >= eof)
tmpOff = tmpOff / 2;
/* corrupt <fileName> at <offset> with <value> */
if (rank == 0 || test->filePerProc) {
@ -442,16 +431,12 @@ void CorruptFile(char *testFileName,
return;
} /* CorruptFile() */
/******************************************************************************/
/*
* Modify byte in file - used to testing write/read data checking.
*/
void
ModifyByteInFile(char * fileName,
IOR_offset_t offset,
int byteValue)
void ModifyByteInFile(char *fileName, IOR_offset_t offset, int byteValue)
{
int fd;
int rc;
@ -475,8 +460,8 @@ ModifyByteInFile(char * fileName,
if (rc == -1)
goto out;
fprintf(stdout,
"** DEBUG: offset %lld in %s changed from %d to %d **\n", offset,
fileName, (unsigned char)old, (unsigned char)new);
"** DEBUG: offset %lld in %s changed from %d to %d **\n",
offset, fileName, (unsigned char)old, (unsigned char)new);
out:
close(fd);
@ -484,14 +469,12 @@ out:
} /* ModifyByteInFile() */
#endif /* USE_UNDOC_OPT - corruptFile */
/******************************************************************************/
/*
* Seed random generator.
*/
void
SeedRandGen(MPI_Comm testComm)
void SeedRandGen(MPI_Comm testComm)
{
unsigned int randomSeed;
@ -510,7 +493,6 @@ SeedRandGen(MPI_Comm testComm)
} /* SeedRandGen() */
/******************************************************************************/
/*
* System info for Windows.
@ -522,7 +504,8 @@ int uname(struct utsname *name)
DWORD nodeNameSize = sizeof(name->nodename) - 1;
memset(name, 0, sizeof(struct utsname));
if (!GetComputerNameEx(ComputerNameDnsFullyQualified, name->nodename, &nodeNameSize))
if (!GetComputerNameEx
(ComputerNameDnsFullyQualified, name->nodename, &nodeNameSize))
ERR("GetComputerNameEx failed");
strncpy(name->sysname, "Windows", sizeof(name->sysname) - 1);