Trivial cleanup: Extracted debug-related stuff into new header.
parent
7edd559c01
commit
145c71f7c3
|
@ -0,0 +1,117 @@
|
||||||
|
#ifndef _AIORI_UTIL_H
|
||||||
|
#define _AIORI_UTIL_H
|
||||||
|
|
||||||
|
/* This file contains only debug relevant helpers */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
extern FILE * out_logfile;
|
||||||
|
extern int verbose; /* verbose output */
|
||||||
|
|
||||||
|
#define FAIL(...) FailMessage(rank, ERROR_LOCATION, __VA_ARGS__)
|
||||||
|
void FailMessage(int rank, const char *location, char *format, ...);
|
||||||
|
|
||||||
|
/******************************** M A C R O S *********************************/
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/*
|
||||||
|
* WARN_RESET will display a custom error message and set value to default
|
||||||
|
*/
|
||||||
|
#define WARN_RESET(MSG, TO_STRUCT_PTR, FROM_STRUCT_PTR, MEMBER) do { \
|
||||||
|
(TO_STRUCT_PTR)->MEMBER = (FROM_STRUCT_PTR)->MEMBER; \
|
||||||
|
if (rank == 0) { \
|
||||||
|
fprintf(out_logfile, "WARNING: %s. Using value of %d.\n", \
|
||||||
|
MSG, (TO_STRUCT_PTR)->MEMBER); \
|
||||||
|
} \
|
||||||
|
fflush(out_logfile); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
extern int aiori_warning_as_errors;
|
||||||
|
|
||||||
|
#define WARN(MSG) do { \
|
||||||
|
if(aiori_warning_as_errors){ ERR(MSG); } \
|
||||||
|
if (verbose > VERBOSE_2) { \
|
||||||
|
fprintf(out_logfile, "WARNING: %s, (%s:%d).\n", \
|
||||||
|
MSG, __FILE__, __LINE__); \
|
||||||
|
} else { \
|
||||||
|
fprintf(out_logfile, "WARNING: %s.\n", MSG); \
|
||||||
|
} \
|
||||||
|
fflush(out_logfile); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
/* warning with format string and errno printed */
|
||||||
|
#define EWARNF(FORMAT, ...) do { \
|
||||||
|
if(aiori_warning_as_errors){ ERRF(FORMAT, __VA_ARGS__); } \
|
||||||
|
if (verbose > VERBOSE_2) { \
|
||||||
|
fprintf(out_logfile, "WARNING: " FORMAT ", (%s:%d).\n", \
|
||||||
|
__VA_ARGS__, __FILE__, __LINE__); \
|
||||||
|
} else { \
|
||||||
|
fprintf(out_logfile, "WARNING: " FORMAT "\n", \
|
||||||
|
__VA_ARGS__); \
|
||||||
|
} \
|
||||||
|
fflush(out_logfile); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
/* warning with errno printed */
|
||||||
|
#define EWARN(MSG) do { \
|
||||||
|
EWARNF("%s", MSG); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
/* display error message with format string and terminate execution */
|
||||||
|
#define ERRF(FORMAT, ...) do { \
|
||||||
|
fprintf(out_logfile, "ERROR: " FORMAT ", (%s:%d)\n", \
|
||||||
|
__VA_ARGS__, __FILE__, __LINE__); \
|
||||||
|
fflush(out_logfile); \
|
||||||
|
MPI_Abort(MPI_COMM_WORLD, -1); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
/* display error message and terminate execution */
|
||||||
|
#define ERR_ERRNO(MSG) do { \
|
||||||
|
ERRF("%s", MSG); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
/* display a simple error message (i.e. errno is not set) and terminate execution */
|
||||||
|
#define ERR(MSG) do { \
|
||||||
|
fprintf(out_logfile, "ERROR: %s, (%s:%d)\n", \
|
||||||
|
MSG, __FILE__, __LINE__); \
|
||||||
|
fflush(out_logfile); \
|
||||||
|
MPI_Abort(MPI_COMM_WORLD, -1); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/*
|
||||||
|
* MPI_CHECKF will display a custom format string as well as an error string
|
||||||
|
* from the MPI_STATUS and then exit the program
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define MPI_CHECKF(MPI_STATUS, FORMAT, ...) do { \
|
||||||
|
char resultString[MPI_MAX_ERROR_STRING]; \
|
||||||
|
int resultLength; \
|
||||||
|
\
|
||||||
|
if (MPI_STATUS != MPI_SUCCESS) { \
|
||||||
|
MPI_Error_string(MPI_STATUS, resultString, &resultLength); \
|
||||||
|
fprintf(out_logfile, "ERROR: " FORMAT ", MPI %s, (%s:%d)\n", \
|
||||||
|
__VA_ARGS__, resultString, __FILE__, __LINE__); \
|
||||||
|
fflush(out_logfile); \
|
||||||
|
MPI_Abort(MPI_COMM_WORLD, -1); \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/*
|
||||||
|
* MPI_CHECK will display a custom error message as well as an error string
|
||||||
|
* from the MPI_STATUS and then exit the program
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define MPI_CHECK(MPI_STATUS, MSG) do { \
|
||||||
|
MPI_CHECKF(MPI_STATUS, "%s", MSG); \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
#endif
|
|
@ -25,6 +25,7 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "iordef.h" /* IOR Definitions */
|
#include "iordef.h" /* IOR Definitions */
|
||||||
|
#include "aiori-debug.h"
|
||||||
#include "option.h"
|
#include "option.h"
|
||||||
|
|
||||||
/*************************** D E F I N I T I O N S ****************************/
|
/*************************** D E F I N I T I O N S ****************************/
|
||||||
|
|
115
src/iordef.h
115
src/iordef.h
|
@ -18,8 +18,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <mpi.h>
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# define _CRT_SECURE_NO_WARNINGS
|
# define _CRT_SECURE_NO_WARNINGS
|
||||||
|
@ -52,13 +50,6 @@
|
||||||
# include <limits.h>
|
# include <limits.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************** D E C L A R A T I O N S ***************************/
|
|
||||||
|
|
||||||
extern int numTasks; /* MPI variables */
|
|
||||||
extern int rank;
|
|
||||||
extern int rankOffset;
|
|
||||||
extern int verbose; /* verbose output */
|
|
||||||
|
|
||||||
/*************************** D E F I N I T I O N S ****************************/
|
/*************************** D E F I N I T I O N S ****************************/
|
||||||
|
|
||||||
enum OutputFormat_t{
|
enum OutputFormat_t{
|
||||||
|
@ -120,112 +111,6 @@ typedef long long int IOR_size_t;
|
||||||
|
|
||||||
#define IOR_format "%016llx"
|
#define IOR_format "%016llx"
|
||||||
|
|
||||||
extern FILE * out_logfile;
|
|
||||||
|
|
||||||
/******************************** M A C R O S *********************************/
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/*
|
|
||||||
* WARN_RESET will display a custom error message and set value to default
|
|
||||||
*/
|
|
||||||
#define WARN_RESET(MSG, TO_STRUCT_PTR, FROM_STRUCT_PTR, MEMBER) do { \
|
|
||||||
(TO_STRUCT_PTR)->MEMBER = (FROM_STRUCT_PTR)->MEMBER; \
|
|
||||||
if (rank == 0) { \
|
|
||||||
fprintf(out_logfile, "ior WARNING: %s. Using value of %d.\n", \
|
|
||||||
MSG, (TO_STRUCT_PTR)->MEMBER); \
|
|
||||||
} \
|
|
||||||
fflush(out_logfile); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
extern int aiori_warning_as_errors;
|
|
||||||
|
|
||||||
#define WARN(MSG) do { \
|
|
||||||
if(aiori_warning_as_errors){ ERR(MSG); } \
|
|
||||||
if (verbose > VERBOSE_2) { \
|
|
||||||
fprintf(out_logfile, "ior WARNING: %s, (%s:%d).\n", \
|
|
||||||
MSG, __FILE__, __LINE__); \
|
|
||||||
} else { \
|
|
||||||
fprintf(out_logfile, "ior WARNING: %s.\n", MSG); \
|
|
||||||
} \
|
|
||||||
fflush(out_logfile); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
|
|
||||||
/* warning with format string and errno printed */
|
|
||||||
#define EWARNF(FORMAT, ...) do { \
|
|
||||||
if(aiori_warning_as_errors){ ERRF(FORMAT, __VA_ARGS__); } \
|
|
||||||
if (verbose > VERBOSE_2) { \
|
|
||||||
fprintf(out_logfile, "ior WARNING: " FORMAT ", (%s:%d).\n", \
|
|
||||||
__VA_ARGS__, __FILE__, __LINE__); \
|
|
||||||
} else { \
|
|
||||||
fprintf(out_logfile, "ior WARNING: " FORMAT "\n", \
|
|
||||||
__VA_ARGS__); \
|
|
||||||
} \
|
|
||||||
fflush(out_logfile); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
|
|
||||||
/* warning with errno printed */
|
|
||||||
#define EWARN(MSG) do { \
|
|
||||||
EWARNF("%s", MSG); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
|
|
||||||
/* display error message with format string and terminate execution */
|
|
||||||
#define ERRF(FORMAT, ...) do { \
|
|
||||||
fprintf(out_logfile, "ior ERROR: " FORMAT ", (%s:%d)\n", \
|
|
||||||
__VA_ARGS__, __FILE__, __LINE__); \
|
|
||||||
fflush(out_logfile); \
|
|
||||||
MPI_Abort(MPI_COMM_WORLD, -1); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
|
|
||||||
/* display error message and terminate execution */
|
|
||||||
#define ERR_ERRNO(MSG) do { \
|
|
||||||
ERRF("%s", MSG); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
|
|
||||||
/* display a simple error message (i.e. errno is not set) and terminate execution */
|
|
||||||
#define ERR(MSG) do { \
|
|
||||||
fprintf(out_logfile, "ior ERROR: %s, (%s:%d)\n", \
|
|
||||||
MSG, __FILE__, __LINE__); \
|
|
||||||
fflush(out_logfile); \
|
|
||||||
MPI_Abort(MPI_COMM_WORLD, -1); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/*
|
|
||||||
* MPI_CHECKF will display a custom format string as well as an error string
|
|
||||||
* from the MPI_STATUS and then exit the program
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define MPI_CHECKF(MPI_STATUS, FORMAT, ...) do { \
|
|
||||||
char resultString[MPI_MAX_ERROR_STRING]; \
|
|
||||||
int resultLength; \
|
|
||||||
\
|
|
||||||
if (MPI_STATUS != MPI_SUCCESS) { \
|
|
||||||
MPI_Error_string(MPI_STATUS, resultString, &resultLength); \
|
|
||||||
fprintf(out_logfile, "ior ERROR: " FORMAT ", MPI %s, (%s:%d)\n", \
|
|
||||||
__VA_ARGS__, resultString, __FILE__, __LINE__); \
|
|
||||||
fflush(out_logfile); \
|
|
||||||
MPI_Abort(MPI_COMM_WORLD, -1); \
|
|
||||||
} \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/*
|
|
||||||
* MPI_CHECK will display a custom error message as well as an error string
|
|
||||||
* from the MPI_STATUS and then exit the program
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define MPI_CHECK(MPI_STATUS, MSG) do { \
|
|
||||||
MPI_CHECKF(MPI_STATUS, "%s", MSG); \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/*
|
/*
|
||||||
* System info for Windows.
|
* System info for Windows.
|
||||||
|
|
|
@ -81,8 +81,8 @@ void FailMessage(int rank, const char *location, char *format, ...) {
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
vsnprintf(msg, 4096, format, args);
|
vsnprintf(msg, 4096, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
fprintf(out_logfile, "%s: Process %d: FAILED in %s, %s: %s\n",
|
fprintf(out_logfile, "%s: Process %d: FAILED in %s, %s\n",
|
||||||
PrintTimestamp(), rank, location, msg, strerror(errno));
|
PrintTimestamp(), rank, location, msg);
|
||||||
fflush(out_logfile);
|
fflush(out_logfile);
|
||||||
MPI_Abort(testComm, 1);
|
MPI_Abort(testComm, 1);
|
||||||
}
|
}
|
||||||
|
@ -889,4 +889,3 @@ unsigned long GetProcessorAndCore(int *chip, int *core){
|
||||||
return ((unsigned long)a) | (((unsigned long)d) << 32);;
|
return ((unsigned long)a) | (((unsigned long)d) << 32);;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ extern int rankOffset;
|
||||||
extern int verbose;
|
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_resultfile;
|
extern FILE * out_resultfile;
|
||||||
extern enum OutputFormat_t outputFormat; /* format of the output */
|
extern enum OutputFormat_t outputFormat; /* format of the output */
|
||||||
|
|
||||||
|
@ -39,8 +38,6 @@ extern enum OutputFormat_t outputFormat; /* format of the output */
|
||||||
#define ERROR_LOCATION __LINE__
|
#define ERROR_LOCATION __LINE__
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define FAIL(...) FailMessage(rank, ERROR_LOCATION, __VA_ARGS__)
|
|
||||||
void FailMessage(int rank, const char *location, char *format, ...);
|
|
||||||
|
|
||||||
void* safeMalloc(uint64_t size);
|
void* safeMalloc(uint64_t size);
|
||||||
void set_o_direct_flag(int *fd);
|
void set_o_direct_flag(int *fd);
|
||||||
|
|
Loading…
Reference in New Issue