Skip to content

Commit

Permalink
Relax the condition for C contiguity for finding a fast path
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescAlted committed Jan 14, 2025
1 parent 867ddb3 commit 07a76d1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions blosc/b2nd.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,10 @@ int64_t nchunk_fastpath(const b2nd_array_t *array, const int64_t *start,
int ndim = (int) array->ndim;
int inner_dim = ndim - 1;
int64_t partial_slice_size = 1;
int outer_dims = 0;
for (int j = 0; j < inner_dim; ++j) {
outer_dims += (array->blockshape[j] != 1);
}
int64_t partial_chunk_size = 1;
for (int i = ndim - 1; i >= 0; --i) {
// We need to check if the slice is contiguous in the C order
Expand All @@ -724,11 +728,13 @@ int64_t nchunk_fastpath(const b2nd_array_t *array, const int64_t *start,
}
}
else {
if (array->chunkshape[i] != array->blockshape[i]) {
// A block is still contiguous in the C order if the outer dimensions are 1 and the inner is
// a divisor of the chunkshape
if ( ! (array->chunkshape[i] == array->blockshape[i] ||
(outer_dims == 0 && array->chunkshape[i] % array->blockshape[i] == 0))) {
return -1;
}
}
inner_dim = i;
}

// We need start and stop to be aligned with the chunkshape
Expand All @@ -743,7 +749,6 @@ int64_t nchunk_fastpath(const b2nd_array_t *array, const int64_t *start,
return -1;
}
}

// Compute the chunk number
int64_t *chunks_idx;
int nchunks = b2nd_get_slice_nchunks(array, start, stop, &chunks_idx);
Expand Down

0 comments on commit 07a76d1

Please sign in to comment.