source: icGREP/icgrep-devel/icgrep/kernels/lz4/lz4_index_builder.h @ 5921

Last change on this file since 5921 was 5921, checked in by xwa163, 13 months ago
  1. Initial checkin for new approach for lz4 index decoder that always use 4MB buffer
  2. Add test case for new approach (for now test cases will fail when test file is larger than 4MB)
File size: 2.9 KB
Line 
1//
2// Created by wxy325 on 2018/3/16.
3//
4
5#ifndef ICGREP_LZ4_INDEX_BUILDER_H
6#define ICGREP_LZ4_INDEX_BUILDER_H
7
8#include "kernels/kernel.h"
9#include <string>
10
11namespace llvm {
12    class Module;
13    class Function;
14    class BasicBlock;
15    class Value;
16}
17
18namespace IDISA { class IDISA_Builder; }
19
20namespace kernel {
21    class LZ4IndexBuilderKernel final : public MultiBlockKernel {
22    public:
23        LZ4IndexBuilderKernel(const std::unique_ptr<kernel::KernelBuilder> &iBuilder);
24
25    protected:
26        void generateMultiBlockLogic(const std::unique_ptr<KernelBuilder> &iBuilder,
27                                     llvm::Value *const numOfStrides) override;
28
29    private:
30        llvm::Value * generateLoadCircularInput(const std::unique_ptr<KernelBuilder> &iBuilder, std::string inputBufferName,
31                                                         llvm::Value *offset, llvm::Type *pointerType);
32        void generateProcessCompressedBlock(const std::unique_ptr<KernelBuilder> &iBuilder, llvm::Value* blockStart, llvm::Value* blockEnd);
33
34        llvm::Value *generateLoadSourceInputByte(const std::unique_ptr<KernelBuilder> &iBuilder, llvm::Value *offset);
35
36        llvm::Value *advanceUntilNextZero(const std::unique_ptr<KernelBuilder> &iBuilder, std::string inputName, llvm::Value* startPos, llvm::Value* maxPos = nullptr);
37        llvm::Value *advanceUntilNextOne(const std::unique_ptr<KernelBuilder> &iBuilder, std::string inputName, llvm::Value* startPos, llvm::Value* maxPos = nullptr);
38        llvm::Value *advanceUntilNextValue(const std::unique_ptr<KernelBuilder> &iBuilder, std::string inputName, llvm::Value* startPos, bool isNextZero, llvm::Value* maxPos = nullptr);
39        void increaseScalarField(const std::unique_ptr<KernelBuilder> &iBuilder, const std::string &fieldName, llvm::Value *value);
40        llvm::Value* processLiteral(const std::unique_ptr<KernelBuilder> &iBuilder, llvm::Value* token, llvm::Value* tokenPos, llvm::Value* blockEnd);
41        llvm::Value* processMatch(const std::unique_ptr<KernelBuilder> &iBuilder, llvm::Value* offsetPos, llvm::Value* token, llvm::Value* blockEnd);
42
43
44        size_t getOutputBufferSize(const std::unique_ptr<KernelBuilder> &iBuilder, std::string bufferName);
45        llvm::BasicBlock *markCircularOutputBitstream(const std::unique_ptr<KernelBuilder> &iBuilder,
46                                                                             const std::string &bitstreamName,
47                                                                             llvm::Value *start, llvm::Value *end, bool isOne,
48                                                                             bool setProduced = true);
49        void generateStoreCircularOutput(const std::unique_ptr<KernelBuilder> &iBuilder, std::string outputBufferName, llvm::Type* pointerType, llvm::Value* value);
50
51        llvm::Value* previousE1Produced ;
52    };
53}
54
55
56#endif //ICGREP_LZ4_INDEX_BUILDER_H
Note: See TracBrowser for help on using the repository browser.