Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,6 @@ One common issue is that people do not provide large enough buffers.
Some schemes can have such small compression rates that the compressed data
generated will be much larger than the input data.

Also, make sure that all provided buffers are 16-byte aligned or else,
some SSE instructions may fail.

## Is any of this code subject to patents?

I (D. Lemire) did not patent anything.
Expand Down
8 changes: 7 additions & 1 deletion headers/VarIntG8IU.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@ class VarIntG8IU : public IntegerCODEC {
while (srclength > 0 && nvalue >= 9) {
compressed_size += encodeBlock(src, srclength, dst, nvalue);
}
// Ouput might not be a multiple of 4 so we make it so
// Output might not be a multiple of 4 so we make it so
nvalue = ((compressed_size + 3) / 4);
while (dst < reinterpret_cast<unsigned char*>(out + nvalue)) {
*dst++ = 0; // clear padding bytes
}
}

const uint32_t *decodeArray(const uint32_t *in, const size_t length,
Expand Down Expand Up @@ -195,6 +198,9 @@ class VarIntG8IU : public IntegerCODEC {
written++;
}
}
while (written < 9) {
dest[written++] = 0; // clear padding bytes
}
dest += 9;
dstlength -= 9;
return 9;
Expand Down
24 changes: 10 additions & 14 deletions headers/deltautil.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,12 @@ class Delta {

__m128i last = _mm_setzero_si128();
while (pCurr < pEnd) {
__m128i a0 = _mm_load_si128(pCurr);
__m128i a0 = _mm_loadu_si128(pCurr);
__m128i a1 = _mm_sub_epi32(a0, _mm_srli_si128(last, 12));
a1 = _mm_sub_epi32(a1, _mm_slli_si128(a0, 4));
last = a0;

_mm_store_si128(pCurr++, a1);
_mm_storeu_si128(pCurr++, a1);
}

if (Qty4 * 4 < TotalQty) {
Expand All @@ -225,10 +225,10 @@ class Delta {
}
__m128i *pCurr = reinterpret_cast<__m128i *>(pData) + Qty4 - 1;
const __m128i *pStart = reinterpret_cast<__m128i *>(pData);
__m128i a = _mm_load_si128(pCurr);
__m128i a = _mm_loadu_si128(pCurr);
while (pCurr > pStart) {
__m128i b = _mm_load_si128(pCurr - 1);
_mm_store_si128(pCurr--, _mm_sub_epi32(a, b));
__m128i b = _mm_loadu_si128(pCurr - 1);
_mm_storeu_si128(pCurr--, _mm_sub_epi32(a, b));
a = b;
}
}
Expand All @@ -244,11 +244,11 @@ class Delta {

__m128i *pCurr = reinterpret_cast<__m128i *>(pData);
const __m128i *pEnd = pCurr + Qty4;
__m128i a = _mm_load_si128(pCurr++);
__m128i a = _mm_loadu_si128(pCurr++);
while (pCurr < pEnd) {
__m128i b = _mm_load_si128(pCurr);
__m128i b = _mm_loadu_si128(pCurr);
a = _mm_add_epi32(a, b);
_mm_store_si128(pCurr++, a);
_mm_storeu_si128(pCurr++, a);
}

for (size_t i = Qty4 * 4; i < TotalQty; ++i) {
Expand Down Expand Up @@ -304,12 +304,12 @@ class Delta {
__m128i *pCurr = reinterpret_cast<__m128i *>(pData);
const __m128i *pEnd = pCurr + Qty4;
while (pCurr < pEnd) {
__m128i a0 = _mm_load_si128(pCurr);
__m128i a0 = _mm_loadu_si128(pCurr);
__m128i a1 = _mm_add_epi32(_mm_slli_si128(a0, 8), a0);
__m128i a2 = _mm_add_epi32(_mm_slli_si128(a1, 4), a1);
a0 = _mm_add_epi32(a2, runningCount);
runningCount = _mm_shuffle_epi32(a0, 0xFF);
_mm_store_si128(pCurr++, a0);
_mm_storeu_si128(pCurr++, a0);
}

for (size_t i = Qty4 * 4; i < TotalQty; ++i) {
Expand Down Expand Up @@ -442,7 +442,6 @@ class Delta {
continue;
uint32_t *outp = &outs[k][0];
nvalue = outs[k].size();
assert(!needPaddingTo128Bits(outp));
const size_t orignvalue = nvalue;
{
nvalue = orignvalue;
Expand Down Expand Up @@ -473,7 +472,6 @@ class Delta {
size_t recoveredsize = datas[k].size();
assert(recoveredsize > 0);
uint32_t *recov = recovereds.data();
assert(!needPaddingTo128Bits(recov));

z.reset();
c.decodeArray(outp, nvalue, recov, recoveredsize);
Expand All @@ -485,8 +483,6 @@ class Delta {
inverseDeltaSIMD(recov, recoveredsize);
} else {
fastinverseDelta2(recov, recoveredsize);
// fastinverseDelta(recov, recoveredsize);
// inverseDelta(recov, recoveredsize);
}
timemsinversedelta += static_cast<double>(z.split());
}
Expand Down
9 changes: 0 additions & 9 deletions headers/simdbinarypacking.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ class SIMDBinaryPacking : public IntegerCODEC {
checkifdivisibleby(length, BlockSize);
const uint32_t *const initout(out);
*out++ = static_cast<uint32_t>(length);
while (needPaddingTo128Bits(out))
*out++ = CookiePadder;
uint32_t Bs[HowManyMiniBlocks];
const uint32_t *const final = in + length;
for (; in + HowManyMiniBlocks * MiniBlockSize <= final;
Expand Down Expand Up @@ -90,13 +88,6 @@ class SIMDBinaryPacking : public IntegerCODEC {
const uint32_t *decodeArray(const uint32_t *in, const size_t /*length*/,
uint32_t *out, size_t &nvalue) {
const uint32_t actuallength = *in++;
if (needPaddingTo128Bits(out))
throw std::runtime_error("bad initial output align");
while (needPaddingTo128Bits(in)) {
if (in[0] != CookiePadder)
throw std::logic_error("SIMDBinaryPacking alignment issue.");
++in;
}
const uint32_t *const initout(out);
uint32_t Bs[HowManyMiniBlocks];
for (; out < initout +
Expand Down
4 changes: 0 additions & 4 deletions headers/simdfastpfor.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,6 @@ class SIMDFastPFor : public IntegerCODEC {
for (uint32_t k = 0; k < 32 + 1; ++k)
datatobepacked[k].clear();
uint8_t *bc = &bytescontainer[0];
out = padTo128bits(out);
assert(!needPaddingTo128Bits(in));
for (const uint32_t *const final = in + length; (in + BlockSize <= final);
in += BlockSize) {
uint8_t bestb, bestcexcept, maxb;
Expand Down Expand Up @@ -319,8 +317,6 @@ class SIMDFastPFor : public IntegerCODEC {
for (uint32_t k = 1; k <= 32; ++k) {
unpackpointers[k] = datatobepacked[k].begin();
}
in = padTo128bits(in);
assert(!needPaddingTo128Bits(out));
for (uint32_t run = 0; run < nvalue / BlockSize; ++run, out += BlockSize) {
const uint8_t b = *bytep++;
const uint8_t cexcept = *bytep++;
Expand Down
Loading