Ignore:
Timestamp:
Aug 1, 2018, 12:22:09 AM (11 months ago)
Author:
xwa163
Message:
  1. LZ4 ScanMatch? pipeline
  2. Refactor LZ4 Generator
  3. Adjust some naming
File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/lz4_decoder.cpp

    r6136 r6137  
    55 */
    66
    7 
    8 #include <llvm/IR/Module.h>
    9 #include <llvm/Linker/Linker.h>
    107#include <llvm/Support/PrettyStackTrace.h>
    11 #include <llvm/Support/Signals.h>
    12 #include <llvm/Support/ManagedStatic.h>
    13 #include <IR_Gen/idisa_target.h>
    14 #include <boost/filesystem.hpp>
    15 #include <boost/iostreams/device/mapped_file.hpp>
    16 
    17 #include <lz4FrameDecoder.h>
    18 #include <cc/cc_compiler.h>
    19 #include <toolchain/toolchain.h>
    20 #include <kernels/cc_kernel.h>
    21 #include <kernels/streamset.h>
    22 #include <kernels/s2p_kernel.h>
    23 #include <kernels/kernel_builder.h>
    24 #include <toolchain/cpudriver.h>
    25 #include <llvm/Support/raw_ostream.h>
    26 #include <iostream>
    27 #include <lz4/LZ4Generator.h>
     8#include <lz4/lz4_decompression_generator.h>
    289
    2910namespace re { class CC; }
    3011
    3112using namespace llvm;
    32 using namespace parabix;
    33 using namespace kernel;
    3413
    3514static cl::OptionCategory lz4dFlags("Command Flags", "lz4d options");
     
    3918
    4019int main(int argc, char *argv[]) {
    41     // This boilerplate provides convenient stack traces and clean LLVM exit
    42     // handling. It also initializes the built in support for convenient
    43     // command line option handling.
    4420    sys::PrintStackTraceOnErrorSignal(argv[0]);
    4521    llvm::PrettyStackTraceProgram X(argc, argv);
    4622    llvm_shutdown_obj shutdown;
    4723    codegen::ParseCommandLineOptions(argc, argv, {&lz4dFlags, codegen::codegen_flags()});
    48     std::string fileName = inputFile;
    49     LZ4FrameDecoder lz4Frame(fileName);
    50     if (!lz4Frame.isValid()) {
    51         llvm::errs() << "Invalid LZ4 file.\n";
    52         return -1;
    53     }
    5424
    55     if (boost::filesystem::exists(outputFile)) {
    56         if (overwriteOutput) {
    57             boost::filesystem::remove(outputFile);
    58         } else {
    59             llvm::errs() << outputFile + " existed. Use -f argument to overwrite.\n";
    60             return -1;
    61         }
    62     }
    63 
    64     boost::iostreams::mapped_file_source mappedFile;
    65     mappedFile.open(fileName, lz4Frame.getBlocksLength() + lz4Frame.getBlocksStart());
    66     char *fileBuffer = const_cast<char *>(mappedFile.data());
    67 
    68     LZ4Generator g;
    69     g.generateDecompressionPipeline(outputFile);
    70 
    71     auto main = g.getMainFunc();
    72     main(fileBuffer, lz4Frame.getBlocksStart(), lz4Frame.getBlocksStart() + lz4Frame.getBlocksLength(), lz4Frame.hasBlockChecksum());
    73     mappedFile.close();
    74 
    75     return 0;
     25    LZ4DecompressionGenerator g;
     26    return g.decompress(std::move(inputFile), std::move(outputFile), overwriteOutput);
    7627}
Note: See TracChangeset for help on using the changeset viewer.