FIx compilation on Windows with GCC16#3386
Conversation
Replace the namespace-scope thread-local MR::DWI::Tractography::rng with a function-local thread_local accessed via a rng() accessor, lazily constructed on first use. The previous extern thread_local definition triggered compilation failures under GCC 16 on Windows due to changes in thread-local storage handling; the Meyers idiom sidesteps that codepath while preserving identical per-thread semantics. All call sites across the seeding, algorithm, and tracking code were updated to invoke rng() accordingly. Session prompts: 1. > Implement a Meyers-style accessor function for variable > MR::DWI::Tractography::rng, to prevent compilation failures on Windows > due to TLS changes in GCC16. Generated-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| } | ||
|
|
||
| if (uniform(rng) < val / max_val) { | ||
| if (uniform(rng()) < val / max_val) { |
There was a problem hiding this comment.
warning: no header providing "MR::DWI::Tractography::rng" is directly included [misc-include-cleaner]
cpp/core/dwi/tractography/algorithms/iFOD1.h:23:
- #include "dwi/tractography/tracking/method.h"
+ #include "dwi/tractography/rng.h"
+ #include "dwi/tractography/tracking/method.h"| } | ||
|
|
||
| if (uniform(rng) < val / max_val) { | ||
| if (uniform(rng()) < val / max_val) { |
There was a problem hiding this comment.
warning: no header providing "MR::DWI::Tractography::rng" is directly included [misc-include-cleaner]
cpp/core/dwi/tractography/algorithms/iFOD2.h:25:
- #include "dwi/tractography/tracking/method.h"
+ #include "dwi/tractography/rng.h"
+ #include "dwi/tractography/tracking/method.h"| } | ||
|
|
||
| float get_metric(const Eigen::Vector3f &, const Eigen::Vector3f &) override { return uniform(rng); } | ||
| float get_metric(const Eigen::Vector3f &, const Eigen::Vector3f &) override { return uniform(rng()); } |
There was a problem hiding this comment.
warning: all parameters should be named in a function [readability-named-parameter]
| float get_metric(const Eigen::Vector3f &, const Eigen::Vector3f &) override { return uniform(rng()); } | |
| float get_metric(const Eigen::Vector3f & /*position*/, const Eigen::Vector3f & /*direction*/) override { return uniform(rng()); } |
| } | ||
|
|
||
| float get_metric(const Eigen::Vector3f &, const Eigen::Vector3f &) override { return uniform(rng); } | ||
| float get_metric(const Eigen::Vector3f &, const Eigen::Vector3f &) override { return uniform(rng()); } |
There was a problem hiding this comment.
warning: no header providing "MR::DWI::Tractography::rng" is directly included [misc-include-cleaner]
cpp/core/dwi/tractography/algorithms/nulldist.h:22:
- #include "dwi/tractography/tracking/method.h"
+ #include "dwi/tractography/rng.h"
+ #include "dwi/tractography/tracking/method.h"| } | ||
|
|
||
| float get_metric(const Eigen::Vector3f &, const Eigen::Vector3f &) override { return uniform(rng); } | ||
| float get_metric(const Eigen::Vector3f &, const Eigen::Vector3f &) override { return uniform(rng()); } |
There was a problem hiding this comment.
warning: all parameters should be named in a function [readability-named-parameter]
| float get_metric(const Eigen::Vector3f &, const Eigen::Vector3f &) override { return uniform(rng()); } | |
| float get_metric(const Eigen::Vector3f & /*position*/, const Eigen::Vector3f & /*direction*/) override { return uniform(rng()); } |
| } while (seed.value() < selector); | ||
| p = {seed.index(0) + uniform(rng) - 0.5f, seed.index(1) + uniform(rng) - 0.5f, seed.index(2) + uniform(rng) - 0.5f}; | ||
| p = {seed.index(0) + uniform(rng()) - 0.5f, | ||
| seed.index(1) + uniform(rng()) - 0.5f, |
There was a problem hiding this comment.
warning: floating point literal has suffix 'f', which is not uppercase [readability-uppercase-literal-suffix]
| seed.index(1) + uniform(rng()) - 0.5f, | |
| seed.index(1) + uniform(rng()) - 0.5F, |
| } while (seed.value() < selector); | ||
| p = {seed.index(0) + uniform(rng) - 0.5f, seed.index(1) + uniform(rng) - 0.5f, seed.index(2) + uniform(rng) - 0.5f}; | ||
| p = {seed.index(0) + uniform(rng()) - 0.5f, | ||
| seed.index(1) + uniform(rng()) - 0.5f, |
There was a problem hiding this comment.
warning: narrowing conversion from 'ssize_t' (aka 'long') to 'result_type' (aka 'float') [bugprone-narrowing-conversions]
seed.index(1) + uniform(rng()) - 0.5f,
^| p = {seed.index(0) + uniform(rng) - 0.5f, seed.index(1) + uniform(rng) - 0.5f, seed.index(2) + uniform(rng) - 0.5f}; | ||
| p = {seed.index(0) + uniform(rng()) - 0.5f, | ||
| seed.index(1) + uniform(rng()) - 0.5f, | ||
| seed.index(2) + uniform(rng()) - 0.5f}; |
There was a problem hiding this comment.
warning: floating point literal has suffix 'f', which is not uppercase [readability-uppercase-literal-suffix]
| seed.index(2) + uniform(rng()) - 0.5f}; | |
| seed.index(2) + uniform(rng()) - 0.5F}; |
| p = {seed.index(0) + uniform(rng) - 0.5f, seed.index(1) + uniform(rng) - 0.5f, seed.index(2) + uniform(rng) - 0.5f}; | ||
| p = {seed.index(0) + uniform(rng()) - 0.5f, | ||
| seed.index(1) + uniform(rng()) - 0.5f, | ||
| seed.index(2) + uniform(rng()) - 0.5f}; |
There was a problem hiding this comment.
warning: narrowing conversion from 'ssize_t' (aka 'long') to 'result_type' (aka 'float') [bugprone-narrowing-conversions]
seed.index(2) + uniform(rng()) - 0.5f};
^| const Eigen::Vector3i &v(fixel.get_voxel()); | ||
| const Eigen::Vector3f vp( | ||
| v[0] + uniform_float(rng) - 0.5, v[1] + uniform_float(rng) - 0.5, v[2] + uniform_float(rng) - 0.5); | ||
| v[0] + uniform_float(rng()) - 0.5, v[1] + uniform_float(rng()) - 0.5, v[2] + uniform_float(rng()) - 0.5); |
There was a problem hiding this comment.
warning: narrowing conversion from 'double' to 'Scalar' (aka 'float') [bugprone-narrowing-conversions]
v[0] + uniform_float(rng()) - 0.5, v[1] + uniform_float(rng()) - 0.5, v[2] + uniform_float(rng()) - 0.5);
^
The failure to generate the DLL due to mismatched compiler used for the GPU Dawn library in #3384 was obscuring a second linking failure due to the same TLS change in GCC16. This is I think the least obtrusive fix.