Restore windows CI#3387
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);
^Required for new test mrinfo_json_keyval
| 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);
^| 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);
^| 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 'int' to 'result_type' (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);
^| 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 'int' to 'result_type' (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);
^| 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 'int' to 'result_type' (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);
^|
|
||
| Eigen::Vector3f MethodBase::random_direction(const float max_angle, const float sin_max_angle) { | ||
| float phi = 2.0 * Math::pi * uniform(rng); | ||
| float phi = 2.0 * Math::pi * uniform(rng()); |
There was a problem hiding this comment.
warning: narrowing conversion from 'double' to 'float' [bugprone-narrowing-conversions]
float phi = 2.0 * Math::pi * uniform(rng());
^|
|
||
| Eigen::Vector3f MethodBase::random_direction(const float max_angle, const float sin_max_angle) { | ||
| float phi = 2.0 * Math::pi * uniform(rng); | ||
| float phi = 2.0 * Math::pi * uniform(rng()); |
There was a problem hiding this comment.
warning: no header providing "MR::Math::pi" is directly included [misc-include-cleaner]
cpp/core/dwi/tractography/tracking/method.cpp:17:
+ #include "math/math.h"|
|
||
| Eigen::Vector3f MethodBase::random_direction(const float max_angle, const float sin_max_angle) { | ||
| float phi = 2.0 * Math::pi * uniform(rng); | ||
| float phi = 2.0 * Math::pi * uniform(rng()); |
There was a problem hiding this comment.
warning: variable 'phi' of type 'float' can be declared 'const' [misc-const-correctness]
| float phi = 2.0 * Math::pi * uniform(rng()); | |
| float const phi = 2.0 * Math::pi * uniform(rng()); |
| theta = max_angle * uniform(rng); | ||
| } while (sin_max_angle * uniform(rng) > sin(theta)); | ||
| theta = max_angle * uniform(rng()); | ||
| } while (sin_max_angle * uniform(rng()) > sin(theta)); |
There was a problem hiding this comment.
warning: call to 'sin' promotes float to double [performance-type-promotion-in-math-fn]
cpp/core/dwi/tractography/tracking/method.cpp:17:
+
+ #include <cmath>| } while (sin_max_angle * uniform(rng()) > sin(theta)); | |
| } while (sin_max_angle * uniform(rng()) > std::sin(theta)); |
| theta = max_angle * uniform(rng); | ||
| } while (sin_max_angle * uniform(rng) > sin(theta)); | ||
| theta = max_angle * uniform(rng()); | ||
| } while (sin_max_angle * uniform(rng()) > sin(theta)); |
There was a problem hiding this comment.
warning: no header providing "sin" is directly included [misc-include-cleaner]
cpp/core/dwi/tractography/tracking/method.cpp:17:
+ #include <cmath>
This PR is a merge of the changes in #3384 and #3386. Both changes must be in place for compilation to proceed in the CI check. Therefore I'm merging the two together in the hope of producing a PR that passes checks before merging.