#2832: possible race condition in LoopControl
Reporter:Roland Haas
Status:new
Milestone:
Version:
Type:bug
Priority:major
Component:

Comment (by Roland Haas):

The issue may be alignment related. gcc-14 produces a warning:

COMPILING Carpet/LoopControl/src/loopcontrol.cc
/data/rhaas/postdoc/gr/cactus/ET_trunk/configs/yosef/build/LoopControl/loopcontrol.cc: In function ?voi  LC_control_init(lc_control_t*, lc_descr_t*, ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t)?:
/data/rhaas/postdoc/gr/cactus/ET_trunk/configs/yosef/build/LoopControl/loopcontrol.cc:797:29: warning:  new? of type ?lc_thread_info_t? with extended alignment 128 [-Waligned-new=]
  797 |     { thread_info_ptr = new lc_thread_info_t; }
      |                             ^~~~~~~~~~~~~~~~
/data/rhaas/postdoc/gr/cactus/ET_trunk/configs/yosef/build/LoopControl/loopcontrol.cc:797:29: note: uses ?void* operator new(std::size_t)?, which does not have an alignment parameter
/data/rhaas/postdoc/gr/cactus/ET_trunk/configs/yosef/build/LoopControl/loopcontrol.cc:797:29: note: use ?-faligned-new? to enable C++17 over-aligned new support

and changing LoopControl like this:

diff --git a/LoopControl/src/loopcontrol.cc b/LoopControl/src/loopcontrol.cc
index a2e3460f2..062db9c1f 100644
--- a/LoopControl/src/loopcontrol.cc
+++ b/LoopControl/src/loopcontrol.cc
@@ -71,12 +71,16 @@ static minstd_rand::result_type const constexpr lc_random_range =

 struct lc_thread_info_t {
   volatile int idx;            // linear index of next coarse thread block
-} CCTK_ATTRIBUTE_ALIGNED(128); // align to prevent sharing cache lines
+  char pad[128 - sizeof(int)]; // align to prevent sharing cache lines
+};
+static_assert

--
Ticket URL: https://bitbucket.org/einsteintoolkit/tickets/issues/2832/possible-race-condition-in-loopcontrol