-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtracking.cpp
More file actions
130 lines (121 loc) · 3.81 KB
/
Copy pathtracking.cpp
File metadata and controls
130 lines (121 loc) · 3.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#include "tracking.h"
#ifdef USE_MPI
#include "mpi.h"
#endif
#ifdef USE_ERRHANDLER
#include <execinfo.h>
#include <sys/types.h>
#include <unistd.h>
#if !__cpp_exceptions
namespace std {
void __throw_system_error(int) { abort(); }
void __throw_bad_function_call() { abort(); }
} // namespace std
#endif
#ifdef USE_MPI
static MPI_Errhandler CommErrHandler{MPI_ERRHANDLER_NULL};
static void myMpiErrHandler(MPI_Comm *comm, int *errCode, ...) {
printf("Handling MPI Error %i at pid %i\n", *errCode, getpid());
sleep(10);
disable_signalhandlers();
abort();
}
void createErrHandler() {
if (!analysis_flags->stacktrace)
return;
PMPI_Comm_create_errhandler(myMpiErrHandler, &CommErrHandler);
}
void registerErrHandler(MPI_Comm comm) {
if (!analysis_flags->stacktrace)
return;
PMPI_Comm_set_errhandler(comm, CommErrHandler);
}
#endif
#ifdef HANDLE_WIN
template <> MPI_Win WinData::nullHandle{MPI_WIN_NULL};
WinFactory wf;
#endif
#ifdef HANDLE_FILE
template <> MPI_File FileData::nullHandle{MPI_FILE_NULL};
FileFactory ff;
#endif
#ifdef HANDLE_COMM
template <>
bool AbstractHandleFactory<MPI_Comm, CommData, toolCommData>::isPredefined(
MPI_Comm handle) {
return handle == MPI_COMM_NULL || handle == MPI_COMM_WORLD ||
handle == MPI_COMM_SELF;
}
template <>
void AbstractHandleFactory<MPI_Comm, CommData, toolCommData>::initPredefined() {
predefHandles[MPI_COMM_NULL].init(MPI_COMM_NULL);
predefHandles[MPI_COMM_WORLD].init(MPI_COMM_WORLD);
predefHandles[MPI_COMM_SELF].init(MPI_COMM_SELF);
}
MPI_Comm CommData::nullHandle{MPI_COMM_NULL};
CommFactory cf;
#endif
#ifdef HANDLE_MESSAGE
template <>
bool AbstractHandleFactory<MPI_Message, MessageData,
toolMessageData>::isPredefined(MPI_Message handle) {
return handle == MPI_MESSAGE_NULL || handle == MPI_MESSAGE_NO_PROC;
}
template <>
void AbstractHandleFactory<MPI_Message, MessageData,
toolMessageData>::initPredefined() {}
MessageFactory mf;
#endif
#ifdef HANDLE_REQUEST
MPI_Request RequestData::nullHandle{MPI_REQUEST_NULL};
RequestFactory rf;
#endif
#if defined(HAVE_SESSION) && defined(HANDLE_SESSION)
template <> MPI_Session SessionData::nullHandle{MPI_SESSION_NULL};
SessionFactory sf;
#endif
int ipcData::num_uc_double{NUM_UC_DOUBLE};
int ipcData::num_uc_int64{NUM_UC_INT64};
MPI_Datatype ipcData::ipcMpiType{MPI_DATATYPE_NULL};
MPI_Op ipcData::ipcMpiOp{MPI_OP_NULL};
void maxloc(depMetric *, depMetric *, int *, MPI_Datatype *);
void maxloc(depMetric *invec, depMetric *inoutvec, int *len,
MPI_Datatype *dtype) {
assert(ipcData::ipcMpiType == *dtype);
for (int i = 0; i < *len; i++) {
if (inoutvec[i].fvalues[0] < invec[i].fvalues[0]) {
for (int j = 0; j < ipcData::num_uc_double; j++)
inoutvec[i].fvalues[j] = invec[i].fvalues[j];
for (int j = 0; j < ipcData::num_uc_int64; j++)
inoutvec[i].ivalues[j] = invec[i].ivalues[j];
}
}
}
void ipcData::initIpcData() {
if (num_uc_int64 > 0) {
depMetric tempData{};
MPI_Aint displs[2];
PMPI_Get_address(tempData.fvalues, displs);
PMPI_Get_address(tempData.ivalues, displs + 1);
MPI_Datatype struType = MPI_DATATYPE_NULL;
displs[1] -= displs[0];
displs[0] = 0;
MPI_Datatype types[] = {MPI_DOUBLE, MPI_INT64_T};
int blengths[] = {num_uc_double, num_uc_int64};
PMPI_Type_create_struct(2, blengths, displs, types, &struType);
PMPI_Type_create_resized(struType, 0, sizeof(depMetric), &ipcMpiType);
PMPI_Type_commit(&ipcMpiType);
PMPI_Type_free(&struType);
PMPI_Op_create((MPI_User_function *)maxloc, 1, &ipcMpiOp);
} else {
ipcMpiType = MPI_DOUBLE;
ipcMpiOp = MPI_MAX;
}
}
void ipcData::finiIpcData() {
if (ipcMpiType != MPI_DATATYPE_NULL && ipcMpiType != MPI_DOUBLE)
PMPI_Type_free(&ipcMpiType);
if (ipcMpiOp != MPI_MAX)
PMPI_Op_free(&ipcMpiOp);
}
#endif // USE_MPI