source: icGREP/icgrep-devel/icgrep/lz4/LZ4Generator.h @ 6136

Last change on this file since 6136 was 6136, checked in by xwa163, 11 months ago
  1. Cleanup legacy slow LZ4 related kernels
  2. Rename lz4d_ext_dep to lz4_decompression
  3. Rename LZ4 AIO related kernels to LZ4 Decompression Kernel
File size: 2.6 KB
Line 
1
2#ifndef ICGREP_LZ4GENERATOR_H
3#define ICGREP_LZ4GENERATOR_H
4#include <llvm/IR/Module.h>
5#include <llvm/IR/Function.h>
6
7#include <llvm/Support/Signals.h>
8#include <llvm/Support/ManagedStatic.h>
9#include <IR_Gen/idisa_target.h>
10
11#include <toolchain/toolchain.h>
12
13#include <toolchain/cpudriver.h>
14#include <string>
15
16namespace re { class CC; }
17
18
19typedef void (*MainFunctionType)(char * byte_data, size_t headerSize, size_t filesize, bool hasBlockChecksum);
20
21struct LZ4BlockInfo {
22    parabix::StreamSetBuffer* blockStart;
23    parabix::StreamSetBuffer* blockEnd;
24    parabix::StreamSetBuffer* isCompress;
25};
26
27class LZ4Generator {
28
29public:
30    LZ4Generator();
31    MainFunctionType getMainFunc();
32
33    void generateDecompressionPipeline(const std::string &outputFile);
34protected:
35
36    //// Protected Method
37    std::vector<parabix::StreamSetBuffer*> convertCompressedBitsStreamWithBitStreamAioApproach(
38            std::vector<parabix::StreamSetBuffer*> compressedBitStreams, std::string prefix);
39
40    void generateMainFunc(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
41    // Pipeline
42    virtual void generateLoadByteStream(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
43    virtual void generateLoadByteStreamAndBitStream(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
44    virtual parabix::StreamSetBuffer * generateParallelAIODecompression(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, bool enableGather, bool enableScatter, int minParallelLevel);
45    virtual parabix::StreamSetBuffer * generateAIODecompression(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
46    virtual parabix::StreamSetBuffer * generateSwizzledAIODecompression(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
47    virtual parabix::StreamSetBuffer * generateBitStreamAIODecompression(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
48
49    // BufferSize related Helper Function
50    virtual int getInputBufferBlocks(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
51    virtual int getDecompressedBufferBlocks(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
52    int get4MbBufferBlocks();
53
54
55    //// Data Member
56    // Driver
57    ParabixDriver mPxDriver;
58
59    // Runtime Arguments
60    llvm::Value * mInputStream;
61    llvm::Value * mHeaderSize;
62    llvm::Value * mFileSize;
63    llvm::Value * mHasBlockChecksum;
64
65    // StreamSetBuffers
66    parabix::StreamSetBuffer * mCompressedByteStream;
67    parabix::StreamSetBuffer * mCompressedBasisBits;
68
69    unsigned mLz4BlockSize;
70
71    LZ4BlockInfo getBlockInfo(const std::unique_ptr<kernel::KernelBuilder> & b);
72};
73
74
75#endif //ICGREP_LZ4GENERATOR_H
Note: See TracBrowser for help on using the repository browser.