source: icGREP/icgrep-devel/icgrep/lz4/grep/lz4_grep_swizzle_generator.cpp @ 6143

Last change on this file since 6143 was 6143, checked in by xwa163, 10 months ago

lz4_grep: some bug fixing and refactor

File size: 2.9 KB
Line 
1
2#include "lz4_grep_swizzle_generator.h"
3#include <kernels/swizzle.h>
4#include <kernels/lz4/decompression/lz4_swizzled_decompression.h>
5#include <kernels/kernel_builder.h>
6
7using namespace parabix;
8using namespace kernel;
9
10StreamSetBuffer *LZ4GrepSwizzleGenerator::generateUncompressedBitStreams() {
11    StreamSetBuffer *compressedByteStream = nullptr, *compressedBasisBits = nullptr;
12    std::tie(compressedByteStream, compressedBasisBits) = this->loadByteStreamAndBitStream();
13    return this->swizzledDecompression(compressedByteStream, compressedBasisBits);
14}
15
16StreamSetBuffer *LZ4GrepSwizzleGenerator::decompressBitStream(parabix::StreamSetBuffer *compressedByteStream,
17                                                                       parabix::StreamSetBuffer *compressedBitStream) {
18    return this->convertCompressedBitsStreamWithSwizzledAioApproach(compressedByteStream, compressedBitStream, "combined");
19}
20
21
22StreamSetBuffer * LZ4GrepSwizzleGenerator::convertCompressedBitsStreamWithSwizzledAioApproach(
23        StreamSetBuffer *compressedByteStream,
24        StreamSetBuffer *compressedBitStream,
25        std::string prefix
26) {
27    auto mGrepDriver = &mPxDriver;
28    auto & b = mGrepDriver->getBuilder();
29
30    LZ4BlockInfo blockInfo = this->getBlockInfo(compressedByteStream);
31
32    // Produce unswizzled bit streams
33    StreamSetBuffer * u16Swizzle0 = mPxDriver.addBuffer<StaticBuffer>(b, b->getStreamSetTy(4),
34                                                                      this->getDefaultBufferBlocks(), 1);
35    Kernel * unSwizzleK = mPxDriver.addKernelInstance<SwizzleGenerator>(b, 4, 1, 1, 64, "source");
36    mPxDriver.makeKernelCall(unSwizzleK, {compressedBitStream}, {u16Swizzle0});
37
38    StreamSetBuffer * uncompressedSwizzled0 = mPxDriver.addBuffer<StaticBuffer>(b, b->getStreamSetTy(4),
39                                                                                this->getDefaultBufferBlocks(), 1);
40
41
42    Kernel* lz4AioK = mPxDriver.addKernelInstance<LZ4SwizzledDecompressionKernel>(b, 4, 1, 4);
43    lz4AioK->setInitialArguments({mFileSize});
44    mPxDriver.makeKernelCall(
45            lz4AioK,
46            {
47                    compressedByteStream,
48
49                    // Block Data
50                    blockInfo.isCompress,
51                    blockInfo.blockStart,
52                    blockInfo.blockEnd,
53
54                    u16Swizzle0,
55            }, {
56                    uncompressedSwizzled0,
57            });
58
59
60
61    StreamSetBuffer * const decompressionBitStream = mPxDriver.addBuffer<StaticBuffer>(b, b->getStreamSetTy(8, 1),
62                                                                                       this->getDefaultBufferBlocks(), 1);
63    Kernel * unSwizzleK2 = mPxDriver.addKernelInstance<SwizzleGenerator>(b, 4, 1, 1, 64, "dst");
64    mPxDriver.makeKernelCall(unSwizzleK2, {uncompressedSwizzled0}, {decompressionBitStream});
65
66    return decompressionBitStream;
67
68}
Note: See TracBrowser for help on using the repository browser.