Changeset 5874


Ignore:
Timestamp:
Feb 19, 2018, 6:19:24 PM (9 months ago)
Author:
xwa163
Message:
  1. Add Debug option “extract-and-deposit-only” for lz4_ext_dep
  2. Use MultiplePdepKernel? in LZ4Generator
Location:
icGREP/icgrep-devel/icgrep
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/lz4/LZ4Generator.cpp

    r5865 r5874  
    2727#include <kernels/swizzle.h>
    2828#include <kernels/pdep_kernel.h>
     29#include <kernels/lz4/lz4_multiple_pdep_kernel.h>
    2930#include <kernels/lz4/lz4_match_copy_kernel.h>
    3031
     
    5455    this->generateLoadByteStreamAndBitStream(iBuilder);
    5556
    56 
    5757    this->generateExtractAndDepositMarkers(iBuilder);
    5858
     
    8585}
    8686
    87 void LZ4Generator::generatePipeline(const std::string& outputFile) {
     87void LZ4Generator::generateExtractAndDepositOnlyPipeline(const std::string &outputFile) {
    8888    auto & iBuilder = pxDriver.getBuilder();
    8989    this->generateMainFunc(iBuilder);
    9090
    9191    StreamSetBuffer * const DecompressedByteStream = pxDriver.addBuffer<CircularBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 8), this->getDecompressedBufferBlocks());
    92   //  StreamSetBuffer * const FinalDecompressedByteStream = pxDriver.addBuffer<CircularBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 8), this->getDecompressedBufferBlocks());
     92    StreamSetBuffer * const FinalDecompressedByteStream = pxDriver.addBuffer<CircularBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 8), this->getDecompressedBufferBlocks());
    9393
    9494
     
    100100    auto swizzle = this->generateSwizzleExtractData(iBuilder);
    101101
    102     StreamSetBuffer * depositedSwizzle0 = this->generateDepositData(iBuilder, swizzle.first);
    103     StreamSetBuffer * depositedSwizzle1 = this->generateDepositData(iBuilder, swizzle.second);
     102    StreamSetBuffer * depositedSwizzle0 = pxDriver.addBuffer<SwizzledCopybackBuffer>(iBuilder, iBuilder->getStreamSetTy(4), this->getInputBufferBlocks(), 1);
     103    StreamSetBuffer * depositedSwizzle1 = pxDriver.addBuffer<SwizzledCopybackBuffer>(iBuilder, iBuilder->getStreamSetTy(4), this->getInputBufferBlocks(), 1);
     104
     105    Kernel * multiplePdepK = pxDriver.addKernelInstance<LZ4MultiplePDEPkernel>(iBuilder, 4, 2, 4);
     106    pxDriver.makeKernelCall(multiplePdepK, {DepositMarker, swizzle.first, swizzle.second}, {depositedSwizzle0, depositedSwizzle1});
    104107
    105108    // Produce unswizzled bit streams
     
    114117    Kernel * p2sK = pxDriver.addKernelInstance<P2SKernel>(iBuilder);
    115118    pxDriver.makeKernelCall(p2sK, {extractedbits}, {DecompressedByteStream});
    116 
    117 //    Kernel * matchCopyK = pxDriver.addKernelInstance<LZ4MatchCopyKernel>(iBuilder);
    118 //    pxDriver.makeKernelCall(matchCopyK, {DecompressedByteStream, M0_Start, M0_End, Match_Offset}, {FinalDecompressedByteStream});
    119119
    120120    // --------------------------------------------------------
     
    123123    outK->setInitialArguments({iBuilder->GetString(outputFile)});
    124124    pxDriver.makeKernelCall(outK, {DecompressedByteStream}, {});
     125
     126    pxDriver.generatePipelineIR();
     127    pxDriver.deallocateBuffers();
     128
     129    iBuilder->CreateRetVoid();
     130
     131    pxDriver.finalizeObject();
     132}
     133
     134void LZ4Generator::generatePipeline(const std::string& outputFile) {
     135    auto & iBuilder = pxDriver.getBuilder();
     136    this->generateMainFunc(iBuilder);
     137
     138    StreamSetBuffer * const DecompressedByteStream = pxDriver.addBuffer<CircularBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 8), this->getDecompressedBufferBlocks());
     139    StreamSetBuffer * const FinalDecompressedByteStream = pxDriver.addBuffer<CircularBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 8), this->getDecompressedBufferBlocks());
     140
     141
     142
     143    // GeneratePipeline
     144    this->generateLoadByteStreamAndBitStream(iBuilder);
     145    this->generateExtractAndDepositMarkers(iBuilder);
     146
     147    auto swizzle = this->generateSwizzleExtractData(iBuilder);
     148
     149    StreamSetBuffer * depositedSwizzle0 = pxDriver.addBuffer<SwizzledCopybackBuffer>(iBuilder, iBuilder->getStreamSetTy(4), this->getInputBufferBlocks(), 1);
     150    StreamSetBuffer * depositedSwizzle1 = pxDriver.addBuffer<SwizzledCopybackBuffer>(iBuilder, iBuilder->getStreamSetTy(4), this->getInputBufferBlocks(), 1);
     151
     152    Kernel * multiplePdepK = pxDriver.addKernelInstance<LZ4MultiplePDEPkernel>(iBuilder, 4, 2, 4);
     153    pxDriver.makeKernelCall(multiplePdepK, {DepositMarker, swizzle.first, swizzle.second}, {depositedSwizzle0, depositedSwizzle1});
     154
     155    // Produce unswizzled bit streams
     156    StreamSetBuffer * extractedbits = pxDriver.addBuffer<CircularBuffer>(iBuilder, iBuilder->getStreamSetTy(8), this->getInputBufferBlocks());
     157    Kernel * unSwizzleK = pxDriver.addKernelInstance<SwizzleGenerator>(iBuilder, 8, 1, 2);
     158    pxDriver.makeKernelCall(unSwizzleK, {depositedSwizzle0, depositedSwizzle1}, {extractedbits});
     159
     160//    pxDriver.makeKernelCall(unSwizzleK, {u16Swizzle0, u16Swizzle1}, {extractedbits});
     161
     162    // TODO MatchCopy before p2s
     163
     164    Kernel * p2sK = pxDriver.addKernelInstance<P2SKernel>(iBuilder);
     165    pxDriver.makeKernelCall(p2sK, {extractedbits}, {DecompressedByteStream});
     166
     167    Kernel * matchCopyK = pxDriver.addKernelInstance<LZ4MatchCopyKernel>(iBuilder);
     168    pxDriver.makeKernelCall(matchCopyK, {DecompressedByteStream, M0_Start, M0_End, Match_Offset}, {FinalDecompressedByteStream});
     169
     170    // --------------------------------------------------------
     171    // End
     172    Kernel * outK = pxDriver.addKernelInstance<FileSink>(iBuilder, 8);
     173    outK->setInitialArguments({iBuilder->GetString(outputFile)});
     174    pxDriver.makeKernelCall(outK, {FinalDecompressedByteStream}, {});
    125175
    126176    pxDriver.generatePipelineIR();
     
    262312}
    263313
    264 StreamSetBuffer* LZ4Generator::generateDepositData(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, StreamSetBuffer* swizzleBuffer) {
    265     //TODO buffer blocks here may be incorrect
    266     StreamSetBuffer * depositedSwizzle0 = pxDriver.addBuffer<SwizzledCopybackBuffer>(iBuilder, iBuilder->getStreamSetTy(4), this->getInputBufferBlocks(), 1); //TODO buffer blocks here may be incorrect
    267     Kernel * pdep1K = pxDriver.addKernelInstance<PDEPkernel>(iBuilder, 4, 4);
    268     pxDriver.makeKernelCall(pdep1K, {DepositMarker, swizzleBuffer}, {depositedSwizzle0});
    269     return depositedSwizzle0;
    270 }
    271 
    272314std::pair<StreamSetBuffer*, StreamSetBuffer*> LZ4Generator::generateSwizzleExtractData(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) {
    273315    StreamSetBuffer * u16Swizzle0 = pxDriver.addBuffer<SwizzledCopybackBuffer>(iBuilder, iBuilder->getStreamSetTy(4), this->getInputBufferBlocks(), 1);
  • icGREP/icgrep-devel/icgrep/lz4/LZ4Generator.h

    r5864 r5874  
    2828    void generatePipeline(const std::string& outputFile);
    2929    void generateExtractOnlyPipeline(const std::string& outputFile);
     30    void generateExtractAndDepositOnlyPipeline(const std::string& outputFile);
    3031
    3132private:
     
    3637    inline void generateExtractAndDepositMarkers(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
    3738    inline std::pair<parabix::StreamSetBuffer*, parabix::StreamSetBuffer*> generateSwizzleExtractData(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
    38     inline parabix::StreamSetBuffer* generateDepositData(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, parabix::StreamSetBuffer* swizzleBuffer);
    3939
    4040    // BufferSize related Helper Function
  • icGREP/icgrep-devel/icgrep/lz4d_ext_dep.cpp

    r5864 r5874  
    4141static cl::OptionCategory lz4dDebugFlags("LZ4D Debug Flags", "lz4d debug options");
    4242static cl::opt<bool> extractOnly("extract-only", cl::desc("Only extract literal data to output file"), cl::init(false), cl::cat(lz4dDebugFlags));
     43static cl::opt<bool> extractAndDepositOnly("extract-and-deposit-only", cl::desc("Only extract and deposit literal data to output file"), cl::init(false), cl::cat(lz4dDebugFlags));
    4344
    4445
     
    8283    if (extractOnly) {
    8384        g.generateExtractOnlyPipeline(outputFile);
     85    } else if (extractAndDepositOnly) {
     86        g.generateExtractAndDepositOnlyPipeline(outputFile);
    8487    } else {
    8588        g.generatePipeline(outputFile);
Note: See TracChangeset for help on using the changeset viewer.