-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utils.hpp
26 lines (23 loc) · 1.61 KB
/
Utils.hpp
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
/*!
* @file Utils.hpp
* @author Athena Elafrou <ae488@cam.ac.uk>
* @date 23 Aug 2024
*/
#pragma once
#include <mpi.h>
#define CHECK_MPI(func) \
{ \
int mpi_status = (func); \
if (mpi_status != MPI_SUCCESS) { \
char mpi_error_string[MPI_MAX_ERROR_STRING]; \
int mpi_error_string_length = 0; \
MPI_Error_string(mpi_status, mpi_error_string, &mpi_error_string_length); \
if (mpi_error_string != NULL) \
fprintf(stderr, "ERROR: MPI call \"%s\" at line %d of file %s with %s (%d)\n", \
#func, __LINE__, __FILE__, mpi_error_string, mpi_status); \
else \
fprintf(stderr, "ERROR: MPI call \"%s\" at line %d of file %s failed with %d.\n", \
#func, __LINE__, __FILE__, mpi_status); \
exit(mpi_status); \
} \
}