Repository navigation
3.3 bugfix - #104
3.3 bugfix#104
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug related to handling cases where data dimensions are smaller than the block size in sampling and profiling functions. The changes prevent potential out-of-bounds access and infinite loops that could occur when dimension sizes are less than the block size used for sampling or compression operations.
- Added dimension validation checks in sampling and profiling functions to prevent processing when any dimension is smaller than the required block size
- Added similar validation in the compression algorithm to disable tuning when dimensions are insufficient
- Ensures early return from functions when block operations would be invalid
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| include/SZ3/utils/Sample.hpp | Added dimension validation checks in profiling_block, sample_blocks, and sampleBlocks functions to prevent processing with insufficient dimension sizes |
| include/SZ3/api/impl/SZAlgoInterp.hpp | Added validation to disable tuning in compression algorithm when dimensions are smaller than sample block size |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| size_t dimx = dims[0], dimy = dims[1], dimz = dims[2], dimw = dims[3], dimyzw = dimy * dimz * dimw, | ||
| dimzw = dimz * dimw; | ||
| if (dimx < block_size || dimy < block_size || dimz < block_size || dimw < block_size) { |
There was a problem hiding this comment.
Extra space between 'if' and the opening parenthesis. Should be 'if(' instead of 'if ('.
| if (dimx < block_size || dimy < block_size || dimz < block_size || dimw < block_size) { | |
| if(dimx < block_size || dimy < block_size || dimz < block_size || dimw < block_size) { |
| } | ||
| } else if constexpr (N == 3) { | ||
| size_t dimx = dims[0], dimy = dims[1], dimz = dims[2], dimyz = dimy * dimz; | ||
| if (dimx < block_size || dimy < block_size || dimz < block_size) { |
There was a problem hiding this comment.
Extra space between 'if' and the opening parenthesis. Should be 'if(' instead of 'if ('.
| if (dimx < block_size || dimy < block_size || dimz < block_size) { | |
| if (dimx < block_size || dimy < block_size || dimz < block_size) { |
| } | ||
| } else if constexpr (N == 2) { | ||
| size_t dimx = dims[0], dimy = dims[1]; | ||
| if (dimx < block_size || dimy < block_size) { |
There was a problem hiding this comment.
Extra space between 'if' and the opening parenthesis. Should be 'if(' instead of 'if ('.
| if (dimx < block_size || dimy < block_size) { | |
| if (dimx < block_size || dimy < block_size) { |
| } | ||
| } else { | ||
| size_t dimx = dims[0]; | ||
| if (dimx < block_size) { |
There was a problem hiding this comment.
Extra space between 'if' and the opening parenthesis. Should be 'if(' instead of 'if ('.
| if (dimx < block_size) { | |
| if (dimx < block_size) { |
| } else if constexpr (N == 3) { | ||
| if (dims[0] < block_size || dims[1] < block_size || dims[2] < block_size) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Trailing whitespace after the closing brace should be removed.
| } | |
| } |
| } else if constexpr (N == 2) { | ||
| if (dims[0] < block_size || dims[1] < block_size) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Trailing whitespace after the closing brace should be removed.
| } | |
| } |
| } else if constexpr (N == 1) { | ||
| if (dims[0] < block_size) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Trailing whitespace after the closing brace should be removed.
| } | |
| } |
| bool to_tune = pow(sampleBlockSize + 1, N) <= 0.05 * conf.num; // to further revise | ||
| if (to_tune) { | ||
| for (size_t i = 0; i < N; i++) { | ||
| if(conf.dims[i] < sampleBlockSize) { |
There was a problem hiding this comment.
Missing space between 'if' and the opening parenthesis. Should be 'if (' instead of 'if('.
| if(conf.dims[i] < sampleBlockSize) { | |
| if (conf.dims[i] < sampleBlockSize) { |
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
include/SZ3/api/impl/SZAlgoInterp.hpp:1
- The loop variable
ishould be of typesize_toruintto match the template parameterNwhich is declared asuint. Usingintmay cause comparison warnings or undefined behavior whenNis larger thanINT_MAX.
#ifndef SZ3_SZALGO_INTERP_HPP
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
No description provided.