Ignore:
Timestamp:
Mar 15, 2016, 10:20:07 PM (3 years ago)
Author:
nmedfort
Message:

Added the kernel instance class; removed original mmap file access in favour of the boost mmap system. corrected PrintRegister? routine.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/pipeline.cpp

    r4970 r4974  
    1010#include <kernels/scanmatchgen.h>
    1111#include <kernels/s2p_kernel.h>
     12#include <kernels/instance.h>
    1213
    1314#include <pablo/function.h>
    1415#include <pablo/pablo_compiler.h>
    1516
     17
    1618using namespace pablo;
     19using namespace kernel;
    1720
    1821PipelineBuilder::PipelineBuilder(Module * m, IDISA::IDISA_Builder * b)
     
    6366    Function::arg_iterator args = main->arg_begin();
    6467
    65     Value* input_param = args++;
    66     input_param->setName("input");
     68    Value * const inputStream = args++;
     69    inputStream->setName("input");
    6770    Value* buffersize_param = args++;
    6871    buffersize_param->setName("buffersize");   
     
    8487    BasicBlock * pipeline_return_block = BasicBlock::Create(mMod->getContext(), "pipeline_return_block", main, 0);
    8588
    86     Value * s2pKernelStruct = mS2PKernel->generateKernelInstance();
    87     Value * icGrepKernelStruct = mICgrepKernel->generateKernelInstance();
    88     Value * scanMatchKernelStruct = mScanMatchKernel->generateKernelInstance();
     89    Instance * s2pInstance = mS2PKernel->instantiate();
     90    Instance * icGrepInstance = mICgrepKernel->instantiate();
     91    Instance * scanMatchInstance = mScanMatchKernel->instantiate();
    8992
    9093
    91     Value * gep = mScanMatchKernel->getInternalState("FileBuf", scanMatchKernelStruct);
    92     Value * filebuf = iBuilder->CreateBitCast(input_param, S);
     94    Value * gep = scanMatchInstance->getInternalState("FileBuf");
     95    Value * filebuf = iBuilder->CreateBitCast(inputStream, S);
    9396    iBuilder->CreateStore(filebuf, gep);
    9497
    95 
    96     gep = mScanMatchKernel->getInternalState("FileSize", scanMatchKernelStruct);
     98    gep = scanMatchInstance->getInternalState("FileSize");
    9799    iBuilder->CreateStore(buffersize_param, gep);
    98100
    99 
    100     gep = mScanMatchKernel->getInternalState("FileName", scanMatchKernelStruct);
     101    gep = scanMatchInstance->getInternalState("FileName");
    101102    iBuilder->CreateStore(filename_param, gep);
    102103
    103     Value * basis_bits = iBuilder->CreateGEP(s2pKernelStruct, {iBuilder->getInt32(0), iBuilder->getInt32(1)});
    104     Value * results = iBuilder->CreateGEP(icGrepKernelStruct, {iBuilder->getInt32(0), iBuilder->getInt32(1)});
    105  
     104    Value * basis_bits = s2pInstance->getOutputStreamSet();
     105
     106    Value * results = icGrepInstance->getOutputStreamSet();
     107
    106108    iBuilder->CreateBr(pipeline_test_block);
    107109
    108110    iBuilder->SetInsertPoint(pipeline_test_block);
    109     PHINode * remaining_phi = iBuilder->CreatePHI(T, 2, "remaining");   
    110     PHINode * blkNo_phi = iBuilder->CreatePHI(T, 2, "blkNo");
    111     remaining_phi->addIncoming(buffersize_param, entry_block);
    112     blkNo_phi->addIncoming(iBuilder->getInt64(0), entry_block);
     111    PHINode * blockNo = iBuilder->CreatePHI(T, 2, "blockNo");
     112    blockNo->addIncoming(iBuilder->getInt64(0), entry_block);
     113    PHINode * remainingBytes = iBuilder->CreatePHI(T, 2, "remainingBytes");
     114    remainingBytes->addIncoming(buffersize_param, entry_block);
    113115
    114116    Constant * step = ConstantInt::get(T, mBlockSize * mS2PKernel->getSegmentBlocks());
    115117
    116     Value * final_block_cond = iBuilder->CreateICmpSLT(remaining_phi, step);
     118    Value * final_block_cond = iBuilder->CreateICmpSLT(remainingBytes, step);
    117119    iBuilder->CreateCondBr(final_block_cond, pipeline_final_block, pipeline_do_block);
    118120
    119121    iBuilder->SetInsertPoint(pipeline_do_block);
    120122
    121     gep = iBuilder->CreateGEP(input_param, blkNo_phi);
    122     Value * update_blkNo = iBuilder->CreateAdd(blkNo_phi, iBuilder->getInt64(1));
    123     blkNo_phi->addIncoming(update_blkNo, pipeline_do_block);
     123    s2pInstance->call(iBuilder->CreateGEP(inputStream, blockNo));
    124124
    125     mS2PKernel->generateDoBlockCall(gep);
    126     mICgrepKernel->generateDoBlockCall(basis_bits);
    127     mScanMatchKernel->generateDoBlockCall(results);
     125    icGrepInstance->call(basis_bits);
     126    scanMatchInstance->call(results);
    128127
    129     Value * update_remaining = iBuilder->CreateSub(remaining_phi, step);
    130     remaining_phi->addIncoming(update_remaining, pipeline_do_block);
     128    blockNo->addIncoming(iBuilder->CreateAdd(blockNo, iBuilder->getInt64(1)), pipeline_do_block);
     129    Value * update_remaining = iBuilder->CreateSub(remainingBytes, step);
     130    remainingBytes->addIncoming(update_remaining, pipeline_do_block);
    131131    iBuilder->CreateBr(pipeline_test_block);
    132132
    133133    iBuilder->SetInsertPoint(pipeline_final_block);
    134134
    135     Value * empty_block_cond = iBuilder->CreateICmpEQ(remaining_phi, ConstantInt::get(T, 0));
     135    Value * empty_block_cond = iBuilder->CreateICmpEQ(remainingBytes, ConstantInt::get(T, 0));
    136136    iBuilder->CreateCondBr(empty_block_cond, pipeline_empty_block, pipeline_partial_block);
    137137
    138138    iBuilder->SetInsertPoint(pipeline_partial_block);
    139139
    140     gep = iBuilder->CreateGEP(input_param, blkNo_phi);
    141     mS2PKernel->generateDoBlockCall(gep);
     140    s2pInstance->call(iBuilder->CreateGEP(inputStream, blockNo));
     141
    142142    iBuilder->CreateBr(pipeline_end_block);
    143143
     
    154154    iBuilder->SetInsertPoint(pipeline_Unterminated_block);
    155155
    156     Value * remaining = iBuilder->CreateZExt(remaining_phi, iBuilder->getIntNTy(mBlockSize));
     156    Value * remaining = iBuilder->CreateZExt(remainingBytes, iBuilder->getIntNTy(mBlockSize));
    157157    Value * EOF_pos = iBuilder->CreateShl(ConstantInt::get(iBuilder->getIntNTy(mBlockSize), 1), remaining);
    158158    EOF_pos = iBuilder->CreateBitCast(EOF_pos, mBitBlockType);
    159159
    160     Value * gep_bits4 = iBuilder->CreateGEP(basis_bits, {iBuilder->getInt32(0), iBuilder->getInt32(0), iBuilder->getInt32(4)});
    161     Value * bits4 = iBuilder->CreateAlignedLoad(gep_bits4, mBlockSize/8, false, "bits4");
     160    Value * gep_bits4 = s2pInstance->getOutputStream(4);
     161    Value * bits4 = iBuilder->CreateBlockAlignedLoad(gep_bits4);
    162162    bits4 = iBuilder->CreateOr(bits4, EOF_pos);
    163     iBuilder->CreateAlignedStore(bits4, gep_bits4, mBlockSize/8, false);
     163    iBuilder->CreateBlockAlignedStore(bits4, gep_bits4);
    164164
    165     Value * gep_bits6 = iBuilder->CreateGEP(basis_bits, {iBuilder->getInt32(0), iBuilder->getInt32(0), iBuilder->getInt32(6)});
    166     Value * bits6 = iBuilder->CreateAlignedLoad(gep_bits6, mBlockSize/8, false, "bits6");
     165    Value * gep_bits6 = s2pInstance->getOutputStream(6);
     166    Value * bits6 = iBuilder->CreateBlockAlignedLoad(gep_bits6);
    167167    bits6 = iBuilder->CreateOr(bits6, EOF_pos);
    168     iBuilder->CreateAlignedStore(bits6, gep_bits6, mBlockSize/8, false);
     168    iBuilder->CreateBlockAlignedStore(bits6, gep_bits6);
     169
    169170    iBuilder->CreateBr(pipeline_return_block);
    170171
    171172    iBuilder->SetInsertPoint(pipeline_return_block);
    172173
    173     mICgrepKernel->generateDoBlockCall(basis_bits);
    174     mScanMatchKernel->generateDoBlockCall(results);
     174    icGrepInstance->call(basis_bits);
     175    scanMatchInstance->call(results);
    175176    iBuilder->CreateRetVoid();
    176177
     178    mMod->dump();
    177179}
Note: See TracChangeset for help on using the changeset viewer.