Ignore:
Timestamp:
Apr 4, 2017, 12:09:16 PM (2 years ago)
Author:
cameron
Message:

ParabixDriver/ObjectCache? separate compilation and linking: initial check-in with wc

File:
1 edited

Legend:

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

    r5377 r5391  
    123123}
    124124
    125 Function * pipeline(Module * m, IDISA::IDISA_Builder * iBuilder) {
     125
     126
     127
     128typedef void (*wcFunctionType)(char * byte_data, size_t filesize, size_t fileIdx);
     129
     130void wcPipelineGen(ParabixDriver & pxDriver) {
     131
     132    IDISA::IDISA_Builder * iBuilder = pxDriver.getIDISA_Builder();
     133    Module * m = iBuilder->getModule();
     134   
    126135    Type * mBitBlockType = iBuilder->getBitBlockType();
    127136    Constant * record_counts_routine;
     
    145154
    146155    SingleBlockBuffer BasisBits(iBuilder, iBuilder->getStreamSetTy(8, 1));
    147    
     156    iBuilder->SetInsertPoint(BasicBlock::Create(m->getContext(), "entry", main,0));
     157
    148158    MMapSourceKernel mmapK(iBuilder);
    149     std::unique_ptr<Module> mmapM = mmapK.createKernelModule({}, {&ByteStream});
    150159    mmapK.setInitialArguments({fileSize});
    151    
     160    pxDriver.addKernelCall(mmapK, {}, {&ByteStream});
     161
    152162    S2PKernel  s2pk(iBuilder);
    153     std::unique_ptr<Module> s2pM = s2pk.createKernelModule({&ByteStream}, {&BasisBits});
     163    pxDriver.addKernelCall(s2pk, {&ByteStream}, {&BasisBits});
    154164   
    155165    PabloKernel wck(iBuilder, "wc",
     
    161171    wc_gen(&wck);
    162172    pablo_function_passes(&wck);
    163    
    164     std::unique_ptr<Module> wcM = wck.createKernelModule({&BasisBits}, {});
    165    
    166     mmapK.addKernelDeclarations(m);
    167     s2pk.addKernelDeclarations(m);
    168     wck.addKernelDeclarations(m);
    169    
    170     iBuilder->SetInsertPoint(BasicBlock::Create(m->getContext(), "entry", main,0));
     173    pxDriver.addKernelCall(wck, {&BasisBits}, {});
    171174
    172175    ByteStream.setStreamSetBuffer(inputStream);
    173176    BasisBits.allocateBuffer();
    174    
    175     generatePipeline(iBuilder, {&mmapK, &s2pk, &wck});
     177
     178    pxDriver.generatePipelineIR();
    176179   
    177180    Value * lineCount = wck.createGetAccumulatorCall(wck.getInstance(), "lineCount");
     
    183186    iBuilder->CreateRetVoid();
    184187   
    185     Linker L(*m);
    186     L.linkInModule(std::move(mmapM));
    187     L.linkInModule(std::move(s2pM));
    188     L.linkInModule(std::move(wcM));
    189    
    190     return main;
    191 }
    192 
    193 
    194 typedef void (*wcFunctionType)(char * byte_data, size_t filesize, size_t fileIdx);
    195 
    196 static ExecutionEngine * wcEngine = nullptr;
     188    pxDriver.JITcompileMain();
     189    pxDriver.linkAndFinalize();
     190}
     191
    197192
    198193wcFunctionType wcCodeGen(void) {
    199194    Module * M = new Module("wc", getGlobalContext());
    200195    IDISA::IDISA_Builder * idb = IDISA::GetIDISA_Builder(M);
    201 
    202     llvm::Function * main_IR = pipeline(M, idb);
    203 
    204     wcEngine = JIT_to_ExecutionEngine(M);
    205    
    206     wcEngine->finalizeObject();
    207 
     196    ParabixDriver pxDriver(idb);
     197   
     198    wcPipelineGen(pxDriver);
     199
     200    wcFunctionType main = reinterpret_cast<wcFunctionType>(pxDriver.getPointerToMain());
    208201    delete idb;
    209     return reinterpret_cast<wcFunctionType>(wcEngine->getPointerToFunction(main_IR));
     202    return main;
    210203}
    211204
Note: See TracChangeset for help on using the changeset viewer.