Commit 7ba6738
Fix MGARD-X HIP Huffman lossless (codec correctness + code-length OOB)
Four independent bugs in the MGARD-X HIP ParallelHuffman lossless path:
three in the Huffman codec (canonical-codeword generation, header
serialization, and codeword-length overflow handling) made GPU-compressed
streams undecodable/oversized or abort, and one out-of-bounds device read
in the parallel code-length generation faulted on the GPU. All verified on
gfx90a (Frontier MI250X/MI210): HIP-compressed streams now round-trip and
are byte-compatible with the SERIAL decoder.
HuffmanWorkspace.hpp: allocate `status` as non-managed device memory.
It was managed (hipMallocManaged); atomicMin on fine-grained memory is
unreliable on ROCm/gfx90a, so GenerateCW::Operation4's atomic min never
updated newCDPI. The Huffman length-group boundary was never found, all
symbols collapsed into one group, and the canonical codewords came out
with a constant offset -- codebook and decodebook mutually inconsistent,
so the stream was undecodable by any backend.
Huffman.hpp: default-initialize `outlier_count = 0`.
ComposedLosslessCompressor::Compress -> CompressPrimary never writes
outlier_count, but Serialize reads it to size compressed_data.resize().
The uninitialized value produced a garbage-sized allocation (hipMalloc
OOM, or an invalid Copy1D).
GetCodebook.hpp: throw instead of exit(1) when the longest codeword
exceeds the H-type budget (sizeof(H)*8 - 8 bits), so callers can catch
it and fall back to another lossless backend or a smaller dict_size.
GenerateCL.hpp: bounds-check histogram[_lNodesCur + _curLeavesNum] in the
parallel code-length generation; when every remaining leaf joins the
batch the index reached dict_size (one past end of the nz_dict_size
histogram), faulting on GPU.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent b40d1a7 commit 7ba6738
4 files changed
Lines changed: 39 additions & 10 deletions
File tree
- include/mgard-x/Lossless/ParallelHuffman
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
349 | 349 | | |
350 | 350 | | |
351 | 351 | | |
352 | | - | |
353 | | - | |
354 | | - | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
355 | 368 | | |
356 | 369 | | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
361 | 376 | | |
362 | 377 | | |
363 | 378 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| |||
119 | 122 | | |
120 | 123 | | |
121 | 124 | | |
122 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
123 | 135 | | |
124 | 136 | | |
125 | 137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
449 | | - | |
| 449 | + | |
450 | 450 | | |
451 | 451 | | |
452 | 452 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
139 | 141 | | |
140 | 142 | | |
141 | 143 | | |
| |||
0 commit comments