-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patherror_output.c
More file actions
92 lines (83 loc) · 1.81 KB
/
Copy patherror_output.c
File metadata and controls
92 lines (83 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* Inter-Communicator MPI Benchmarking
* Copyright (c) 2021 Stefan Christians
* SPDX-License-Identifier: MIT
*/
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include "utilities.h"
#include "error_output.h"
static const int MAX_MSG_LEN = 256;
static const int OUTPUT_ROOT_PROC = 0;
/*
* prints message to stdout
*/
void icmb_message(const char* message, ...)
{
if (icmb_has_initiator_rank(OUTPUT_ROOT_PROC))
{
va_list args;
va_start(args, message);
char buffer[MAX_MSG_LEN];
vsnprintf(buffer, MAX_MSG_LEN, message, args);
va_end(args);
fprintf(stdout, "%s\n", buffer);
}
}
/*
* prints warning to stderr
*/
void icmb_warning(const char* message, ...)
{
if (icmb_has_initiator_rank(OUTPUT_ROOT_PROC))
{
va_list args;
va_start(args, message);
char buffer[MAX_MSG_LEN];
vsnprintf(buffer, MAX_MSG_LEN, message, args);
va_end(args);
fprintf(stderr, "Warning: %s\n", buffer);
}
}
/*
* prints error to stderr
*/
void icmb_error(const char* message, ...)
{
if (icmb_has_initiator_rank(OUTPUT_ROOT_PROC))
{
va_list args;
va_start(args, message);
char buffer[MAX_MSG_LEN];
vsnprintf(buffer, MAX_MSG_LEN, message, args);
va_end(args);
fprintf(stderr, "ERROR: %s\n", buffer);
}
}
/*
* exits benchmark
*/
void icmb_exit(int exit_code)
{
// finalize automatically frees benchmark and global
// communicators by callback
MPI_Finalize();
exit(exit_code);
}
/*
* aborts benchmark
*
* aborts all processes connected by the global communicator
*/
void icmb_abort(int exit_code)
{
MPI_Abort(icmb_global_communicator(), exit_code);
}
/*
* prints error message and exits
*/
void icmb_error_and_exit(const char* message, int exit_code)
{
icmb_error(message);
icmb_exit(exit_code);
}