Skip to content

Change decompress_chunk to get_chunk into cbuffer#663

Merged
lshaw8317 merged 11 commits intomainfrom
fixConcatenate2
Jun 12, 2025
Merged

Change decompress_chunk to get_chunk into cbuffer#663
lshaw8317 merged 11 commits intomainfrom
fixConcatenate2

Conversation

@lshaw8317
Copy link
Collaborator

Add arange to test for concatenate. Also - rather than decompressing chunk before passing to get_set_slice to be loaded into target array - simply retrieve chunk into buffer and then load. This avoids mangling of entries owing to block shapes that was happening in previous PR.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors chunk concatenation to retrieve chunks into a buffer instead of decompressing them first and adds an optional “arange” mode to fill tests with increasing values.

  • Introduce arange parameter and support functions (increment_large_value, fill_recursive_arange, updated fill_buffer_region)
  • Change b2nd_concatenate to use blosc2_schunk_get_chunk for aligned chunks and b2nd_get_slice_cbuffer for unaligned ones
  • Minor updates in tests, benchmark (copy flag, timing), build CI matrix, and propagate chunksize in schunk_copy

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/b2nd/test_b2nd_copy.c Remove stray blank line
tests/b2nd/test_b2nd_concatenate.c Add arange helper, update test logic to use cbuffer, new params
blosc/schunk.c Propagate chunksize in blosc2_schunk_copy
blosc/directories.c Relocate free(fname) after error check
blosc/b2nd.c Replace decompress+set with get_chunk or cbuffer paths
bench/b2nd/bench_concatenate.c Default copy=false, split timing variables, print speedup
.github/workflows/cmake.yml Comment out cross-compile, add native AARCH64 job
Comments suppressed due to low confidence (2)

tests/b2nd/test_b2nd_concatenate.c:59

  • [nitpick] This comment is in Spanish; please translate to English to match the rest of the codebase (e.g. "// If no overflow occurs, break").
// Si no hay desbordamiento, salimos

tests/b2nd/test_b2nd_concatenate.c:269

  • The inline comment says value is not used in arange mode, but fill_recursive_arange actually reads and updates it. Please correct or remove this misleading comment.
//                     start_, shapes.shape2, value, typesize, arange); // value is not used in this case

_findclose(file);
return BLOSC2_ERROR_FAILURE;
}
free(fname);
Copy link

Copilot AI Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On error paths (e.g. when remove() fails) fname is not freed, resulting in a memory leak. Move free(fname) before the early return.

Copilot uses AI. Check for mistakes.
buffsize *= shapes.shape2[i]; // Multiply by each dimension
}
// Allocate a buffer for the src2 array
uint8_t *buff = malloc(buffsize);
Copy link

Copilot AI Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The allocated buffer (and value pointer) are not freed after use in the test. Consider calling free(buff); and free(value); to avoid memory leaks.

Copilot uses AI. Check for mistakes.
Copy link
Member

@FrancescAlted FrancescAlted left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than suggestions for some cleanup, this looks good to me.

@lshaw8317 lshaw8317 merged commit d68a9cd into main Jun 12, 2025
34 checks passed
@lshaw8317 lshaw8317 deleted the fixConcatenate2 branch June 12, 2025 11:35
// TODO: the above makes some tests to crash, so always force a copy; try to optimize this later
int64_t nchunk_dest = 0;
nchunk_ndim[axis] += src1_shape[axis] / (*array)->chunkshape[axis];
for ( int i =0; i< src2->ndim; i++){nchunk_dest += nchunk_ndim[i] * chunks_in_array_strides[i];}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is against our style. FYI, we are using K&R standard internally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants