seams-core v2.14.0
libyodaLib, the C++ engine of d-SEAMS
Loading...
Searching...
No Matches
seams::tsan Namespace Reference

Classes

struct  Slot

Functions

void arrive_and_wait (Slot &slot, int threads)

Function Documentation

◆ arrive_and_wait()

void seams::tsan::arrive_and_wait ( Slot & slot,
int threads )
inline

Definition at line 23 of file omp_tsan.hpp.

23 {
24#ifdef SEAMS_TSAN_JOIN
25 if (threads < 1) {
26 return;
27 }
28 const int seen = slot.epoch.load(std::memory_order_relaxed);
29 const int turn = slot.arrived.fetch_add(1, std::memory_order_acq_rel);
30 if (turn + 1 == threads) {
31 slot.arrived.store(0, std::memory_order_relaxed);
32 slot.epoch.fetch_add(1, std::memory_order_release);
33 return;
34 }
35 while (slot.epoch.load(std::memory_order_acquire) == seen) {
36 }
37#else
38 (void)slot;
39 (void)threads;
40#endif
41}
std::atomic< int > arrived
Definition omp_tsan.hpp:19
std::atomic< int > epoch
Definition omp_tsan.hpp:20