Skip to content

Commit b156231

Browse files
committed
add benchmark test case for little order.
1 parent b5c5ad8 commit b156231

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Diff for: benchmarks/benchmarks/bench_core.py

+3
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ def setup(self, dtype):
165165
def time_packbits(self, dtype):
166166
np.packbits(self.d)
167167

168+
def time_packbits_little(self, dtype):
169+
np.packbits(self.d, bitorder="little")
170+
168171
def time_packbits_axis0(self, dtype):
169172
np.packbits(self.d2, axis=0)
170173

Diff for: numpy/core/src/multiarray/compiled_base.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1502,6 +1502,7 @@ pack_inner(const char *inptr,
15021502
npy_intp vn_out = n_out - (remain ? 1 : 0);
15031503
const int vstep = npyv_nlanes_u64;
15041504
const int vstepx4 = vstep * 4;
1505+
const int isAligned = npy_is_aligned(outptr, sizeof(npy_uint64));
15051506
vn_out -= (vn_out & (vstep - 1));
15061507
for (; index <= vn_out - vstepx4; index += vstepx4, inptr += npyv_nlanes_u8 * 4) {
15071508
npyv_u8 v0 = npyv_load_u8((const npy_uint8*)inptr);
@@ -1520,7 +1521,7 @@ pack_inner(const char *inptr,
15201521
bb[2] = npyv_tobits_b8(npyv_cmpneq_u8(v2, v_zero));
15211522
bb[3] = npyv_tobits_b8(npyv_cmpneq_u8(v3, v_zero));
15221523
if(out_stride == 1 &&
1523-
(!NPY_STRONG_ALIGNMENT || npy_is_aligned(outptr, sizeof(npy_uint64)))) {
1524+
(!NPY_STRONG_ALIGNMENT || isAligned)) {
15241525
npy_uint64 *ptr64 = (npy_uint64*)outptr;
15251526
#if NPY_SIMD_WIDTH == 16
15261527
npy_uint64 bcomp = bb[0] | (bb[1] << 16) | (bb[2] << 32) | (bb[3] << 48);

0 commit comments

Comments
 (0)