Ignore:
Timestamp:
Apr 6, 2017, 4:14:34 PM (2 years ago)
Author:
cameron
Message:

Uniquify kernel names with buffer types/sizes; update u8u16 to use ParabixDriver?

File:
1 edited

Legend:

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

    r5377 r5395  
    254254}
    255255
    256 Function * u8u16PipelineAVX2(Module * mod, IDISA::IDISA_Builder * iBuilder) {
    257 
     256void u8u16PipelineAVX2Gen(ParabixDriver & pxDriver) {
     257
     258    IDISA::IDISA_Builder * iBuilder = pxDriver.getIDISA_Builder();
     259    Module * mod = iBuilder->getModule();
    258260    const unsigned segmentSize = codegen::SegmentSize;
    259261    const unsigned bufferSegments = codegen::ThreadNum+1;
     
    282284
    283285    MMapSourceKernel mmapK(iBuilder, segmentSize);
    284     mmapK.generateKernel({}, {&ByteStream});
    285286    mmapK.setInitialArguments({fileSize});
    286    
     287    pxDriver.addKernelCall(mmapK, {}, {&ByteStream});
     288
    287289    // Transposed bits from s2p
    288290    CircularBuffer BasisBits(iBuilder, iBuilder->getStreamSetTy(8), segmentSize * bufferSegments);
    289291
    290292    S2PKernel s2pk(iBuilder);
    291     s2pk.generateKernel({&ByteStream}, {&BasisBits});
     293    pxDriver.addKernelCall(s2pk, {&ByteStream}, {&BasisBits});
    292294   
    293295    // Calculate UTF-16 data bits through bitwise logic on u8-indexed streams.
     
    303305   
    304306    u8u16_pablo(&u8u16k);
    305     u8u16k.generateKernel({&BasisBits}, {&U8u16Bits, &DelMask, &ErrorMask});
     307    pxDriver.addKernelCall(u8u16k, {&BasisBits}, {&U8u16Bits, &DelMask, &ErrorMask});
    306308
    307309    // Apply a deletion algorithm to discard all but the final position of the UTF-8
     
    314316
    315317    DeleteByPEXTkernel delK(iBuilder, 64, 16, true);
    316     delK.generateKernel({&U8u16Bits, &DelMask}, {&SwizzleFields0, &SwizzleFields1, &SwizzleFields2, &SwizzleFields3, &DeletionCounts});
     318    pxDriver.addKernelCall(delK, {&U8u16Bits, &DelMask}, {&SwizzleFields0, &SwizzleFields1, &SwizzleFields2, &SwizzleFields3, &DeletionCounts});
    317319;
    318320    //  Produce fully compressed swizzled UTF-16 bit streams
     
    323325
    324326    SwizzledBitstreamCompressByCount compressK(iBuilder, 16);
    325     compressK.generateKernel({&DeletionCounts, &SwizzleFields0, &SwizzleFields1, &SwizzleFields2, &SwizzleFields3},
     327    pxDriver.addKernelCall(compressK, {&DeletionCounts, &SwizzleFields0, &SwizzleFields1, &SwizzleFields2, &SwizzleFields3},
    326328                             {&u16Swizzle0, &u16Swizzle1, &u16Swizzle2, &u16Swizzle3});
    327329 
     
    330332    SwizzleGenerator unSwizzleK(iBuilder, 16, 1, 4);
    331333    unSwizzleK.setName("unswizzle");
    332     unSwizzleK.generateKernel({&u16Swizzle0, &u16Swizzle1, &u16Swizzle2, &u16Swizzle3}, {&u16bits});
     334    pxDriver.addKernelCall(unSwizzleK, {&u16Swizzle0, &u16Swizzle1, &u16Swizzle2, &u16Swizzle3}, {&u16bits});
    333335   
    334336    // Different choices for the output buffer depending on chosen option.
     
    342344    FileSink outK(iBuilder, 16);
    343345    if (mMapBuffering || memAlignBuffering) {
    344         p2sk.generateKernel({&u16bits}, {&U16external});
    345         outK.generateKernel({&U16external}, {});
     346        pxDriver.addKernelCall(p2sk, {&u16bits}, {&U16external});
     347        pxDriver.addKernelCall(outK, {&U16external}, {});
    346348    } else {
    347         p2sk.generateKernel({&u16bits}, {&U16out});
    348         outK.generateKernel({&U16out}, {});
     349        pxDriver.addKernelCall(p2sk, {&u16bits}, {&U16out});
     350        pxDriver.addKernelCall(outK, {&U16out}, {});
    349351    }
    350352   
     
    375377    outK.setInitialArguments({fName});
    376378
    377     generatePipeline(iBuilder, {&mmapK, &s2pk, &u8u16k, &delK, &compressK, &unSwizzleK, &p2sk, &outK});
     379    pxDriver.generatePipelineIR();
    378380
    379381    iBuilder->CreateRetVoid();
    380     return main;
     382    pxDriver.JITcompileMain();
     383    pxDriver.linkAndFinalize();
    381384}
    382385
    383 
    384 Function * u8u16Pipeline(Module * mod, IDISA::IDISA_Builder * iBuilder) {
     386void u8u16PipelineGen(ParabixDriver & pxDriver) {
     387   
     388    IDISA::IDISA_Builder * iBuilder = pxDriver.getIDISA_Builder();
     389    Module * mod = iBuilder->getModule();
    385390   
    386391    const unsigned segmentSize = codegen::SegmentSize;
     
    423428   
    424429    MMapSourceKernel mmapK(iBuilder, segmentSize);
    425     mmapK.generateKernel({}, {&ByteStream});
    426430    mmapK.setInitialArguments({fileSize});
     431    pxDriver.addKernelCall(mmapK, {}, {&ByteStream});
    427432   
    428433    S2PKernel s2pk(iBuilder);
    429    
    430     s2pk.generateKernel({&ByteStream}, {&BasisBits});
     434    pxDriver.addKernelCall(s2pk, {&ByteStream}, {&BasisBits});
    431435   
    432436    PabloKernel u8u16k(iBuilder, "u8u16",
     
    437441   
    438442    u8u16_pablo(&u8u16k);
    439    
    440     u8u16k.generateKernel({&BasisBits}, {&U8u16Bits, &DelMask, &ErrorMask});
     443    pxDriver.addKernelCall(u8u16k, {&BasisBits}, {&U8u16Bits, &DelMask, &ErrorMask});
    441444   
    442445    DeletionKernel delK(iBuilder, iBuilder->getBitBlockWidth()/16, 16);
    443     delK.generateKernel({&U8u16Bits, &DelMask}, {&U16Bits, &DeletionCounts});
     446    pxDriver.addKernelCall(delK, {&U8u16Bits, &DelMask}, {&U16Bits, &DeletionCounts});
    444447   
    445448    P2S16KernelWithCompressedOutput p2sk(iBuilder);
     
    447450    FileSink outK(iBuilder, 16);
    448451    if (mMapBuffering || memAlignBuffering) {
    449         p2sk.generateKernel({&U16Bits, &DeletionCounts}, {&U16external});
    450         outK.generateKernel({&U16external}, {});
     452        pxDriver.addKernelCall(p2sk, {&U16Bits, &DeletionCounts}, {&U16external});
     453        pxDriver.addKernelCall(outK, {&U16external}, {});
    451454    } else {
    452         p2sk.generateKernel({&U16Bits, &DeletionCounts}, {&U16out});
    453         outK.generateKernel({&U16out}, {});
     455        pxDriver.addKernelCall(p2sk, {&U16Bits, &DeletionCounts}, {&U16out});
     456        pxDriver.addKernelCall(outK, {&U16out}, {});
    454457    }
    455458    iBuilder->SetInsertPoint(BasicBlock::Create(mod->getContext(), "entry", main,0));
     
    470473    outK.setInitialArguments({fName});
    471474   
    472     generatePipeline(iBuilder, {&mmapK, &s2pk, &u8u16k, &delK, &p2sk, &outK});
     475    pxDriver.generatePipelineIR();
     476
    473477   
    474478    iBuilder->CreateRetVoid();
    475     return main;
     479    pxDriver.JITcompileMain();
     480    pxDriver.linkAndFinalize();
    476481}
    477482
     
    479484
    480485typedef void (*u8u16FunctionType)(char * byte_data, char * output_data, size_t filesize);
    481 
    482 static ExecutionEngine * u8u16Engine = nullptr;
    483486
    484487u8u16FunctionType u8u16CodeGen(void) {
     
    486489    Module * M = new Module("u8u16", TheContext);
    487490    IDISA::IDISA_Builder * idb = IDISA::GetIDISA_Builder(M);
    488 
    489     llvm::Function * main_IR = (enableAVXdel && AVX2_available() && codegen::BlockSize==256) ? u8u16PipelineAVX2(M, idb) : u8u16Pipeline(M, idb);
    490 
    491     verifyModule(*M, &dbgs());
    492     u8u16Engine = JIT_to_ExecutionEngine(M);   
    493     u8u16Engine->finalizeObject();
     491    ParabixDriver pxDriver(idb);
     492   
     493    if (enableAVXdel && AVX2_available() && codegen::BlockSize==256) {
     494        //u8u16PipelineAVX2(M, idb)
     495        u8u16PipelineAVX2Gen(pxDriver);
     496    }
     497    else{
     498        //u8u16Pipeline(M, idb);
     499        u8u16PipelineGen(pxDriver);
     500    }
     501    u8u16FunctionType main = reinterpret_cast<u8u16FunctionType>(pxDriver.getPointerToMain());
    494502
    495503    delete idb;
    496     return reinterpret_cast<u8u16FunctionType>(u8u16Engine->getPointerToFunction(main_IR));
     504    return main;
    497505}
    498506
Note: See TracChangeset for help on using the changeset viewer.