Skip to content

Commit 961ab63

Browse files
committed
Refactor kind -> mutexKind.
1 parent c7e1e7a commit 961ab63

3 files changed

Lines changed: 40 additions & 40 deletions

File tree

include/opdi/logic/omp/instrument/ompLogicOutputInstrument.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ namespace opdi {
9292
virtual void reverseMutexWait(MutexOmpLogic::Data* data) {
9393
TapedOutput::print("R MWAI l", omp_get_level(),
9494
"t", omp_get_thread_num(),
95-
"kind", data->kind,
95+
"kind", data->mutexKind,
9696
"id", data->waitId,
9797
"until", data->counter);
9898
}
9999

100100
virtual void reverseMutexDecrement(MutexOmpLogic::Data* data) {
101101
TapedOutput::print("R MDEC t", omp_get_thread_num(),
102-
"kind", data->kind,
102+
"kind", data->mutexKind,
103103
"id", data->waitId,
104104
"to", data->counter);
105105
}
@@ -112,14 +112,14 @@ namespace opdi {
112112

113113
virtual void onMutexAcquired(MutexOmpLogic::Data* data) {
114114
TapedOutput::print("F MACQ t", omp_get_thread_num(),
115-
"kind", data->kind,
115+
"kind", data->mutexKind,
116116
"id", data->waitId,
117117
"at", data->counter);
118118
}
119119

120120
virtual void onMutexReleased(MutexOmpLogic::Data* data) {
121121
TapedOutput::print("F MREL t", omp_get_thread_num(),
122-
"kind", data->kind,
122+
"kind", data->mutexKind,
123123
"id", data->waitId,
124124
"at", data->counter);
125125
}

include/opdi/logic/omp/mutexOmpLogic.cpp

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ opdi::MutexOmpLogic::AllCounters opdi::MutexOmpLogic::evaluationCounters;
4040
opdi::MutexOmpLogic::AllCounters opdi::MutexOmpLogic::tsanDummies;
4141
#endif
4242

43-
void opdi::MutexOmpLogic::checkKind(MutexKind kind) {
44-
if (kind >= nMutexKind) {
43+
void opdi::MutexOmpLogic::checkKind(MutexKind mutexKind) {
44+
if (mutexKind >= nMutexKind) {
4545
OPDI_ERROR("Invalid mutex kind.");
4646
}
4747
}
@@ -61,15 +61,15 @@ void opdi::MutexOmpLogic::waitReverseFunc(void* dataPtr) {
6161
MutexOmpLogic::Counter currentValue;
6262

6363
#pragma omp atomic read
64-
currentValue = MutexOmpLogic::evaluationCounters[data->kind][data->waitId];
64+
currentValue = MutexOmpLogic::evaluationCounters[data->mutexKind][data->waitId];
6565

6666
if (currentValue == data->counter) {
6767
break;
6868
}
6969
}
7070

7171
#ifdef __SANITIZE_THREAD__
72-
ANNOTATE_RWLOCK_ACQUIRED(&MutexOmpLogic::tsanDummies[data->kind][data->waitId], true);
72+
ANNOTATE_RWLOCK_ACQUIRED(&MutexOmpLogic::tsanDummies[data->mutexKind][data->waitId], true);
7373
#endif
7474
}
7575

@@ -83,12 +83,12 @@ void opdi::MutexOmpLogic::decrementReverseFunc(void* dataPtr) {
8383
Data* data = static_cast<Data*>(dataPtr);
8484

8585
#ifdef __SANITIZE_THREAD__
86-
ANNOTATE_RWLOCK_RELEASED(&MutexOmpLogic::tsanDummies[data->kind][data->waitId], true);
86+
ANNOTATE_RWLOCK_RELEASED(&MutexOmpLogic::tsanDummies[data->mutexKind][data->waitId], true);
8787
#endif
8888

8989
// decrement counter
9090
#pragma omp atomic update
91-
MutexOmpLogic::evaluationCounters[data->kind][data->waitId] -= 1;
91+
MutexOmpLogic::evaluationCounters[data->mutexKind][data->waitId] -= 1;
9292

9393
#if OPDI_OMP_LOGIC_INSTRUMENT
9494
for (auto& instrument : ompLogicInstruments) {
@@ -115,24 +115,24 @@ void opdi::MutexOmpLogic::internalFinalize() {
115115
}
116116
}
117117

118-
void opdi::MutexOmpLogic::onMutexDestroyed(MutexKind kind, WaitId waitId) {
118+
void opdi::MutexOmpLogic::onMutexDestroyed(MutexKind mutexKind, WaitId waitId) {
119119

120120
#if OPDI_OMP_LOGIC_INSTRUMENT
121121
for (auto& instrument : ompLogicInstruments) {
122-
instrument->onMutexDestroyed(kind, waitId);
122+
instrument->onMutexDestroyed(mutexKind, waitId);
123123
}
124124
#endif
125125

126-
checkKind(kind);
127-
this->recordings[kind].inactive.erase(waitId);
126+
checkKind(mutexKind);
127+
this->recordings[mutexKind].inactive.erase(waitId);
128128
}
129129

130-
void opdi::MutexOmpLogic::onMutexAcquired(MutexKind kind, WaitId waitId) {
130+
void opdi::MutexOmpLogic::onMutexAcquired(MutexKind mutexKind, WaitId waitId) {
131131

132-
checkKind(kind);
132+
checkKind(mutexKind);
133133

134134
// always skip internal locks
135-
if (MutexKind::Lock == kind) {
135+
if (MutexKind::Lock == mutexKind) {
136136
for (std::size_t mutexKind = 0; mutexKind < nMutexKind; ++mutexKind) {
137137
if (waitId == this->recordings[mutexKind].waitId) {
138138
return;
@@ -143,16 +143,16 @@ void opdi::MutexOmpLogic::onMutexAcquired(MutexKind kind, WaitId waitId) {
143143
if (tool != nullptr && tool->getThreadLocalTape() != nullptr && tool->isActive(tool->getThreadLocalTape())) {
144144

145145
// skip inactive mutexes
146-
if (recordings[kind].inactive.count(waitId) == 0) {
146+
if (recordings[mutexKind].inactive.count(waitId) == 0) {
147147

148148
Data* data = new Data;
149-
data->kind = kind;
149+
data->mutexKind = mutexKind;
150150
data->waitId = waitId;
151151

152-
omp_set_lock(&recordings[kind].lock);
153-
data->counter = recordings[kind].counters[waitId]++;
154-
localCounters[kind][waitId] = recordings[kind].counters[waitId]; // remember incremented counter value for the release event
155-
omp_unset_lock(&recordings[kind].lock);
152+
omp_set_lock(&recordings[mutexKind].lock);
153+
data->counter = recordings[mutexKind].counters[waitId]++;
154+
localCounters[mutexKind][waitId] = recordings[mutexKind].counters[waitId]; // remember incremented counter value for the release event
155+
omp_unset_lock(&recordings[mutexKind].lock);
156156

157157
#if OPDI_OMP_LOGIC_INSTRUMENT
158158
for (auto& instrument : ompLogicInstruments) {
@@ -171,12 +171,12 @@ void opdi::MutexOmpLogic::onMutexAcquired(MutexKind kind, WaitId waitId) {
171171
}
172172
}
173173

174-
void opdi::MutexOmpLogic::onMutexReleased(MutexKind kind, WaitId waitId) {
174+
void opdi::MutexOmpLogic::onMutexReleased(MutexKind mutexKind, WaitId waitId) {
175175

176-
checkKind(kind);
176+
checkKind(mutexKind);
177177

178178
// always skip internal locks
179-
if (MutexKind::Lock == kind) {
179+
if (MutexKind::Lock == mutexKind) {
180180
for (std::size_t mutexKind = 0; mutexKind < nMutexKind; ++mutexKind) {
181181
if (waitId == this->recordings[mutexKind].waitId) {
182182
return;
@@ -187,15 +187,15 @@ void opdi::MutexOmpLogic::onMutexReleased(MutexKind kind, WaitId waitId) {
187187
if (tool != nullptr && tool->getThreadLocalTape() != nullptr && tool->isActive(tool->getThreadLocalTape())) {
188188

189189
// skip inactive mutexes
190-
if (recordings[kind].inactive.count(waitId) == 0) {
190+
if (recordings[mutexKind].inactive.count(waitId) == 0) {
191191

192192
Data* data = new Data;
193-
data->kind = kind;
193+
data->mutexKind = mutexKind;
194194
data->waitId = waitId;
195195

196-
omp_set_lock(&recordings[kind].lock);
197-
data->counter = localCounters[kind][waitId];
198-
omp_unset_lock(&recordings[kind].lock);
196+
omp_set_lock(&recordings[mutexKind].lock);
197+
data->counter = localCounters[mutexKind][waitId];
198+
omp_unset_lock(&recordings[mutexKind].lock);
199199

200200
#if OPDI_OMP_LOGIC_INSTRUMENT
201201
for (auto& instrument : ompLogicInstruments) {
@@ -215,9 +215,9 @@ void opdi::MutexOmpLogic::onMutexReleased(MutexKind kind, WaitId waitId) {
215215
}
216216

217217
// not thread safe! only use outside parallel regions
218-
void opdi::MutexOmpLogic::registerInactiveMutex(MutexKind kind, WaitId waitId) {
219-
checkKind(kind);
220-
this->recordings[kind].inactive.insert(waitId);
218+
void opdi::MutexOmpLogic::registerInactiveMutex(MutexKind mutexKind, WaitId waitId) {
219+
checkKind(mutexKind);
220+
this->recordings[mutexKind].inactive.insert(waitId);
221221
}
222222

223223
void opdi::MutexOmpLogic::prepareEvaluate() {

include/opdi/logic/omp/mutexOmpLogic.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ namespace opdi {
7979

8080
struct Data {
8181
public:
82-
MutexKind kind;
82+
MutexKind mutexKind;
8383
Counter counter;
8484
WaitId waitId;
8585
};
8686

8787
private:
8888

89-
void checkKind(MutexKind kind);
89+
void checkKind(MutexKind mutexKind);
9090

9191
static void waitReverseFunc(void* dataPtr);
9292
static void waitDeleteFunc(void* dataPtr);
@@ -101,12 +101,12 @@ namespace opdi {
101101

102102
public:
103103

104-
virtual void onMutexDestroyed(MutexKind kind, WaitId waitId);
105-
virtual void onMutexAcquired(MutexKind kind, WaitId waitId);
106-
virtual void onMutexReleased(MutexKind kind, WaitId waitId);
104+
virtual void onMutexDestroyed(MutexKind mutexKind, WaitId waitId);
105+
virtual void onMutexAcquired(MutexKind mutexKind, WaitId waitId);
106+
virtual void onMutexReleased(MutexKind mutexKind, WaitId waitId);
107107

108108
// not thread-safe! only use outside parallel regions
109-
virtual void registerInactiveMutex(MutexKind kind, WaitId waitId);
109+
virtual void registerInactiveMutex(MutexKind mutexKind, WaitId waitId);
110110

111111
void prepareEvaluate();
112112
void postEvaluate();

0 commit comments

Comments
 (0)