Put the test's mask in through LoadUserMask, not through a const_cast
The fused GPU preprocessor uploads a byte-per-pixel form of the mask that PixelMask derives when the mask is loaded. Writing the bitfield behind its back left that form stale, so the device worked from a mask the CPU reference did not have. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
aceaf8b714
commit
f6983486c3
@@ -69,10 +69,13 @@ void CheckFusedMatchesCPU(CompressedImageMode mode, T err_value, uint32_t seed)
|
||||
|
||||
PixelMask mask(x);
|
||||
// Mask a deterministic scatter of pixels, so masked-vs-error-vs-saturated priority is exercised
|
||||
// rather than assumed.
|
||||
auto &m = const_cast<std::vector<uint32_t> &>(mask.GetMask());
|
||||
for (size_t i = 0; i < npixels; i += 997) m[i] = 1;
|
||||
for (size_t i = 13; i < npixels; i += 4001) m[i] = 1;
|
||||
// rather than assumed. It goes in through LoadUserMask because the mask derives the
|
||||
// byte-per-pixel form the GPU preprocessor uploads: writing the bitfield behind its back leaves
|
||||
// that form stale, and the device then works from a mask the CPU reference does not have.
|
||||
std::vector<uint32_t> user_mask(mask.GetMask().size(), 0);
|
||||
for (size_t i = 0; i < npixels; i += 997) user_mask[i] = 1;
|
||||
for (size_t i = 13; i < npixels; i += 4001) user_mask[i] = 1;
|
||||
mask.LoadUserMask(x, user_mask);
|
||||
|
||||
const auto img = MakeImage<T>(npixels, err_value, seed);
|
||||
JFJochBitShuffleCompressor compressor(CompressionAlgorithm::BSHUF_LZ4);
|
||||
@@ -132,8 +135,9 @@ TEST_CASE("ImagePreprocessorGPU_FusedMatchesHostUpload", "[ImagePreprocessorGPU]
|
||||
DiffractionExperiment x = MakeExperiment(32000);
|
||||
const size_t npixels = x.GetPixelsNum();
|
||||
PixelMask mask(x);
|
||||
auto &m = const_cast<std::vector<uint32_t> &>(mask.GetMask());
|
||||
for (size_t i = 0; i < npixels; i += 1301) m[i] = 1;
|
||||
std::vector<uint32_t> user_mask(mask.GetMask().size(), 0);
|
||||
for (size_t i = 0; i < npixels; i += 1301) user_mask[i] = 1;
|
||||
mask.LoadUserMask(x, user_mask);
|
||||
|
||||
const auto img = MakeImage<uint32_t>(npixels, UINT32_MAX, 77);
|
||||
JFJochBitShuffleCompressor compressor(CompressionAlgorithm::BSHUF_LZ4);
|
||||
|
||||
Reference in New Issue
Block a user