Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial implementation of using Accelogic compression (RLE-Huffman) on integer types #8

Merged
merged 1 commit into from
Oct 29, 2021
Merged
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
65 changes: 61 additions & 4 deletions core/accelogic/src/ZipAccelogic.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ void R__zipBLAST(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgt,

size_t out_size;

if (cxlevel <= 71 && (*srcsize % 4 == 0)) {
size_t float_size = *srcsize / 4;
if (cxlevel <= 71 && (*srcsize % sizeof(float) == 0)) {
size_t float_size = *srcsize / sizeof(float);
// Use "absSense". We shift the request config from [1,71] to [-60, 10]
auto absSensLevel = cxlevel - 61;
// Note: We need to check the source really start of a float boundary.
Expand All @@ -46,6 +46,39 @@ void R__zipBLAST(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgt,
memcpy(tgt + kHeaderSize, staging, out_size);
delete [] staging;
*irep = out_size + kHeaderSize;
} else if (cxlevel <= 79) {
// Use "RLE. cx level determines data type
// Note: We need to check the source really start of a boundary.
// Note: We need to upgrade blast to avoid the memcpy (which is IN ADDITION to an internal copy already!!!)
char *staging = nullptr;
// out_size = blast2_compress<T,true>((T*)src, *srcsize, staging);
if (cxlevel == 72) {
out_size = blast2_compress<char,true>(src, *srcsize, staging);
} else if (cxlevel == 73 && (*srcsize % sizeof(short) == 0)) {
out_size = blast2_compress<short,true>((short*)src, *srcsize, staging);
} else if (cxlevel == 74 && (*srcsize % sizeof(int) == 0)) {
out_size = blast2_compress<int,true>((int*)src, *srcsize, staging);
} else if (cxlevel == 75 && (*srcsize % sizeof(long long) == 0)) {
out_size = blast2_compress<long long,true>((long long*)src, *srcsize, staging);
} else if (cxlevel == 76) {
out_size = blast2_compress<unsigned char,true>((unsigned char*) src, *srcsize, staging);
} else if (cxlevel == 77 && (*srcsize % sizeof(unsigned short) == 0)) {
out_size = blast2_compress<unsigned short,true>((unsigned short*)src, *srcsize, staging);
} else if (cxlevel == 78 && (*srcsize % sizeof(unsigned int) == 0)) {
out_size = blast2_compress<unsigned int,true>((unsigned int*)src, *srcsize, staging);
} else if (cxlevel == 79 && (*srcsize % sizeof(unsigned long long) == 0)) {
out_size = blast2_compress<unsigned long long,true>((unsigned long long*)src, *srcsize, staging);
} else {
// not proper length
return;
}
if ( (out_size + kHeaderSize) > (size_t)*tgtsize ) {
delete [] staging;
return;
}
memcpy(tgt + kHeaderSize, staging, out_size);
delete [] staging;
*irep = out_size + kHeaderSize;
} else {
// Call the other engines
return;
Expand Down Expand Up @@ -74,13 +107,38 @@ void R__unzipBLAST(int *srcsize, unsigned char *src, int *tgtsize, unsigned char

auto cxlevel = src[2];

size_t out_size;

if (cxlevel <= 71) {
// Use "absSense". We shift the request config from [1,71] to [-60, 10]
auto absSensLevel = cxlevel - 61;
// Note: We need to check the destination really start of a float boundary.
float *staging = nullptr;
size_t float_size = blast1_decompress<true>(absSensLevel, (char*)(&src[kHeaderSize]), *srcsize, staging);
size_t out_size = float_size * 4;
out_size = float_size * sizeof(float);
// Note: We need to upgrade blast to avoid the memcpy
if ( out_size > (size_t)*tgtsize ) {
delete [] staging;
return;
}
memcpy(tgt, staging, out_size);
delete [] staging;
*irep = out_size;
} else if (cxlevel <= 79) {
// Use "RLE. cx level determines data type
// Note: We need to check the destination really start of a short boundary.
char *staging = nullptr;
char*& stagingPtr = staging;
switch (cxlevel) {
case (79) : out_size = blast2_decompress<unsigned long long,true>((char*)(&src[kHeaderSize]), *srcsize, (unsigned long long*&) stagingPtr); break;
case (78) : out_size = blast2_decompress<unsigned int,true>((char*)(&src[kHeaderSize]), *srcsize, (unsigned int*&) stagingPtr); break;
case (77) : out_size = blast2_decompress<unsigned short,true>((char*)(&src[kHeaderSize]), *srcsize, (unsigned short*&) stagingPtr); break;
case (76) : out_size = blast2_decompress<unsigned char,true>((char*)(&src[kHeaderSize]), *srcsize, (unsigned char*&) stagingPtr);
case (75) : out_size = blast2_decompress<long long,true>((char*)(&src[kHeaderSize]), *srcsize, (long long*&) stagingPtr); break;
case (74) : out_size = blast2_decompress<int,true>((char*)(&src[kHeaderSize]), *srcsize, (int*&) stagingPtr); break;
case (73) : out_size = blast2_decompress<short,true>((char*)(&src[kHeaderSize]), *srcsize, (short*&) stagingPtr); break;
default : out_size = blast2_decompress<char,true>((char*)(&src[kHeaderSize]), *srcsize, staging);
}
// Note: We need to upgrade blast to avoid the memcpy
if ( out_size > (size_t)*tgtsize ) {
delete [] staging;
Expand All @@ -89,7 +147,6 @@ void R__unzipBLAST(int *srcsize, unsigned char *src, int *tgtsize, unsigned char
memcpy(tgt, staging, out_size);
delete [] staging;
*irep = out_size;

} else {
// Need to handle the other engine
return;
Expand Down