Support IO redirect from main()

master
Julian M. Kunkel 2018-07-08 13:07:32 +01:00
parent 0052bff3e9
commit 0f7a1f14b9
7 changed files with 45 additions and 21 deletions

View File

@ -280,7 +280,8 @@ GENERAL:
* summaryAlways - Always print the long summary for each test. * summaryAlways - Always print the long summary for each test.
Useful for long runs that may be interrupted, preventing Useful for long runs that may be interrupted, preventing
the final long summary for ALL tests to be printed. the final long summary for ALL tests to be printed.
* summaryFile=File - Output the summary to the file instead on stdout/stderr.
* summaryFormat=FMT - Choose the output format -- default, JSON, CSV
POSIX-ONLY: POSIX-ONLY:
=========== ===========

View File

@ -90,6 +90,7 @@ IOR_test_t * ior_run(int argc, char **argv, MPI_Comm world_com, FILE * world_out
for (tptr = tests_head; tptr != NULL; tptr = tptr->next) { for (tptr = tests_head; tptr != NULL; tptr = tptr->next) {
totalErrorCount = 0; totalErrorCount = 0;
verbose = tptr->params.verbose; verbose = tptr->params.verbose;
tptr->params.testComm = world_com;
if (rank == 0 && verbose >= VERBOSE_0) { if (rank == 0 && verbose >= VERBOSE_0) {
ShowTestInfo(&tptr->params); ShowTestInfo(&tptr->params);
} }
@ -125,6 +126,7 @@ int ior_main(int argc, char **argv)
int i; int i;
IOR_test_t *tests_head; IOR_test_t *tests_head;
IOR_test_t *tptr; IOR_test_t *tptr;
out_logfile = stdout; out_logfile = stdout;
/* /*
@ -153,6 +155,7 @@ int ior_main(int argc, char **argv)
MPI_CHECK(MPI_Comm_size(mpi_comm_world, &numTasksWorld), MPI_CHECK(MPI_Comm_size(mpi_comm_world, &numTasksWorld),
"cannot get number of tasks"); "cannot get number of tasks");
MPI_CHECK(MPI_Comm_rank(mpi_comm_world, &rank), "cannot get rank"); MPI_CHECK(MPI_Comm_rank(mpi_comm_world, &rank), "cannot get rank");
PrintEarlyHeader(); PrintEarlyHeader();
/* set error-handling */ /* set error-handling */
@ -230,6 +233,8 @@ int ior_main(int argc, char **argv)
aws_cleanup(); aws_cleanup();
#endif #endif
fflush(out_logfile);
return totalErrorCount; return totalErrorCount;
} }
@ -1668,7 +1673,6 @@ static void PrintLongSummaryOneOperation(IOR_test_t *test, double *times, char *
struct results *bw; struct results *bw;
struct results *ops; struct results *ops;
int reps; int reps;
if (rank != 0 || verbose < VERBOSE_0) if (rank != 0 || verbose < VERBOSE_0)
return; return;
@ -1682,14 +1686,12 @@ static void PrintLongSummaryOneOperation(IOR_test_t *test, double *times, char *
fprintf(out_logfile, "%10.2f ", bw->max / MEBIBYTE); fprintf(out_logfile, "%10.2f ", bw->max / MEBIBYTE);
fprintf(out_logfile, "%10.2f ", bw->min / MEBIBYTE); fprintf(out_logfile, "%10.2f ", bw->min / MEBIBYTE);
fprintf(out_logfile, "%10.2f ", bw->mean / MEBIBYTE); fprintf(out_logfile, "%10.2f ", bw->mean / MEBIBYTE);
fprintf(out_logfile, "%10.2f ", bw->sd / MEBIBYTE); fprintf(out_logfile, "%10.2f ", bw->sd / MEBIBYTE);
fprintf(out_logfile, "%10.2f ", ops->max); fprintf(out_logfile, "%10.2f ", ops->max);
fprintf(out_logfile, "%10.2f ", ops->min); fprintf(out_logfile, "%10.2f ", ops->min);
fprintf(out_logfile, "%10.2f ", ops->mean); fprintf(out_logfile, "%10.2f ", ops->mean);
fprintf(out_logfile, "%10.2f ", ops->sd); fprintf(out_logfile, "%10.2f ", ops->sd);
fprintf(out_logfile, "%10.5f ", fprintf(out_logfile, "%10.5f ", mean_of_array_of_doubles(times, reps));
mean_of_array_of_doubles(times, reps));
fprintf(out_logfile, "%5d ", params->id); fprintf(out_logfile, "%5d ", params->id);
fprintf(out_logfile, "%6d ", params->numTasks); fprintf(out_logfile, "%6d ", params->numTasks);
fprintf(out_logfile, "%3d ", params->tasksPerNode); fprintf(out_logfile, "%3d ", params->tasksPerNode);
@ -1742,7 +1744,6 @@ static void PrintLongSummaryHeader()
static void PrintLongSummaryAllTests(IOR_test_t *tests_head) static void PrintLongSummaryAllTests(IOR_test_t *tests_head)
{ {
IOR_test_t *tptr; IOR_test_t *tptr;
if (rank != 0 || verbose < VERBOSE_0) if (rank != 0 || verbose < VERBOSE_0)
return; return;

View File

@ -82,7 +82,6 @@ typedef struct IO_BUFFERS
typedef struct typedef struct
{ {
FILE * out_logfile;
char debug[MAX_STR]; /* debug info string */ char debug[MAX_STR]; /* debug info string */
unsigned int mode; /* file permissions */ unsigned int mode; /* file permissions */
unsigned int openFlags; /* open flags (see also <open>) */ unsigned int openFlags; /* open flags (see also <open>) */

View File

@ -61,6 +61,12 @@ extern int verbose; /* verbose output */
/*************************** D E F I N I T I O N S ****************************/ /*************************** D E F I N I T I O N S ****************************/
enum OutputFormat_t{
OUTPUT_DEFAULT,
OUTPUT_CSV,
OUTPUT_JSON
};
#ifndef FALSE #ifndef FALSE
# define FALSE 0 # define FALSE 0
#endif /* not FALSE */ #endif /* not FALSE */

View File

@ -170,6 +170,21 @@ void DecodeDirective(char *line, IOR_param_t *params)
} }
if (strcasecmp(option, "api") == 0) { if (strcasecmp(option, "api") == 0) {
strcpy(params->api, value); strcpy(params->api, value);
} else if (strcasecmp(option, "summaryFile") == 0) {
out_logfile = fopen(value, "w");
if (out_logfile == NULL){
FAIL("Cannot open output file for writes!");
}
} else if (strcasecmp(option, "summaryFormat") == 0) {
if(strcasecmp(value, "default")){
outputFormat = OUTPUT_DEFAULT;
}else if(strcasecmp(value, "JSON")){
outputFormat = OUTPUT_JSON;
}else if(strcasecmp(value, "CSV")){
outputFormat = OUTPUT_CSV;
}else{
FAIL("Unknown summaryFormat");
}
} else if (strcasecmp(option, "refnum") == 0) { } else if (strcasecmp(option, "refnum") == 0) {
params->referenceNumber = atoi(value); params->referenceNumber = atoi(value);
} else if (strcasecmp(option, "debug") == 0) { } else if (strcasecmp(option, "debug") == 0) {

View File

@ -57,6 +57,7 @@ int verbose = VERBOSE_0; /* verbose output */
MPI_Comm testComm; MPI_Comm testComm;
MPI_Comm mpi_comm_world; MPI_Comm mpi_comm_world;
FILE * out_logfile; FILE * out_logfile;
enum OutputFormat_t outputFormat;
/***************************** F U N C T I O N S ******************************/ /***************************** F U N C T I O N S ******************************/

View File

@ -26,6 +26,7 @@ extern int verbose;
extern MPI_Comm testComm; extern MPI_Comm testComm;
extern MPI_Comm mpi_comm_world; extern MPI_Comm mpi_comm_world;
extern FILE * out_logfile; extern FILE * out_logfile;
extern enum OutputFormat_t outputFormat; /* format of the output */
/* /*
* Try using the system's PATH_MAX, which is what realpath and such use. * Try using the system's PATH_MAX, which is what realpath and such use.