Skip to content
Snippets Groups Projects
Commit 912f28d4 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Better name for the time-stamp function

parent 1a2e49aa
No related branches found
No related tags found
2 merge requests!136Master,!107Code timing and verbosity
...@@ -233,7 +233,7 @@ const char *clocks_getunit() { return clocks_units[clocks_units_index]; } ...@@ -233,7 +233,7 @@ const char *clocks_getunit() { return clocks_units[clocks_units_index]; }
* *
* @result the time since the start of the execution * @result the time since the start of the execution
*/ */
const char *clocks_get_timeofday() { const char *clocks_get_timesincestart() {
static char buffer[40]; static char buffer[40];
......
...@@ -39,6 +39,6 @@ void clocks_set_cpufreq(unsigned long long freq); ...@@ -39,6 +39,6 @@ void clocks_set_cpufreq(unsigned long long freq);
unsigned long long clocks_get_cpufreq(); unsigned long long clocks_get_cpufreq();
double clocks_from_ticks(ticks tics); double clocks_from_ticks(ticks tics);
double clocks_diff_ticks(ticks tic, ticks toc); double clocks_diff_ticks(ticks tic, ticks toc);
const char *clocks_get_timeofday(); const char *clocks_get_timesincestart();
#endif /* SWIFT_CLOCKS_H */ #endif /* SWIFT_CLOCKS_H */
...@@ -1171,10 +1171,10 @@ void engine_print(struct engine *e) { ...@@ -1171,10 +1171,10 @@ void engine_print(struct engine *e) {
counts[task_type_count] += 1; counts[task_type_count] += 1;
#ifdef WITH_MPI #ifdef WITH_MPI
printf("[%04i] %s engine_print: task counts are [ %s=%i", e->nodeID, printf("[%04i] %s engine_print: task counts are [ %s=%i", e->nodeID,
clocks_get_timeofday(), taskID_names[0], counts[0]); clocks_get_timesincestart(), taskID_names[0], counts[0]);
#else #else
printf("%s engine_print: task counts are [ %s=%i", clocks_get_timeofday(), printf("%s engine_print: task counts are [ %s=%i",
taskID_names[0], counts[0]); clocks_get_timesincestart(), taskID_names[0], counts[0]);
#endif #endif
for (k = 1; k < task_type_count; k++) for (k = 1; k < task_type_count; k++)
printf(" %s=%i", taskID_names[k], counts[k]); printf(" %s=%i", taskID_names[k], counts[k]);
...@@ -1929,9 +1929,9 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads, ...@@ -1929,9 +1929,9 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
if (nodeID == 0) { if (nodeID == 0) {
#ifdef WITH_MPI #ifdef WITH_MPI
printf("[%04i] %s engine_init: cpu map is [ ", nodeID, printf("[%04i] %s engine_init: cpu map is [ ", nodeID,
clocks_get_timeofday()); clocks_get_timesincestart());
#else #else
printf("%s engine_init: cpu map is [ ", clocks_get_timeofday()); printf("%s engine_init: cpu map is [ ", clocks_get_timesincestart());
#endif #endif
for (int i = 0; i < nr_cores; i++) printf("%i ", cpuid[i]); for (int i = 0; i < nr_cores; i++) printf("%i ", cpuid[i]);
printf("].\n"); printf("].\n");
...@@ -2108,14 +2108,15 @@ void engine_print_policy(struct engine *e) { ...@@ -2108,14 +2108,15 @@ void engine_print_policy(struct engine *e) {
#ifdef WITH_MPI #ifdef WITH_MPI
if (e->nodeID == 0) { if (e->nodeID == 0) {
printf("[0000] %s engine_policy: engine policies are [ ", printf("[0000] %s engine_policy: engine policies are [ ",
clocks_get_timeofday()); clocks_get_timesincestart());
for (int k = 1; k < 32; k++) for (int k = 1; k < 32; k++)
if (e->policy & (1 << k)) printf(" %s ", engine_policy_names[k + 1]); if (e->policy & (1 << k)) printf(" %s ", engine_policy_names[k + 1]);
printf(" ]\n"); printf(" ]\n");
fflush(stdout); fflush(stdout);
} }
#else #else
printf("%s engine_policy: engine policies are [ ", clocks_get_timeofday()); printf("%s engine_policy: engine policies are [ ",
clocks_get_timesincestart());
for (int k = 1; k < 32; k++) for (int k = 1; k < 32; k++)
if (e->policy & (1 << k)) printf(" %s ", engine_policy_names[k + 1]); if (e->policy & (1 << k)) printf(" %s ", engine_policy_names[k + 1]);
printf(" ]\n"); printf(" ]\n");
......
...@@ -37,19 +37,19 @@ ...@@ -37,19 +37,19 @@
*/ */
#ifdef WITH_MPI #ifdef WITH_MPI
extern int engine_rank; extern int engine_rank;
#define error(s, ...) \ #define error(s, ...) \
{ \ { \
fprintf(stderr, "[%04i] %s %s:%s():%i: " s "\n", engine_rank, \ fprintf(stderr, "[%04i] %s %s:%s():%i: " s "\n", engine_rank, \
clocks_get_timeofday(), __FILE__, __FUNCTION__, __LINE__, \ clocks_get_timesincestart(), __FILE__, __FUNCTION__, __LINE__, \
##__VA_ARGS__); \ ##__VA_ARGS__); \
MPI_Abort(MPI_COMM_WORLD, -1); \ MPI_Abort(MPI_COMM_WORLD, -1); \
} }
#else #else
#define error(s, ...) \ #define error(s, ...) \
{ \ { \
fprintf(stderr, "%s %s:%s():%i: " s "\n", clocks_get_timeofday(), \ fprintf(stderr, "%s %s:%s():%i: " s "\n", clocks_get_timesincestart(), \
__FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
abort(); \ abort(); \
} }
#endif #endif
...@@ -59,27 +59,27 @@ extern int engine_rank; ...@@ -59,27 +59,27 @@ extern int engine_rank;
* followed by the MPI error string and aborts. * followed by the MPI error string and aborts.
* *
*/ */
#define mpi_error(res, s, ...) \ #define mpi_error(res, s, ...) \
{ \ { \
fprintf(stderr, "[%04i] %s %s:%s():%i: " s "\n", engine_rank, \ fprintf(stderr, "[%04i] %s %s:%s():%i: " s "\n", engine_rank, \
clocks_get_timeofday(), __FILE__, __FUNCTION__, __LINE__, \ clocks_get_timesincestart(), __FILE__, __FUNCTION__, __LINE__, \
##__VA_ARGS__); \ ##__VA_ARGS__); \
int len = 1024; \ int len = 1024; \
char buf[len]; \ char buf[len]; \
MPI_Error_string(res, buf, &len); \ MPI_Error_string(res, buf, &len); \
fprintf(stderr, "%s\n\n", buf); \ fprintf(stderr, "%s\n\n", buf); \
MPI_Abort(MPI_COMM_WORLD, -1); \ MPI_Abort(MPI_COMM_WORLD, -1); \
} }
#define mpi_error_string(res, s, ...) \ #define mpi_error_string(res, s, ...) \
{ \ { \
fprintf(stderr, "[%04i] %s %s:%s():%i: " s "\n", engine_rank, \ fprintf(stderr, "[%04i] %s %s:%s():%i: " s "\n", engine_rank, \
clocks_get_timeofday(), __FILE__, __FUNCTION__, __LINE__, \ clocks_get_timesincestart(), __FILE__, __FUNCTION__, __LINE__, \
##__VA_ARGS__); \ ##__VA_ARGS__); \
int len = 1024; \ int len = 1024; \
char buf[len]; \ char buf[len]; \
MPI_Error_string(res, buf, &len); \ MPI_Error_string(res, buf, &len); \
fprintf(stderr, "%s\n\n", buf); \ fprintf(stderr, "%s\n\n", buf); \
} }
#endif #endif
...@@ -89,12 +89,13 @@ extern int engine_rank; ...@@ -89,12 +89,13 @@ extern int engine_rank;
*/ */
#ifdef WITH_MPI #ifdef WITH_MPI
extern int engine_rank; extern int engine_rank;
#define message(s, ...) \ #define message(s, ...) \
printf("[%04i] %s %s: " s "\n", engine_rank, clocks_get_timeofday(), \ printf("[%04i] %s %s: " s "\n", engine_rank, clocks_get_timesincestart(), \
__FUNCTION__, ##__VA_ARGS__) __FUNCTION__, ##__VA_ARGS__)
#else #else
#define message(s, ...) \ #define message(s, ...) \
printf("%s %s: " s "\n", clocks_get_timeofday(), __FUNCTION__, ##__VA_ARGS__) printf("%s %s: " s "\n", clocks_get_timesincestart(), __FUNCTION__, \
##__VA_ARGS__)
#endif #endif
/** /**
...@@ -107,21 +108,21 @@ extern int engine_rank; ...@@ -107,21 +108,21 @@ extern int engine_rank;
{ \ { \
if (!(expr)) { \ if (!(expr)) { \
fprintf(stderr, "[%04i] %s %s:%s():%i: FAILED ASSERTION: " #expr " \n", \ fprintf(stderr, "[%04i] %s %s:%s():%i: FAILED ASSERTION: " #expr " \n", \
engine_rank, clocks_get_timeofday(), __FILE__, __FUNCTION__, \ engine_rank, clocks_get_timesincestart(), __FILE__, \
__LINE__); \ __FUNCTION__, __LINE__); \
fflush(stderr); \ fflush(stderr); \
MPI_Abort(MPI_COMM_WORLD, -1); \ MPI_Abort(MPI_COMM_WORLD, -1); \
} \ } \
} }
#else #else
#define assert(expr) \ #define assert(expr) \
{ \ { \
if (!(expr)) { \ if (!(expr)) { \
fprintf(stderr, "%s %s:%s():%i: FAILED ASSERTION: " #expr " \n", \ fprintf(stderr, "%s %s:%s():%i: FAILED ASSERTION: " #expr " \n", \
clocks_get_timeofday(), __FILE__, __FUNCTION__, __LINE__); \ clocks_get_timesincestart(), __FILE__, __FUNCTION__, __LINE__); \
fflush(stderr); \ fflush(stderr); \
abort(); \ abort(); \
} \ } \
} }
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment