Ignore:
Timestamp:
Apr 6, 2017, 6:26:03 PM (2 years ago)
Author:
cameron
Message:

Update base64 and radix64 kernels for Parabix Driver and object cache system

File:
1 edited

Legend:

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

    r5377 r5396  
    3737using namespace parabix;
    3838
    39 Function * base64Pipeline(Module * mMod, IDISA::IDISA_Builder * iBuilder) {
     39void base64PipelineGen(ParabixDriver & pxDriver) {
     40       
     41    IDISA::IDISA_Builder * iBuilder = pxDriver.getIDISA_Builder();
     42    Module * mod = iBuilder->getModule();
    4043    Type * mBitBlockType = iBuilder->getBitBlockType();
    4144
    4245    Type * const size_ty = iBuilder->getSizeTy();
    43     Type * const voidTy = Type::getVoidTy(mMod->getContext());
     46    Type * const voidTy = Type::getVoidTy(mod->getContext());
    4447    Type * const inputType = PointerType::get(ArrayType::get(ArrayType::get(mBitBlockType, 8), 1), 0);
    4548    Type * const outputType = PointerType::get(ArrayType::get(ArrayType::get(mBitBlockType, 8), 1), 0);
    4649   
    4750   
    48     Function * const main = cast<Function>(mMod->getOrInsertFunction("Main", voidTy, inputType, outputType, size_ty, nullptr));
     51    Function * const main = cast<Function>(mod->getOrInsertFunction("Main", voidTy, inputType, outputType, size_ty, nullptr));
    4952    main->setCallingConv(CallingConv::C);
    5053    Function::arg_iterator args = main->arg_begin();
     
    6972   
    7073    MMapSourceKernel mmapK(iBuilder, segmentSize);
    71     mmapK.generateKernel({}, {&ByteStream});
    7274    mmapK.setInitialArguments({fileSize});
    73        
     75    pxDriver.addKernelCall(mmapK, {}, {&ByteStream});
     76   
    7477    expand3_4Kernel expandK(iBuilder);
    75     expandK.generateKernel({&ByteStream}, {&Expanded3_4Out});
     78    pxDriver.addKernelCall(expandK, {&ByteStream}, {&Expanded3_4Out});
    7679
    7780    radix64Kernel radix64K(iBuilder);
    78     radix64K.generateKernel({&Expanded3_4Out}, {&Radix64out});
     81    pxDriver.addKernelCall(radix64K, {&Expanded3_4Out}, {&Radix64out});
    7982
    8083    base64Kernel base64K(iBuilder);
    81     base64K.generateKernel({&Radix64out}, {&Base64out});
     84    pxDriver.addKernelCall(base64K, {&Radix64out}, {&Base64out});
    8285   
    8386    StdOutKernel stdoutK(iBuilder, 8);
    84     stdoutK.generateKernel({&Base64out}, {});
     87    pxDriver.addKernelCall(stdoutK, {&Base64out}, {});
    8588   
    86     iBuilder->SetInsertPoint(BasicBlock::Create(mMod->getContext(), "entry", main,0));
     89    iBuilder->SetInsertPoint(BasicBlock::Create(mod->getContext(), "entry", main,0));
    8790
    8891    ByteStream.setStreamSetBuffer(inputStream);
     
    9194    Base64out.allocateBuffer();
    9295
    93     generatePipeline(iBuilder, {&mmapK, &expandK, &radix64K, &base64K, &stdoutK});
     96    pxDriver.generatePipelineIR();
    9497
    9598    iBuilder->CreateRetVoid();
    96     return main;
     99    pxDriver.JITcompileMain();
     100    pxDriver.linkAndFinalize();
    97101}
    98102
     
    100104typedef void (*base64FunctionType)(char * byte_data, char * output_data, size_t filesize);
    101105
    102 static ExecutionEngine * base64Engine = nullptr;
    103 
    104106base64FunctionType base64CodeGen(void) {
    105107    LLVMContext TheContext;                           
    106108    Module * M = new Module("base64", TheContext);
    107109    IDISA::IDISA_Builder * idb = IDISA::GetIDISA_Builder(M);
    108 
     110    ParabixDriver pxDriver(idb);
    109111   
    110     llvm::Function * main_IR = base64Pipeline(M, idb);
     112    base64PipelineGen(pxDriver);
     113    base64FunctionType main = reinterpret_cast<base64FunctionType>(pxDriver.getPointerToMain());
    111114   
    112     verifyModule(*M, &dbgs());
    113     //std::cerr << "ExecuteKernels(); done\n";
    114     base64Engine = JIT_to_ExecutionEngine(M);
    115    
    116     base64Engine->finalizeObject();
    117     //std::cerr << "finalizeObject(); done\n";
    118 
    119115    delete idb;
    120     return reinterpret_cast<base64FunctionType>(base64Engine->getPointerToFunction(main_IR));
     116    return main;
    121117}
    122118
     
    155151        outputBuffer.advise(boost::interprocess::mapped_region::advice_willneed);
    156152        outputBuffer.advise(boost::interprocess::mapped_region::advice_sequential);
    157         std::cerr << "outputBuffer " << std::hex << (intptr_t)(outputBuffer.get_address()) << std::dec << "\n";
    158153        fn_ptr(mFileBuffer, static_cast<char*>(outputBuffer.get_address()), mFileSize);
    159154    }
Note: See TracChangeset for help on using the changeset viewer.