Impose proper file scoping and header usage.

Clean up the header files to only contain those things that
need to be shared between .c files.

Functions that are not shared are now declared static to
make their file scope explicit.  Functions that ARE shared
are declared in appropriate headers.

I am not going to claim that I caugh everything, but at
least it is a good start.
master
Christopher J. Morrone 2011-11-11 16:40:45 -08:00
parent e7fea4f102
commit a60ad0b088
14 changed files with 535 additions and 494 deletions

View File

@ -16,6 +16,10 @@
*
\******************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>

View File

@ -4,7 +4,7 @@ bin_PROGRAMS += IOR
endif
ior_SOURCES = ior.c utilities.c parse_options.c
ior_SOURCES += ior.h aiori.h iordef.h
ior_SOURCES += ior.h utilities.h parse_options.h aiori.h iordef.h
ior_LDADD =
if USE_POSIX_AIORI

View File

@ -9,12 +9,19 @@
*
\******************************************************************************/
#include "aiori.h" /* abstract IOR interface */
#include <errno.h> /* sys_errlist */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h> /* only for fprintf() */
#include <stdlib.h>
#include <sys/stat.h>
#include <hdf5.h>
#include <mpi.h>
#include "aiori.h" /* abstract IOR interface */
#include "utilities.h"
#include "iordef.h"
#define NUM_DIMS 1 /* number of dimensions to data set */
@ -69,37 +76,32 @@
#endif /* H5_VERS_MAJOR > 1 && H5_VERS_MINOR > 6 */
/**************************** P R O T O T Y P E S *****************************/
static IOR_offset_t SeekOffset_HDF5(void *, IOR_offset_t, IOR_param_t *);
void SetupDataSet_HDF5(void *, IOR_param_t *);
void *IOR_Create_HDF5(char *, IOR_param_t *);
void *IOR_Open_HDF5(char *, IOR_param_t *);
IOR_offset_t IOR_Xfer_HDF5(int, void *, IOR_size_t *,
static IOR_offset_t SeekOffset(void *, IOR_offset_t, IOR_param_t *);
static void SetupDataSet(void *, IOR_param_t *);
static void *HDF5_Create(char *, IOR_param_t *);
static void *HDF5_Open(char *, IOR_param_t *);
static IOR_offset_t HDF5_Xfer(int, void *, IOR_size_t *,
IOR_offset_t, IOR_param_t *);
void IOR_Close_HDF5(void *, IOR_param_t *);
void IOR_Delete_HDF5(char *, IOR_param_t *);
void IOR_SetVersion_HDF5(IOR_param_t *);
void IOR_Fsync_HDF5(void *, IOR_param_t *);
IOR_offset_t IOR_GetFileSize_HDF5(IOR_param_t *, MPI_Comm, char *);
static void HDF5_Close(void *, IOR_param_t *);
static void HDF5_Delete(char *, IOR_param_t *);
static void HDF5_SetVersion(IOR_param_t *);
static void HDF5_Fsync(void *, IOR_param_t *);
static IOR_offset_t HDF5_GetFileSize(IOR_param_t *, MPI_Comm, char *);
/************************** D E C L A R A T I O N S ***************************/
ior_aiori_t hdf5_aiori = {
"HDF5",
IOR_Create_HDF5,
IOR_Open_HDF5,
IOR_Xfer_HDF5,
IOR_Close_HDF5,
IOR_Delete_HDF5,
IOR_SetVersion_HDF5,
IOR_Fsync_HDF5,
IOR_GetFileSize_HDF5
HDF5_Create,
HDF5_Open,
HDF5_Xfer,
HDF5_Close,
HDF5_Delete,
HDF5_SetVersion,
HDF5_Fsync,
HDF5_GetFileSize
};
extern int errno, /* error number */
rank, rankOffset, verbose; /* verbose output */
extern MPI_Comm testComm;
static hid_t xferPropList; /* xfer property list */
hid_t dataSet; /* data set id */
hid_t dataSpace; /* data space id */
@ -112,15 +114,15 @@ int newlyOpenedFile; /* newly opened file */
/*
* Create and open a file through the HDF5 interface.
*/
void *IOR_Create_HDF5(char *testFileName, IOR_param_t * param)
static void *HDF5_Create(char *testFileName, IOR_param_t * param)
{
return IOR_Open_HDF5(testFileName, param);
return HDF5_Open(testFileName, param);
}
/*
* Open a file through the HDF5 interface.
*/
void *IOR_Open_HDF5(char *testFileName, IOR_param_t * param)
static void *HDF5_Open(char *testFileName, IOR_param_t * param)
{
hid_t accessPropList, createPropList;
hsize_t memStart[NUM_DIMS],
@ -322,10 +324,8 @@ void *IOR_Open_HDF5(char *testFileName, IOR_param_t * param)
/*
* Write or read access to file using the HDF5 interface.
*/
IOR_offset_t
IOR_Xfer_HDF5(int access,
void *fd,
IOR_size_t * buffer, IOR_offset_t length, IOR_param_t * param)
static IOR_offset_t HDF5_Xfer(int access, void *fd, IOR_size_t * buffer,
IOR_offset_t length, IOR_param_t * param)
{
static int firstReadCheck = FALSE, startNewDataSet;
IOR_offset_t segmentPosition, segmentSize;
@ -374,10 +374,10 @@ IOR_Xfer_HDF5(int access,
HDF5_CHECK(H5Sclose(fileDataSpace),
"cannot close file data space");
}
SetupDataSet_HDF5(fd, param);
SetupDataSet(fd, param);
}
SeekOffset_HDF5(fd, param->offset, param);
SeekOffset(fd, param->offset, param);
/* this is necessary to reset variables for reaccessing file */
startNewDataSet = FALSE;
@ -401,7 +401,7 @@ IOR_Xfer_HDF5(int access,
/*
* Perform fsync().
*/
void IOR_Fsync_HDF5(void *fd, IOR_param_t * param)
static void HDF5_Fsync(void *fd, IOR_param_t * param)
{
;
}
@ -409,7 +409,7 @@ void IOR_Fsync_HDF5(void *fd, IOR_param_t * param)
/*
* Close a file through the HDF5 interface.
*/
void IOR_Close_HDF5(void *fd, IOR_param_t * param)
static void HDF5_Close(void *fd, IOR_param_t * param)
{
if (param->fd_fppReadCheck == NULL) {
HDF5_CHECK(H5Dclose(dataSet), "cannot close data set");
@ -428,7 +428,7 @@ void IOR_Close_HDF5(void *fd, IOR_param_t * param)
/*
* Delete a file through the HDF5 interface.
*/
void IOR_Delete_HDF5(char *testFileName, IOR_param_t * param)
static void HDF5_Delete(char *testFileName, IOR_param_t * param)
{
if (unlink(testFileName) != 0)
WARN("cannot delete file");
@ -437,7 +437,7 @@ void IOR_Delete_HDF5(char *testFileName, IOR_param_t * param)
/*
* Determine api version.
*/
void IOR_SetVersion_HDF5(IOR_param_t * test)
static void HDF5_SetVersion(IOR_param_t * test)
{
unsigned major, minor, release;
if (H5get_libversion(&major, &minor, &release) < 0) {
@ -456,8 +456,8 @@ void IOR_SetVersion_HDF5(IOR_param_t * test)
/*
* Seek to offset in file using the HDF5 interface and set up hyperslab.
*/
static IOR_offset_t SeekOffset_HDF5(void *fd, IOR_offset_t offset,
IOR_param_t * param)
static static HDF5_offset_t SeekOffset(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];
@ -491,12 +491,12 @@ static IOR_offset_t SeekOffset_HDF5(void *fd, IOR_offset_t offset,
hsStart, hsStride, hsCount, hsBlock),
"cannot select hyperslab");
return (offset);
} /* SeekOffset_HDF5() */
}
/*
* Create HDF5 data set.
*/
static void SetupDataSet_HDF5(void *fd, IOR_param_t * param)
static static void SetupDataSet(void *fd, IOR_param_t * param)
{
char dataSetName[MAX_STR];
hid_t dataSetPropList;
@ -557,8 +557,8 @@ static void SetupDataSet_HDF5(void *fd, IOR_param_t * param)
/*
* Use MPIIO call to get file size.
*/
IOR_offset_t
IOR_GetFileSize_HDF5(IOR_param_t * test, MPI_Comm testComm, char *testFileName)
static IOR_offset_t
HDF5_GetFileSize(IOR_param_t * test, MPI_Comm testComm, char *testFileName)
{
return (IOR_GetFileSize_MPIIO(test, testComm, testFileName));
return (MPIIO_GetFileSize(test, testComm, testFileName));
}

View File

@ -9,49 +9,48 @@
*
\******************************************************************************/
#include "aiori.h" /* abstract IOR interface */
#include <errno.h> /* sys_errlist */
#include <stdio.h> /* only for fprintf() */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include "ior.h"
#include "iordef.h"
#include "aiori.h"
#include "utilities.h"
#ifndef MPIAPI
#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(MPI_File, IOR_offset_t, IOR_param_t *);
void *IOR_Create_MPIIO(char *, IOR_param_t *);
void *IOR_Open_MPIIO(char *, IOR_param_t *);
IOR_offset_t IOR_Xfer_MPIIO(int, void *, IOR_size_t *,
IOR_offset_t, IOR_param_t *);
void IOR_Close_MPIIO(void *, IOR_param_t *);
void IOR_Delete_MPIIO(char *, IOR_param_t *);
void IOR_SetVersion_MPIIO(IOR_param_t *);
void IOR_Fsync_MPIIO(void *, IOR_param_t *);
IOR_offset_t IOR_GetFileSize_MPIIO(IOR_param_t *, MPI_Comm, char *);
static void *MPIIO_Create(char *, IOR_param_t *);
static void *MPIIO_Open(char *, IOR_param_t *);
static IOR_offset_t MPIIO_Xfer(int, void *, IOR_size_t *,
IOR_offset_t, IOR_param_t *);
static void MPIIO_Close(void *, IOR_param_t *);
static void MPIIO_Delete(char *, IOR_param_t *);
static void MPIIO_SetVersion(IOR_param_t *);
static void MPIIO_Fsync(void *, IOR_param_t *);
/************************** D E C L A R A T I O N S ***************************/
extern int errno;
extern int rank;
extern int rankOffset;
extern int verbose;
extern MPI_Comm testComm;
ior_aiori_t mpiio_aiori = {
"MPIIO",
IOR_Create_MPIIO,
IOR_Open_MPIIO,
IOR_Xfer_MPIIO,
IOR_Close_MPIIO,
IOR_Delete_MPIIO,
IOR_SetVersion_MPIIO,
IOR_Fsync_MPIIO,
IOR_GetFileSize_MPIIO
MPIIO_Create,
MPIIO_Open,
MPIIO_Xfer,
MPIIO_Close,
MPIIO_Delete,
MPIIO_SetVersion,
MPIIO_Fsync,
MPIIO_GetFileSize
};
/***************************** F U N C T I O N S ******************************/
@ -59,15 +58,15 @@ ior_aiori_t mpiio_aiori = {
/*
* Create and open a file through the MPIIO interface.
*/
void *IOR_Create_MPIIO(char *testFileName, IOR_param_t * param)
static void *MPIIO_Create(char *testFileName, IOR_param_t * param)
{
return IOR_Open_MPIIO(testFileName, param);
return MPIIO_Open(testFileName, param);
}
/*
* Open a file through the MPIIO interface. Setup file view.
*/
void *IOR_Open_MPIIO(char *testFileName, IOR_param_t * param)
static void *MPIIO_Open(char *testFileName, IOR_param_t * param)
{
int fd_mode = (int)0,
offsetFactor,
@ -210,10 +209,8 @@ void *IOR_Open_MPIIO(char *testFileName, IOR_param_t * param)
/*
* Write or read access to file using the MPIIO interface.
*/
IOR_offset_t
IOR_Xfer_MPIIO(int access,
void *fd,
IOR_size_t * buffer, IOR_offset_t length, IOR_param_t * param)
static IOR_offset_t MPIIO_Xfer(int access, void *fd, IOR_size_t * buffer,
IOR_offset_t length, IOR_param_t * param)
{
int (MPIAPI * Access) (MPI_File, void *, int,
MPI_Datatype, MPI_Status *);
@ -259,7 +256,7 @@ IOR_Xfer_MPIIO(int access,
*/
if (param->useFileView) {
/* find offset in file */
if (SeekOffset_MPIIO(*(MPI_File *) fd, param->offset, param) <
if (SeekOffset(*(MPI_File *) fd, param->offset, param) <
0) {
/* if unsuccessful */
length = -1;
@ -297,7 +294,7 @@ IOR_Xfer_MPIIO(int access,
*/
if (param->useSharedFilePointer) {
/* find offset in file */
if (SeekOffset_MPIIO
if (SeekOffset
(*(MPI_File *) fd, param->offset, param) < 0) {
/* if unsuccessful */
length = -1;
@ -335,15 +332,15 @@ IOR_Xfer_MPIIO(int access,
/*
* Perform fsync().
*/
void IOR_Fsync_MPIIO(void *fd, IOR_param_t * param)
static void MPIIO_Fsync(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)
static void MPIIO_Close(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,7 +358,7 @@ void IOR_Close_MPIIO(void *fd, IOR_param_t * param)
/*
* Delete a file through the MPIIO interface.
*/
void IOR_Delete_MPIIO(char *testFileName, IOR_param_t * param)
static void MPIIO_Delete(char *testFileName, IOR_param_t * param)
{
MPI_CHECK(MPI_File_delete(testFileName, (MPI_Info) MPI_INFO_NULL),
"cannot delete file");
@ -370,7 +367,7 @@ void IOR_Delete_MPIIO(char *testFileName, IOR_param_t * param)
/*
* Determine api version.
*/
void IOR_SetVersion_MPIIO(IOR_param_t * test)
static void MPIIO_SetVersion(IOR_param_t * test)
{
int version, subversion;
MPI_CHECK(MPI_Get_version(&version, &subversion),
@ -382,8 +379,8 @@ void IOR_SetVersion_MPIIO(IOR_param_t * test)
/*
* 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)
static IOR_offset_t SeekOffset(MPI_File fd, IOR_offset_t offset,
IOR_param_t * param)
{
int offsetFactor, tasksPerFile;
IOR_offset_t tempOffset;
@ -422,9 +419,10 @@ SeekOffset_MPIIO(MPI_File fd, IOR_offset_t offset, IOR_param_t * param)
/*
* Use MPI_File_get_size() to return aggregate file size.
* NOTE: This function is used by the HDF5 and NCMPI backends.
*/
IOR_offset_t
IOR_GetFileSize_MPIIO(IOR_param_t * test, MPI_Comm testComm, char *testFileName)
IOR_offset_t MPIIO_GetFileSize(IOR_param_t * test, MPI_Comm testComm,
char *testFileName)
{
IOR_offset_t aggFileSizeFromStat, tmpMin, tmpMax, tmpSum;
MPI_File fd;
@ -458,5 +456,4 @@ IOR_GetFileSize_MPIIO(IOR_param_t * test, MPI_Comm testComm, char *testFileName)
}
return (aggFileSizeFromStat);
}

View File

@ -9,13 +9,20 @@
*
\******************************************************************************/
#include "aiori.h" /* abstract IOR interface */
#include <errno.h> /* sys_errlist */
#include <stdio.h> /* only for fprintf() */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <pnetcdf.h>
#include "ior.h"
#include "iordef.h"
#include "aiori.h"
#include "utilities.h"
#define NUM_DIMS 3 /* number of dimensions to data set */
/*
@ -38,43 +45,36 @@
static int GetFileMode(IOR_param_t *);
void *IOR_Create_NCMPI(char *, IOR_param_t *);
void *IOR_Open_NCMPI(char *, IOR_param_t *);
IOR_offset_t IOR_Xfer_NCMPI(int, void *, IOR_size_t *,
IOR_offset_t, IOR_param_t *);
void IOR_Close_NCMPI(void *, IOR_param_t *);
void IOR_Delete_NCMPI(char *, IOR_param_t *);
void IOR_SetVersion_NCMPI(IOR_param_t *);
void IOR_Fsync_NCMPI(void *, IOR_param_t *);
IOR_offset_t IOR_GetFileSize_NCMPI(IOR_param_t *, MPI_Comm, char *);
static void *NCMPI_Create(char *, IOR_param_t *);
static void *NCMPI_Open(char *, IOR_param_t *);
static IOR_offset_t NCMPI_Xfer(int, void *, IOR_size_t *,
IOR_offset_t, IOR_param_t *);
static void NCMPI_Close(void *, IOR_param_t *);
static void NCMPI_Delete(char *, IOR_param_t *);
static void NCMPI_SetVersion(IOR_param_t *);
static void NCMPI_Fsync(void *, IOR_param_t *);
static IOR_offset_t NCMPI_GetFileSize(IOR_param_t *, MPI_Comm, char *);
/************************** D E C L A R A T I O N S ***************************/
ior_aiori_t ncmpi_aiori = {
"NCMPI",
IOR_Create_NCMPI,
IOR_Open_NCMPI,
IOR_Xfer_NCMPI,
IOR_Close_NCMPI,
IOR_Delete_NCMPI,
IOR_SetVersion_NCMPI,
IOR_Fsync_NCMPI,
IOR_GetFileSize_NCMPI
NCMPI_Create,
NCMPI_Open,
NCMPI_Xfer,
NCMPI_Close,
NCMPI_Delete,
NCMPI_SetVersion,
NCMPI_Fsync,
NCMPI_GetFileSize
};
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)
static void *NCMPI_Create(char *testFileName, IOR_param_t * param)
{
int *fd;
int fd_mode;
@ -119,7 +119,7 @@ void *IOR_Create_NCMPI(char *testFileName, IOR_param_t * param)
/*
* Open a file through the NCMPI interface.
*/
void *IOR_Open_NCMPI(char *testFileName, IOR_param_t * param)
static void *NCMPI_Open(char *testFileName, IOR_param_t * param)
{
int *fd;
int fd_mode;
@ -164,10 +164,8 @@ void *IOR_Open_NCMPI(char *testFileName, IOR_param_t * param)
/*
* Write or read access to file using the NCMPI interface.
*/
IOR_offset_t
IOR_Xfer_NCMPI(int access,
void *fd,
IOR_size_t * buffer, IOR_offset_t length, IOR_param_t * param)
static IOR_offset_t NCMPI_Xfer(int access, void *fd, IOR_size_t * buffer,
IOR_offset_t length, IOR_param_t * param)
{
char *bufferPtr = (char *)buffer;
static int firstReadCheck = FALSE, startDataSet;
@ -306,7 +304,7 @@ IOR_Xfer_NCMPI(int access,
/*
* Perform fsync().
*/
void IOR_Fsync_NCMPI(void *fd, IOR_param_t * param)
static void NCMPI_Fsync(void *fd, IOR_param_t * param)
{
;
}
@ -314,7 +312,7 @@ void IOR_Fsync_NCMPI(void *fd, IOR_param_t * param)
/*
* Close a file through the NCMPI interface.
*/
void IOR_Close_NCMPI(void *fd, IOR_param_t * param)
static void NCMPI_Close(void *fd, IOR_param_t * param)
{
if (param->collective == FALSE) {
NCMPI_CHECK(ncmpi_end_indep_data(*(int *)fd),
@ -327,7 +325,7 @@ void IOR_Close_NCMPI(void *fd, IOR_param_t * param)
/*
* Delete a file through the NCMPI interface.
*/
void IOR_Delete_NCMPI(char *testFileName, IOR_param_t * param)
static void NCMPI_Delete(char *testFileName, IOR_param_t * param)
{
if (unlink(testFileName) != 0)
WARN("unlink() failed");
@ -336,7 +334,7 @@ void IOR_Delete_NCMPI(char *testFileName, IOR_param_t * param)
/*
* Determine api version.
*/
void IOR_SetVersion_NCMPI(IOR_param_t * test)
static void NCMPI_SetVersion(IOR_param_t * test)
{
sprintf(test->apiVersion, "%s (%s)", test->api, ncmpi_inq_libvers());
}
@ -384,8 +382,8 @@ static int GetFileMode(IOR_param_t * param)
/*
* Use MPIIO call to get file size.
*/
IOR_offset_t
IOR_GetFileSize_NCMPI(IOR_param_t * test, MPI_Comm testComm, char *testFileName)
static IOR_offset_t NCMPI_GetFileSize(IOR_param_t * test, MPI_Comm testComm,
char *testFileName)
{
return (IOR_GetFileSize_MPIIO(test, testComm, testFileName));
return (MPIIO_GetFileSize(test, testComm, testFileName));
}

View File

@ -9,22 +9,29 @@
*
\******************************************************************************/
#include "aiori.h" /* abstract IOR interface */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#ifdef __linux__
#include <sys/ioctl.h> /* necessary for: */
#define __USE_GNU /* O_DIRECT and */
#include <fcntl.h> /* IO operations */
#undef __USE_GNU
#endif /* __linux__ */
#include <errno.h> /* sys_errlist */
#include <errno.h>
#include <fcntl.h> /* IO operations */
#include <stdio.h> /* only for fprintf() */
#include <stdlib.h>
#include <sys/stat.h>
#include <assert.h>
#ifdef HAVE_LUSTRE_LUSTRE_USER_H
#include <lustre/lustre_user.h>
#endif /* HAVE_LUSTRE_LUSTRE_USER_H */
#endif
#include "ior.h"
#include "aiori.h"
#include "iordef.h"
#ifndef open64 /* necessary for TRU64 -- */
#define open64 open /* unlikely, but may pose */
@ -39,36 +46,30 @@
#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 *);
IOR_offset_t IOR_Xfer_POSIX(int, void *, IOR_size_t *,
IOR_offset_t, IOR_param_t *);
void IOR_Close_POSIX(void *, IOR_param_t *);
void IOR_Delete_POSIX(char *, IOR_param_t *);
void IOR_SetVersion_POSIX(IOR_param_t *);
void IOR_Fsync_POSIX(void *, IOR_param_t *);
IOR_offset_t IOR_GetFileSize_POSIX(IOR_param_t *, MPI_Comm, char *);
static void *POSIX_Create(char *, IOR_param_t *);
static void *POSIX_Open(char *, IOR_param_t *);
static IOR_offset_t POSIX_Xfer(int, void *, IOR_size_t *,
IOR_offset_t, IOR_param_t *);
static void POSIX_Close(void *, IOR_param_t *);
static void POSIX_Delete(char *, IOR_param_t *);
static void POSIX_SetVersion(IOR_param_t *);
static void POSIX_Fsync(void *, IOR_param_t *);
static IOR_offset_t POSIX_GetFileSize(IOR_param_t *, MPI_Comm, char *);
/************************** D E C L A R A T I O N S ***************************/
ior_aiori_t posix_aiori = {
"POSIX",
IOR_Create_POSIX,
IOR_Open_POSIX,
IOR_Xfer_POSIX,
IOR_Close_POSIX,
IOR_Delete_POSIX,
IOR_SetVersion_POSIX,
IOR_Fsync_POSIX,
IOR_GetFileSize_POSIX
POSIX_Create,
POSIX_Open,
POSIX_Xfer,
POSIX_Close,
POSIX_Delete,
POSIX_SetVersion,
POSIX_Fsync,
POSIX_GetFileSize
};
extern int errno;
extern int rank;
extern int rankOffset;
extern int verbose;
extern MPI_Comm testComm;
/***************************** F U N C T I O N S ******************************/
void set_o_direct_flag(int *fd)
@ -90,7 +91,7 @@ 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)
static void *POSIX_Create(char *testFileName, IOR_param_t * param)
{
int fd_oflag = O_BINARY;
int *fd;
@ -168,7 +169,7 @@ void *IOR_Create_POSIX(char *testFileName, IOR_param_t * param)
/*
* Open a file through the POSIX interface.
*/
void *IOR_Open_POSIX(char *testFileName, IOR_param_t * param)
static void *POSIX_Open(char *testFileName, IOR_param_t * param)
{
int fd_oflag = O_BINARY;
int *fd;
@ -203,10 +204,8 @@ void *IOR_Open_POSIX(char *testFileName, IOR_param_t * param)
/*
* Write or read access to file using the POSIX interface.
*/
IOR_offset_t
IOR_Xfer_POSIX(int access,
void *file,
IOR_size_t * buffer, IOR_offset_t length, IOR_param_t * param)
static IOR_offset_t POSIX_Xfer(int access, void *file, IOR_size_t * buffer,
IOR_offset_t length, IOR_param_t * param)
{
int xferRetries = 0;
long long remaining = (long long)length;
@ -231,7 +230,7 @@ IOR_Xfer_POSIX(int access,
}
rc = write(fd, ptr, remaining);
if (param->fsyncPerWrite == TRUE)
IOR_Fsync_POSIX(&fd, param);
POSIX_Fsync(&fd, param);
if (rc == -1)
ERR("write() failed");
} else { /* READ or CHECK */
@ -272,7 +271,7 @@ IOR_Xfer_POSIX(int access,
/*
* Perform fsync().
*/
void IOR_Fsync_POSIX(void *fd, IOR_param_t * param)
static void POSIX_Fsync(void *fd, IOR_param_t * param)
{
if (fsync(*(int *)fd) != 0)
WARN("fsync() failed");
@ -281,7 +280,7 @@ void IOR_Fsync_POSIX(void *fd, IOR_param_t * param)
/*
* Close a file through the POSIX interface.
*/
void IOR_Close_POSIX(void *fd, IOR_param_t * param)
static void POSIX_Close(void *fd, IOR_param_t * param)
{
if (close(*(int *)fd) != 0)
ERR("close() failed");
@ -291,7 +290,7 @@ void IOR_Close_POSIX(void *fd, IOR_param_t * param)
/*
* Delete a file through the POSIX interface.
*/
void IOR_Delete_POSIX(char *testFileName, IOR_param_t * param)
static void POSIX_Delete(char *testFileName, IOR_param_t * param)
{
char errmsg[256];
sprintf(errmsg, "[RANK %03d]: unlink() of file \"%s\" failed\n",
@ -303,16 +302,16 @@ void IOR_Delete_POSIX(char *testFileName, IOR_param_t * param)
/*
* Determine api version.
*/
void IOR_SetVersion_POSIX(IOR_param_t * test)
static void POSIX_SetVersion(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)
static IOR_offset_t POSIX_GetFileSize(IOR_param_t * test, MPI_Comm testComm,
char *testFileName)
{
struct stat stat_buf;
IOR_offset_t aggFileSizeFromStat, tmpMin, tmpMax, tmpSum;

View File

@ -12,14 +12,14 @@
#ifndef _AIORI_H
#define _AIORI_H
#include "iordef.h" /* IOR Definitions */
#include <mpi.h>
#ifndef MPI_FILE_NULL
# include <mpio.h>
#endif /* not MPI_FILE_NULL */
#include <string.h>
#include "ior.h"
#include "iordef.h" /* IOR Definitions */
/*************************** D E F I N I T I O N S ****************************/
@ -46,129 +46,6 @@
#define IOR_IWOTH 1024 /* write permission: other */
#define IOR_IXOTH 2048 /* execute permission: other */
/******************************************************************************/
/*
* The parameter struct holds all of the "global" data to be passed,
* as well as results to be parsed.
*
* NOTE: If IOR_Param_t is changed, also change:
* init_IOR_Param_t() [ior.c]
* DisplayUsage() [ior.c]
* ShowTest() [ior.c]
* DecodeDirective() [parse_options.c]
* ParseCommandLine() [parse_options.c]
* USER_GUIDE
*/
typedef struct
{
char debug[MAX_STR]; /* debug info string */
unsigned int mode; /* file permissions */
unsigned int openFlags; /* open flags */
int TestNum; /* test reference number */
char api[MAX_STR]; /* API for I/O */
char apiVersion[MAX_STR]; /* API version */
char platform[MAX_STR]; /* platform type */
char testFileName[MAXPATHLEN]; /* full name for test */
char testFileName_fppReadCheck[MAXPATHLEN];/* filename for fpp read check */
char hintsFileName[MAXPATHLEN]; /* full name for hints file */
char options[MAXPATHLEN]; /* options string */
int numTasks; /* number of tasks for test */
int nodes; /* number of nodes for test */
int tasksPerNode; /* number of tasks per node */
int repetitions; /* number of repetitions of test */
int repCounter; /* rep counter */
int multiFile; /* multiple files */
int interTestDelay; /* delay between reps in seconds */
double * writeVal[2]; /* array to write results */
double * readVal[2]; /* array to read results */
int open; /* flag for writing or reading */
int readFile; /* read of existing file */
int writeFile; /* write of file */
int filePerProc; /* single file or file-per-process */
int reorderTasks; /* reorder tasks for read back and check */
int taskPerNodeOffset; /* task node offset for reading files */
int reorderTasksRandom; /* reorder tasks for random file read back */
int reorderTasksRandomSeed; /* reorder tasks for random file read seed */
int checkWrite; /* check read after write */
int checkRead; /* check read after read */
int keepFile; /* don't delete the testfile on exit */
int keepFileWithError; /* don't delete the testfile with errors */
int errorFound; /* error found in data check */
int quitOnError; /* quit code when error in check */
int collective; /* collective I/O */
IOR_offset_t segmentCount; /* number of segments (or HDF5 datasets) */
IOR_offset_t blockSize; /* contiguous bytes to write per task */
IOR_offset_t transferSize; /* size of transfer in bytes */
IOR_offset_t offset; /* offset for read/write */
IOR_offset_t * aggFileSizeFromCalc; /* calculated aggregate file size */
IOR_offset_t * aggFileSizeFromStat; /* stat() aggregate file size */
IOR_offset_t * aggFileSizeFromXfer; /* transfered aggregate file size */
IOR_offset_t * aggFileSizeForBW; /* aggregate file size used for b/w */
int preallocate; /* preallocate file size */
int useFileView; /* use MPI_File_set_view */
int useSharedFilePointer; /* use shared file pointer */
int useStridedDatatype; /* put strided access into datatype */
int useO_DIRECT; /* use O_DIRECT, bypassing I/O buffers */
int showHints; /* show hints */
int showHelp; /* show options and help */
int uniqueDir; /* use unique directory for each fpp */
int useExistingTestFile; /* do not delete test file before access */
int storeFileOffset; /* use file offset as stored signature */
int deadlineForStonewalling; /* max time in seconds to run any test phase */
int maxTimeDuration; /* max time in minutes to run tests */
int outlierThreshold; /* warn on outlier N seconds from mean */
int verbose; /* verbosity */
int setTimeStampSignature; /* set time stamp signature */
unsigned int timeStampSignatureValue; /* value for time stamp signature */
void * fd_fppReadCheck; /* additional fd for fpp read check */
int randomSeed; /* random seed for write/read check */
int randomOffset; /* access is to random offsets */
MPI_Comm testComm; /* MPI communicator */
/* POSIX variables */
int singleXferAttempt; /* do not retry transfer if incomplete */
int fsyncPerWrite; /* fsync() after each write */
int fsync; /* fsync() after write */
/* MPI variables */
MPI_Datatype transferType; /* datatype for transfer */
MPI_Datatype fileType; /* filetype for file view */
/* HDF5 variables */
int individualDataSets; /* datasets not shared by all procs */
int noFill; /* no fill in file creation */
IOR_offset_t setAlignment; /* alignment in bytes */
/* NCMPI variables */
int var_id; /* variable id handle for data set */
/* Lustre variables */
int lustre_stripe_count;
int lustre_stripe_size;
int lustre_start_ost;
int lustre_set_striping; /* flag that we need to set lustre striping */
int lustre_ignore_locks;
#if USE_UNDOC_OPT
int corruptFile;
int fillTheFileSystem;
int includeDeleteTime;
int multiReRead;
/* NFS variables */
char NFS_rootPath[MAXPATHLEN]; /* absolute path to NFS servers */
char NFS_serverName[MAXPATHLEN]; /* prefix for NFS server name */
int NFS_serverCount; /* number of NFS servers to be used */
#endif /* USE_UNDOC_OPT */
int id; /* test's unique ID */
int intraTestBarriers; /* barriers between open/op and op/close */
} IOR_param_t;
/**************************** P R O T O T Y P E S *****************************/
typedef struct ior_aiori {
char *name;
void *(*create)(char *, IOR_param_t *);
@ -182,8 +59,12 @@ typedef struct ior_aiori {
IOR_offset_t (*get_file_size)(IOR_param_t *, MPI_Comm, char *);
} ior_aiori_t;
void init_IOR_Param_t(IOR_param_t *p);
void SetHints (MPI_Info *, char *);
void ShowHints (MPI_Info *);
ior_aiori_t posix_aiori;
ior_aiori_t mpiio_aiori;
ior_aiori_t hdf5_aiori;
ior_aiori_t ncmpi_aiori;
IOR_offset_t MPIIO_GetFileSize(IOR_param_t * test, MPI_Comm testComm,
char *testFileName);
#endif /* not _AIORI_H */

195
src/ior.c
View File

@ -5,15 +5,16 @@
* *
\******************************************************************************/
#include "aiori.h" /* IOR I/O interfaces */
#include "ior.h" /* IOR definitions
and prototypes */
#include <ctype.h> /* tolower() */
#include <errno.h> /* sys_errlist */
#include <math.h>
#include <mpi.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h> /* tolower() */
#include <errno.h>
#include <math.h>
#include <mpi.h>
#include <string.h>
#include <sys/stat.h> /* struct stat */
#include <time.h>
@ -23,36 +24,26 @@
#endif
#include <assert.h>
/************************** D E C L A R A T I O N S ***************************/
#include "ior.h"
#include "aiori.h"
#include "utilities.h"
#include "parse_options.h"
extern IOR_param_t initialTestParams;
extern int errno; /* error number */
extern char **environ;
int totalErrorCount = 0;
/* globals used by other files, also defined "extern" in ior.h */
int numTasksWorld = 0;
int rank = 0;
int rankOffset = 0;
int tasksPerNode = 0; /* tasks per node */
int verbose = VERBOSE_0; /* verbose output */
double wall_clock_delta = 0;
double wall_clock_deviation;
MPI_Comm testComm;
/* file scope globals */
extern char **environ;
int totalErrorCount = 0;
double wall_clock_delta = 0;
double wall_clock_deviation;
ior_aiori_t *backend;
#ifdef USE_POSIX_AIORI
extern ior_aiori_t posix_aiori;
#endif
#ifdef USE_MPIIO_AIORI
extern ior_aiori_t mpiio_aiori;
#endif
#ifdef USE_HDF5_AIORI
extern ior_aiori_t hdf5_aiori;
#endif
#ifdef USE_NCMPI_AIORI
extern ior_aiori_t ncmpi_aiori;
#endif
ior_aiori_t *available_aiori[] = {
#ifdef USE_POSIX_AIORI
&posix_aiori,
@ -69,6 +60,47 @@ ior_aiori_t *available_aiori[] = {
NULL
};
static void AioriBind(char *);
static void CheckForOutliers(IOR_param_t *, double **, int, int);
static void CheckFileSize(IOR_param_t *, IOR_offset_t, int);
static char *CheckTorF(char *);
static size_t CompareBuffers(void *, void *, size_t,
IOR_offset_t, IOR_param_t *, int);
static int CountErrors(IOR_param_t *, int, int);
static int CountTasksPerNode(int, MPI_Comm);
static void *CreateBuffer(size_t);
static void DelaySecs(int);
static void DisplayFreespace(IOR_param_t *);
static void DisplayOutliers(int, double, char *, int, int);
static void DisplayUsage(char **);
static void DistributeHints(void);
static void FillBuffer(void *, IOR_param_t *, unsigned long long, int);
static void FreeBuffers(int, void *, void *, void *, IOR_offset_t *);
static void GetTestFileName(char *, IOR_param_t *);
static double GetTimeStamp(void);
static char *HumanReadable(IOR_offset_t, int);
static char *LowerCase(char *);
static void PPDouble(int, double, char *);
static char *PrependDir(IOR_param_t *, char *);
static char **ParseFileName(char *, int *);
static void ReadCheck(void *, void *, void *, void *, IOR_param_t *,
IOR_offset_t, IOR_offset_t, IOR_offset_t *,
IOR_offset_t *, int, int *);
static void ReduceIterResults(IOR_param_t *, double **, int, int);
static void RemoveFile(char *, int, IOR_param_t *);
static void SetupXferBuffers(void **, void **, void **,
IOR_param_t *, int, int);
static IOR_queue_t *SetupTests(int, char **);
static void ShowInfo(int, char **, IOR_param_t *);
static void ShowSetup(IOR_param_t *);
static void ShowTest(IOR_param_t *);
static void SummarizeResults(IOR_param_t *);
static void TestIoSys(IOR_param_t *);
static double TimeDeviation(void);
static void ValidTests(IOR_param_t *);
static IOR_offset_t WriteOrRead(IOR_param_t *, void *, int);
static void WriteTimes(IOR_param_t *, double **, int, int);
/********************************** M A I N ***********************************/
int main(int argc, char **argv)
@ -170,7 +202,7 @@ void init_IOR_Param_t(IOR_param_t * p)
* Bind the global "backend" pointer to the requested backend AIORI's
* function table.
*/
void AioriBind(char *api)
static void AioriBind(char *api)
{
ior_aiori_t **tmp;
@ -186,9 +218,9 @@ void AioriBind(char *api)
ERR("unrecognized IO API");
}
} /* AioriBind() */
}
void
static void
DisplayOutliers(int numTasks,
double timerVal,
char *timeString, int access, int outlierThreshold)
@ -221,12 +253,13 @@ DisplayOutliers(int numTasks,
fprintf(stdout, " (mean=%f, stddev=%f)\n", mean, sd);
fflush(stdout);
}
} /* 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)
static void CheckForOutliers(IOR_param_t * test, double **timer, int rep,
int access)
{
int shift;
@ -251,13 +284,13 @@ void CheckForOutliers(IOR_param_t * test, double **timer, int rep, int access)
DisplayOutliers(test->numTasks, timer[shift + 5][rep], "end time",
access, test->outlierThreshold);
} /* 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)
static void CheckFileSize(IOR_param_t * test, IOR_offset_t dataMoved, int rep)
{
MPI_CHECK(MPI_Allreduce(&dataMoved, &test->aggFileSizeFromXfer[rep],
1, MPI_LONG_LONG_INT, MPI_SUM, testComm),
@ -286,12 +319,12 @@ void CheckFileSize(IOR_param_t * test, IOR_offset_t dataMoved, int rep)
}
test->aggFileSizeForBW[rep] = test->aggFileSizeFromXfer[rep];
} /* CheckFileSize() */
}
/*
* Check if string is true or false.
*/
char *CheckTorF(char *string)
static char *CheckTorF(char *string)
{
string = LowerCase(string);
if (strcmp(string, "false") == 0) {
@ -300,13 +333,13 @@ char *CheckTorF(char *string)
strcpy(string, "1");
}
return (string);
} /* CheckTorF() */
}
/*
* Compare buffers after reading/writing each transfer. Displays only first
* difference in buffers and returns total errors counted.
*/
size_t
static size_t
CompareBuffers(void *expectedBuffer,
void *unknownBuffer,
size_t size,
@ -412,7 +445,7 @@ CompareBuffers(void *expectedBuffer,
/*
* Count all errors across all tasks; report errors found.
*/
int CountErrors(IOR_param_t * test, int access, int errors)
static int CountErrors(IOR_param_t * test, int access, int errors)
{
int allErrors = 0;
@ -455,7 +488,7 @@ int CountErrors(IOR_param_t * test, int access, int errors)
/*
* Compares hostnames to determine the number of tasks per node
*/
int CountTasksPerNode(int numTasks, MPI_Comm comm)
static int CountTasksPerNode(int numTasks, MPI_Comm comm)
{
char localhost[MAX_STR], hostname[MAX_STR], taskOnNode[MAX_STR];
int count = 1, resultsLen = MAX_STR, i;
@ -493,12 +526,12 @@ int CountTasksPerNode(int numTasks, MPI_Comm comm)
}
return (count);
} /* CountTasksPerNode() */
}
/*
* Allocate a page-aligned (required by O_DIRECT) buffer.
*/
void *CreateBuffer(size_t size)
static void *CreateBuffer(size_t size)
{
size_t pageSize;
size_t pageMask;
@ -544,19 +577,19 @@ IOR_queue_t *CreateNewTest(int test_num)
/*
* Sleep for 'delay' seconds.
*/
void DelaySecs(int delay)
static void DelaySecs(int delay)
{
if (rank == 0 && delay > 0) {
if (verbose >= VERBOSE_1)
fprintf(stdout, "delaying %d seconds . . .\n", delay);
sleep(delay);
}
} /* DelaySecs() */
}
/*
* Display freespace (df).
*/
void DisplayFreespace(IOR_param_t * test)
static void DisplayFreespace(IOR_param_t * test)
{
char fileName[MAX_STR] = { 0 };
int i;
@ -588,12 +621,12 @@ void DisplayFreespace(IOR_param_t * test)
ShowFileSystemSize(fileName);
return;
} /* DisplayFreespace() */
}
/*
* Display usage of script file.
*/
void DisplayUsage(char **argv)
static void DisplayUsage(char **argv)
{
char *opts[] = {
"OPTIONS:",
@ -708,7 +741,7 @@ void DistributeHints(void)
* ints, store transfer offset. If storeFileOffset option is used, the file
* (not transfer) offset is stored instead.
*/
void
static void
FillBuffer(void *buffer,
IOR_param_t * test, unsigned long long offset, int fillrank)
{
@ -732,7 +765,7 @@ FillBuffer(void *buffer,
/*
* Free transfer buffers.
*/
void
static void
FreeBuffers(int access,
void *checkBuffer,
void *readCheckBuffer, void *buffer, IOR_offset_t * offsetArray)
@ -795,7 +828,7 @@ void GetPlatformName(char *platformName)
* Return test file name to access.
* for single shared file, fileNames[0] is returned in testFileName
*/
void GetTestFileName(char *testFileName, IOR_param_t * test)
static void GetTestFileName(char *testFileName, IOR_param_t * test)
{
char **fileNames,
initialTestFileName[MAXPATHLEN],
@ -851,7 +884,7 @@ void GetTestFileName(char *testFileName, IOR_param_t * test)
* Get time stamp. Use MPI_Timer() unless _NO_MPI_TIMER is defined,
* in which case use gettimeofday().
*/
double GetTimeStamp(void)
static double GetTimeStamp(void)
{
double timeVal;
#ifdef _NO_MPI_TIMER
@ -875,7 +908,7 @@ double GetTimeStamp(void)
/*
* Convert IOR_offset_t value to human readable string.
*/
char *HumanReadable(IOR_offset_t value, int base)
static char *HumanReadable(IOR_offset_t value, int base)
{
char *valueStr;
int m = 0, g = 0;
@ -922,7 +955,7 @@ char *HumanReadable(IOR_offset_t value, int base)
/*
* Change string to lower case.
*/
char *LowerCase(char *string)
static char *LowerCase(char *string)
{
char *nextChar = string;
@ -936,7 +969,7 @@ char *LowerCase(char *string)
/*
* Parse file name.
*/
char **ParseFileName(char *name, int *count)
static char **ParseFileName(char *name, int *count)
{
char **fileNames, *tmp, *token;
char delimiterString[3] = { FILENAME_DELIMITER, '\n', '\0' };
@ -977,7 +1010,7 @@ char **ParseFileName(char *name, int *count)
* 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)
static void PPDouble(int leftjustify, double number, char *append)
{
if (number < 0) {
fprintf(stdout, " - %s", append);
@ -1004,7 +1037,7 @@ void PPDouble(int leftjustify, double number, char *append)
* 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)
static char *PrependDir(IOR_param_t * test, char *rootDir)
{
char *dir;
char fname[MAX_STR + 1];
@ -1063,7 +1096,7 @@ char *PrependDir(IOR_param_t * test, char *rootDir)
/*
* Read and then reread buffer to confirm data read twice matches.
*/
void
static void
ReadCheck(void *fd,
void *buffer,
void *checkBuffer,
@ -1125,8 +1158,8 @@ ReadCheck(void *fd,
% test->numTasks;
readCheckFromRank = (rank + (test->numTasks
-
(test->reorderTasks ? test->
tasksPerNode : 0)))
(test->
reorderTasks ? test->tasksPerNode : 0)))
% test->numTasks;
MPI_CHECK(MPI_Barrier(testComm), "barrier error");
MPI_Sendrecv(checkBuffer, transfer, MPI_CHAR, readCheckToRank, 1,
@ -1143,7 +1176,8 @@ ReadCheck(void *fd,
* Reduce test results, and show if verbose set.
*/
void ReduceIterResults(IOR_param_t * test, double **timer, int rep, int access)
static void ReduceIterResults(IOR_param_t * test, double **timer, int rep,
int access)
{
double reduced[12] = { 0 },
diff[6], currentWrite, currentRead, totalWriteTime, totalReadTime;
@ -1244,7 +1278,7 @@ void ReduceIterResults(IOR_param_t * test, double **timer, int rep, int access)
/*
* 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)
static void RemoveFile(char *testFileName, int filePerProc, IOR_param_t * test)
{
int tmpRankOffset;
if (filePerProc) {
@ -1271,7 +1305,7 @@ void RemoveFile(char *testFileName, int filePerProc, IOR_param_t * test)
/*
* Setup tests by parsing commandline and creating test script.
*/
IOR_queue_t *SetupTests(int argc, char **argv)
static IOR_queue_t *SetupTests(int argc, char **argv)
{
IOR_queue_t *tests, *testsHead;
@ -1304,7 +1338,7 @@ IOR_queue_t *SetupTests(int argc, char **argv)
/*
* Setup transfer buffers, creating and filling as needed.
*/
void
static void
SetupXferBuffers(void **buffer,
void **checkBuffer,
void **readCheckBuffer,
@ -1326,7 +1360,7 @@ SetupXferBuffers(void **buffer,
/*
* Print header information for test output.
*/
void ShowInfo(int argc, char **argv, IOR_param_t * test)
static void ShowInfo(int argc, char **argv, IOR_param_t * test)
{
int i;
struct utsname unamebuf;
@ -1392,7 +1426,7 @@ void ShowInfo(int argc, char **argv, IOR_param_t * test)
/*
* Show simple test output with max results for iterations.
*/
void ShowSetup(IOR_param_t * test)
static void ShowSetup(IOR_param_t * test)
{
IOR_offset_t aggFileSizeForBW;
@ -1480,7 +1514,7 @@ void ShowSetup(IOR_param_t * test)
/*
* Show test description.
*/
void ShowTest(IOR_param_t * test)
static void ShowTest(IOR_param_t * test)
{
fprintf(stdout, "\n\n ================================\n\n");
fprintf(stdout, "TEST:\t%s=%d\n", "id", test->id);
@ -1551,7 +1585,7 @@ void ShowTest(IOR_param_t * test)
/*
* Summarize results, showing max rates (and min, mean, stddev if verbose)
*/
void SummarizeResults(IOR_param_t * test)
static void SummarizeResults(IOR_param_t * test)
{
int rep, ival;
double maxWrite[2], minWrite[2], maxRead[2], minRead[2];
@ -1720,7 +1754,7 @@ void SummarizeResults(IOR_param_t * test)
/*
* Using the test parameters, run iteration(s) of single test.
*/
void TestIoSys(IOR_param_t * test)
static void TestIoSys(IOR_param_t * test)
{
char testFileName[MAX_STR];
double *timer[12];
@ -2066,7 +2100,8 @@ void TestIoSys(IOR_param_t * test)
filecont[(ifile +
rankoffs
[ifile]) %
test->numTasks]++;
test->
numTasks]++;
}
memset((void *)filehits, 0,
test->numTasks *
@ -2199,8 +2234,9 @@ void TestIoSys(IOR_param_t * test)
test);
rankOffset = tmpRankOffset;
test->fd_fppReadCheck =
backend->
open(test->testFileName_fppReadCheck, test);
backend->open(test->
testFileName_fppReadCheck,
test);
}
dataMoved = WriteOrRead(test, fd, READCHECK);
if (test->filePerProc) {
@ -2252,7 +2288,7 @@ void TestIoSys(IOR_param_t * test)
/*
* Determine any spread (range) between node times.
*/
double TimeDeviation(void)
static double TimeDeviation(void)
{
double timestamp;
double min = 0;
@ -2280,7 +2316,7 @@ double TimeDeviation(void)
/*
* Determine if valid tests from parameters.
*/
void ValidTests(IOR_param_t * test)
static void ValidTests(IOR_param_t * test)
{
IOR_param_t defaults;
@ -2434,7 +2470,8 @@ void ValidTests(IOR_param_t * test)
ERR("Lustre stripe options are incompatible with useExistingTestFile");
}
IOR_offset_t *GetOffsetArraySequential(IOR_param_t * test, int pretendRank)
static IOR_offset_t *GetOffsetArraySequential(IOR_param_t * test,
int pretendRank)
{
IOR_offset_t i, j, k = 0;
IOR_offset_t offsets;
@ -2468,8 +2505,8 @@ IOR_offset_t *GetOffsetArraySequential(IOR_param_t * test, int pretendRank)
return (offsetArray);
}
IOR_offset_t *GetOffsetArrayRandom(IOR_param_t * test, int pretendRank,
int access)
static IOR_offset_t *GetOffsetArrayRandom(IOR_param_t * test, int pretendRank,
int access)
{
int seed;
IOR_offset_t i, value, tmp;
@ -2540,7 +2577,7 @@ IOR_offset_t *GetOffsetArrayRandom(IOR_param_t * test, int pretendRank,
* 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)
static IOR_offset_t WriteOrRead(IOR_param_t * test, void *fd, int access)
{
int errors = 0;
IOR_offset_t amtXferred,
@ -2629,7 +2666,7 @@ IOR_offset_t WriteOrRead(IOR_param_t * test, void *fd, int access)
/*
* Write times taken during each iteration of the test.
*/
void
static void
WriteTimes(IOR_param_t * test, double **timer, int iteration, int writeOrRead)
{
char accessType[MAX_STR];

205
src/ior.h
View File

@ -9,83 +9,146 @@
#define _IOR_H
#ifdef HAVE_CONFIG_H
# include "config.h"
#include "config.h"
#endif
#include "aiori.h" /* abstract IOR interfaces */
#include "iordef.h" /* IOR Definitions */
#include "iordef.h"
/*************************** D E F I N I T I O N S ****************************/
extern int numTasksWorld;
extern int rank;
extern int rankOffset;
extern int tasksPerNode;
extern int verbose;
extern MPI_Comm testComm;
/******************************************************************************/
/*
* The parameter struct holds all of the "global" data to be passed,
* as well as results to be parsed.
*
* NOTE: If IOR_Param_t is changed, also change:
* init_IOR_Param_t() [ior.c]
* DisplayUsage() [ior.c]
* ShowTest() [ior.c]
* DecodeDirective() [parse_options.c]
* ParseCommandLine() [parse_options.c]
* USER_GUIDE
*/
typedef struct
{
char debug[MAX_STR]; /* debug info string */
unsigned int mode; /* file permissions */
unsigned int openFlags; /* open flags */
int TestNum; /* test reference number */
char api[MAX_STR]; /* API for I/O */
char apiVersion[MAX_STR]; /* API version */
char platform[MAX_STR]; /* platform type */
char testFileName[MAXPATHLEN]; /* full name for test */
char testFileName_fppReadCheck[MAXPATHLEN];/* filename for fpp read check */
char hintsFileName[MAXPATHLEN]; /* full name for hints file */
char options[MAXPATHLEN]; /* options string */
int numTasks; /* number of tasks for test */
int nodes; /* number of nodes for test */
int tasksPerNode; /* number of tasks per node */
int repetitions; /* number of repetitions of test */
int repCounter; /* rep counter */
int multiFile; /* multiple files */
int interTestDelay; /* delay between reps in seconds */
double * writeVal[2]; /* array to write results */
double * readVal[2]; /* array to read results */
int open; /* flag for writing or reading */
int readFile; /* read of existing file */
int writeFile; /* write of file */
int filePerProc; /* single file or file-per-process */
int reorderTasks; /* reorder tasks for read back and check */
int taskPerNodeOffset; /* task node offset for reading files */
int reorderTasksRandom; /* reorder tasks for random file read back */
int reorderTasksRandomSeed; /* reorder tasks for random file read seed */
int checkWrite; /* check read after write */
int checkRead; /* check read after read */
int keepFile; /* don't delete the testfile on exit */
int keepFileWithError; /* don't delete the testfile with errors */
int errorFound; /* error found in data check */
int quitOnError; /* quit code when error in check */
int collective; /* collective I/O */
IOR_offset_t segmentCount; /* number of segments (or HDF5 datasets) */
IOR_offset_t blockSize; /* contiguous bytes to write per task */
IOR_offset_t transferSize; /* size of transfer in bytes */
IOR_offset_t offset; /* offset for read/write */
IOR_offset_t * aggFileSizeFromCalc; /* calculated aggregate file size */
IOR_offset_t * aggFileSizeFromStat; /* stat() aggregate file size */
IOR_offset_t * aggFileSizeFromXfer; /* transfered aggregate file size */
IOR_offset_t * aggFileSizeForBW; /* aggregate file size used for b/w */
int preallocate; /* preallocate file size */
int useFileView; /* use MPI_File_set_view */
int useSharedFilePointer; /* use shared file pointer */
int useStridedDatatype; /* put strided access into datatype */
int useO_DIRECT; /* use O_DIRECT, bypassing I/O buffers */
int showHints; /* show hints */
int showHelp; /* show options and help */
int uniqueDir; /* use unique directory for each fpp */
int useExistingTestFile; /* do not delete test file before access */
int storeFileOffset; /* use file offset as stored signature */
int deadlineForStonewalling; /* max time in seconds to run any test phase */
int maxTimeDuration; /* max time in minutes to run tests */
int outlierThreshold; /* warn on outlier N seconds from mean */
int verbose; /* verbosity */
int setTimeStampSignature; /* set time stamp signature */
unsigned int timeStampSignatureValue; /* value for time stamp signature */
void * fd_fppReadCheck; /* additional fd for fpp read check */
int randomSeed; /* random seed for write/read check */
int randomOffset; /* access is to random offsets */
MPI_Comm testComm; /* MPI communicator */
/* POSIX variables */
int singleXferAttempt; /* do not retry transfer if incomplete */
int fsyncPerWrite; /* fsync() after each write */
int fsync; /* fsync() after write */
/* MPI variables */
MPI_Datatype transferType; /* datatype for transfer */
MPI_Datatype fileType; /* filetype for file view */
/* HDF5 variables */
int individualDataSets; /* datasets not shared by all procs */
int noFill; /* no fill in file creation */
IOR_offset_t setAlignment; /* alignment in bytes */
/* NCMPI variables */
int var_id; /* variable id handle for data set */
/* Lustre variables */
int lustre_stripe_count;
int lustre_stripe_size;
int lustre_start_ost;
int lustre_set_striping; /* flag that we need to set lustre striping */
int lustre_ignore_locks;
#if USE_UNDOC_OPT
int corruptFile;
int fillTheFileSystem;
int includeDeleteTime;
int multiReRead;
/* NFS variables */
char NFS_rootPath[MAXPATHLEN]; /* absolute path to NFS servers */
char NFS_serverName[MAXPATHLEN]; /* prefix for NFS server name */
int NFS_serverCount; /* number of NFS servers to be used */
#endif /* USE_UNDOC_OPT */
int id; /* test's unique ID */
int intraTestBarriers; /* barriers between open/op and op/close */
} IOR_param_t;
/* define the queuing structure for the test parameters */
typedef struct IOR_queue_t {
IOR_param_t testParameters;
struct IOR_queue_t * nextTest;
IOR_param_t testParameters;
struct IOR_queue_t *nextTest;
} IOR_queue_t;
IOR_queue_t *CreateNewTest(int);
void GetPlatformName(char *);
void init_IOR_Param_t(IOR_param_t *p);
/**************************** P R O T O T Y P E S *****************************/
/* functions used in ior.c */
void AioriBind (char *);
void CheckForOutliers (IOR_param_t *, double **, int, int);
void CheckFileSize (IOR_param_t *, IOR_offset_t, int);
char * CheckTorF (char *);
size_t CompareBuffers (void *, void *, size_t,
IOR_offset_t, IOR_param_t *, int);
int CountErrors (IOR_param_t *, int, int);
int CountTasksPerNode(int, MPI_Comm);
void * CreateBuffer (size_t);
IOR_queue_t * CreateNewTest (int);
void DelaySecs (int);
void DisplayFreespace (IOR_param_t *);
void DisplayOutliers (int, double, char *, int, int);
void DisplayUsage (char **);
void DistributeHints (void);
void FillBuffer (void *, IOR_param_t *,
unsigned long long, int);
void FreeBuffers (int, void *, void *, void *, IOR_offset_t *);
void GetPlatformName (char *);
void GetTestFileName (char *, IOR_param_t *);
double GetTimeStamp (void);
char * HumanReadable (IOR_offset_t, int);
char * LowerCase (char *);
void OutputToRoot (int, MPI_Comm, char *);
void PPDouble (int, double, char *);
char * PrependDir (IOR_param_t *, char *);
IOR_queue_t * ParseCommandLine (int, char **);
char ** ParseFileName (char *, int *);
void ReadCheck (void *, void *, void *, void *, IOR_param_t *,
IOR_offset_t, IOR_offset_t, IOR_offset_t *,
IOR_offset_t *, int, int *);
void ReduceIterResults(IOR_param_t *, double **, int, int);
int Regex (char *, char *);
void RemoveFile (char *, int, IOR_param_t *);
int Regex (char *, char *);
void SetupXferBuffers (void **, void **, void **,
IOR_param_t *, int, int);
IOR_queue_t * SetupTests (int, char **);
void ShowFileSystemSize (char *);
void ShowInfo (int, char **, IOR_param_t *);
void ShowSetup (IOR_param_t *);
void ShowTest (IOR_param_t *);
void SummarizeResults (IOR_param_t *);
void TestIoSys (IOR_param_t *);
double TimeDeviation (void);
void ValidTests (IOR_param_t *);
IOR_offset_t WriteOrRead (IOR_param_t *, void *, int);
void WriteTimes (IOR_param_t *, double **, int, int);
/* functions used in utilities.c */
char * CurrentTimeString(void);
void DumpBuffer (void *, size_t);
void ExtractHint (char *, char *, char *);
IOR_offset_t StringToBytes (char *);
#if USE_UNDOC_OPT
void CorruptFile (char *, IOR_param_t *, int, int);
#endif /* USE_UNDOC_OPTS */
void SeedRandGen (MPI_Comm);
#endif /* not _IOR_H */
#endif /* !_IOR_H */

View File

@ -12,6 +12,12 @@
# include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <mpi.h>
#ifdef _WIN32
# define _CRT_SECURE_NO_WARNINGS
# define _CRT_RAND_S
@ -20,10 +26,8 @@
# pragma warning(4 : 4244) /* 'function' : conversion from 'IOR_offset_t' to 'int' */
# include <Windows.h>
# include <stdlib.h>
# include <io.h>
# include <direct.h>
# include <string.h>
# include "win/getopt.h"
# define MAXPATHLEN 1024
@ -46,9 +50,6 @@
# include <unistd.h>
# include <limits.h>
#endif
#include <mpi.h>
#include <stdio.h>
#include <errno.h>
/************************** D E C L A R A T I O N S ***************************/

View File

@ -9,19 +9,25 @@
*
\******************************************************************************/
#include "ior.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include "ior.h"
#include "aiori.h"
#include "parse_options.h"
IOR_param_t initialTestParams;
/*
* Check and correct all settings of each test in queue for correctness.
*/
void CheckRunSettings(IOR_queue_t * tests)
static void CheckRunSettings(IOR_queue_t * tests)
{
while (tests != NULL) {
/* If no write/read/check action requested, set both write and read */

17
src/parse_options.h Normal file
View File

@ -0,0 +1,17 @@
/******************************************************************************\
* *
* Copyright (c) 2003, The Regents of the University of California *
* See the file COPYRIGHT for a complete copyright notice and license. *
* *
\******************************************************************************/
#ifndef _PARSE_OPTIONS_H
#define _PARSE_OPTIONS_H
#include "ior.h"
extern IOR_param_t initialTestParams;
IOR_queue_t *ParseCommandLine(int argc, char **argv);
#endif /* !_PARSE_OPTIONS_H */

View File

@ -9,13 +9,15 @@
*
\******************************************************************************/
#include "aiori.h" /* abstract IOR interface */
#include "ior.h" /* IOR functions */
#include <errno.h> /* sys_errlist */
#include <fcntl.h> /* open() */
#include <math.h> /* pow() */
#include <stdio.h> /* only for fprintf() */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <math.h> /* pow() */
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
@ -30,6 +32,10 @@
#include <sys/time.h> /* gettimeofday() */
#endif
#include "utilities.h"
#include "aiori.h"
#include "ior.h"
/************************** D E C L A R A T I O N S ***************************/
extern int errno;
@ -146,6 +152,32 @@ void OutputToRoot(int numTasks, MPI_Comm comm, char *stringToDisplay)
free(stringArray);
}
/*
* Extract key/value pair from hint string.
*/
void ExtractHint(char *settingVal, char *valueVal, char *hintString)
{
char *settingPtr, *valuePtr, *tmpPtr1, *tmpPtr2;
settingPtr = (char *)strtok(hintString, "=");
valuePtr = (char *)strtok(NULL, " \t\r\n");
tmpPtr1 = settingPtr;
tmpPtr2 = (char *)strstr(settingPtr, "IOR_HINT__MPI__");
if (tmpPtr1 == tmpPtr2) {
settingPtr += strlen("IOR_HINT__MPI__");
} else {
tmpPtr2 = (char *)strstr(settingPtr, "IOR_HINT__GPFS__");
if (tmpPtr1 == tmpPtr2) {
settingPtr += strlen("IOR_HINT__GPFS__");
fprintf(stdout,
"WARNING: Unable to set GPFS hints (not implemented.)\n");
}
}
strcpy(settingVal, settingPtr);
strcpy(valueVal, valuePtr);
}
/*
* Set hints for MPIIO, HDF5, or NCMPI.
*/
@ -207,32 +239,6 @@ void SetHints(MPI_Info * mpiHints, char *hintsFileName)
}
}
/*
* Extract key/value pair from hint string.
*/
void ExtractHint(char *settingVal, char *valueVal, char *hintString)
{
char *settingPtr, *valuePtr, *tmpPtr1, *tmpPtr2;
settingPtr = (char *)strtok(hintString, "=");
valuePtr = (char *)strtok(NULL, " \t\r\n");
tmpPtr1 = settingPtr;
tmpPtr2 = (char *)strstr(settingPtr, "IOR_HINT__MPI__");
if (tmpPtr1 == tmpPtr2) {
settingPtr += strlen("IOR_HINT__MPI__");
} else {
tmpPtr2 = (char *)strstr(settingPtr, "IOR_HINT__GPFS__");
if (tmpPtr1 == tmpPtr2) {
settingPtr += strlen("IOR_HINT__GPFS__");
fprintf(stdout,
"WARNING: Unable to set GPFS hints (not implemented.)\n");
}
}
strcpy(settingVal, settingPtr);
strcpy(valueVal, valuePtr);
}
/*
* Show all hints (key/value pairs) in an MPI_Info object.
*/
@ -333,7 +339,7 @@ void ShowFileSystemSize(char *fileSystem)
(double)totalFileSystemSize / (double)(1<<30);
fileSystemUnitStr = "GiB";
if (totalFileSystemSizeHR > 1024) {
totalFileSystemSizeHR = (double)totalFileSystemSize / (double)(1<<40);
totalFileSystemSizeHR = (double)totalFileSystemSize / (double)((long long)1<<40);
fileSystemUnitStr = "TiB";
}

32
src/utilities.h Normal file
View File

@ -0,0 +1,32 @@
/******************************************************************************\
* *
* Copyright (c) 2003, The Regents of the University of California *
* See the file COPYRIGHT for a complete copyright notice and license. *
* *
\******************************************************************************/
#ifndef _UTILITIES_H
#define _UTILITIES_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <mpi.h>
#include "ior.h"
char *CurrentTimeString(void);
void OutputToRoot(int, MPI_Comm, char *);
int Regex(char *, char *);
void ShowFileSystemSize(char *);
void DumpBuffer(void *, size_t);
IOR_offset_t StringToBytes(char *);
void SeedRandGen(MPI_Comm);
#if USE_UNDOC_OPT
void CorruptFile(char *, IOR_param_t *, int, int);
#endif
void SetHints (MPI_Info *, char *);
void ShowHints (MPI_Info *);
#endif /* !_UTILITIES_H */