Changeset 5102 for icGREP/icgrep-devel


Ignore:
Timestamp:
Jul 20, 2016, 1:15:01 PM (3 years ago)
Author:
cameron
Message:

Kernel system restructuring progress

Location:
icGREP/icgrep-devel/icgrep
Files:
11 edited

Legend:

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

    r5101 r5102  
    132132
    133133    Encoding encoding(type, bits);
    134 
    135     ExternalUnboundedBuffer ByteStream(iBuilder, StreamSetType(1, i8));
    136     CircularBuffer BasisBits(iBuilder, StreamSetType(8, i1), segmentSize);
    137 
    138134    mIsNameExpression = isNameExpression;
    139     re_ast = re::regular_expression_passes(encoding, re_ast);   
    140     pablo::PabloFunction * function = re::re2pablo_compiler(encoding, re_ast);
    141    
    142     kernel::s2pKernel  s2pk(iBuilder, ByteStream, BasisBits);
    143     kernel::scanMatchKernel scanMatchK(iBuilder, 64, false);
    144    
    145     s2pk.generateKernel();
    146     scanMatchK.generateKernel();
    147    
    148     //std::unique_ptr<Module> s2pM = s2pk.createKernelModule();
    149     //std::unique_ptr<Module> scanMatchM = scanMatchK.createKernelModule();
    150    
    151     //s2pk.addKernelDeclarations(mMod);
    152     //scanMatchK.addKernelDeclarations(mMod);
    153    
    154     pablo_function_passes(function);
    155     pablo::PabloKernel  icgrepK(iBuilder, "icgrep", function, {"matchedLineCount"});
    156     icgrepK.generateKernel();
    157    
    158     //std::unique_ptr<Module> icgrepM = icgrepK.createKernelModule();
    159     //icgrepK.addKernelDeclarations(mMod);
    160    
     135
    161136    Type * const int64ty = iBuilder->getInt64Ty();
    162137    Type * const int8PtrTy = iBuilder->getInt8PtrTy();
     
    175150    fileIdx->setName("fileIdx");
    176151
     152       
     153    ExternalUnboundedBuffer ByteStream(iBuilder, StreamSetType(1, i8));
     154    CircularBuffer BasisBits(iBuilder, StreamSetType(8, i1), segmentSize);
     155    CircularBuffer MatchResults(iBuilder, StreamSetType(2, i1), segmentSize);
     156
     157    kernel::s2pKernel  s2pk(iBuilder, ByteStream, BasisBits);
     158    s2pk.generateKernel();
     159
     160    re_ast = re::regular_expression_passes(encoding, re_ast);   
     161    pablo::PabloFunction * function = re::re2pablo_compiler(encoding, re_ast);
     162    pablo_function_passes(function);
     163    pablo::PabloKernel  icgrepK(iBuilder, "icgrep", function, BasisBits, MatchResults, {"matchedLineCount"});
     164    icgrepK.generateKernel();
    177165
    178166    ByteStream.setStreamSetBuffer(inputStream);
    179167    BasisBits.allocateBuffer();
    180 
     168    MatchResults.allocateBuffer();
     169   
     170    Value * s2pInstance = s2pk.createInstance({}, {&ByteStream}, {&BasisBits});
     171    Value * icgrepInstance = icgrepK.createInstance({}, {&BasisBits}, {&MatchResults});
     172   
    181173    if (CountOnly) {
    182         Value * s2pInstance = s2pk.createInstance({}, {&ByteStream}, {&BasisBits});
    183         Value * icgrepInstance = icgrepK.createInstance({}, {&BasisBits}, {});
    184        
    185174        generatePipelineLoop(iBuilder, {&s2pk, &icgrepK}, {s2pInstance, icgrepInstance}, fileSize);
    186175        Value * matchCount = icgrepK.createGetAccumulatorCall(icgrepInstance, "matchedLineCount");
     
    188177    }
    189178    else {
    190        
    191         CircularBuffer MatchResults(iBuilder, StreamSetType(2, i1), segmentSize);
    192         ByteStream.setStreamSetBuffer(inputStream);
    193         BasisBits.allocateBuffer();
    194         MatchResults.allocateBuffer();
    195        
    196        
    197         Value * s2pInstance = s2pk.createInstance({}, {&ByteStream}, {&BasisBits});
    198         Value * icgrepInstance = icgrepK.createInstance({}, {&BasisBits}, {&MatchResults});
     179        kernel::scanMatchKernel scanMatchK(iBuilder, MatchResults, 64, false);
     180        scanMatchK.generateKernel();
     181               
    199182        Value * scanMatchInstance = scanMatchK.createInstance({iBuilder->CreateBitCast(inputStream, int8PtrTy), fileSize, fileIdx}, {&MatchResults}, {});
    200183       
  • icGREP/icgrep-devel/icgrep/kernels/interface.h

    r5100 r5102  
    2121
    2222struct StreamSetBinding {
    23     parabix::StreamSetType ssType;
     23    parabix::StreamSetBuffer & ssType;
    2424    std::string ssName;
    2525};
  • icGREP/icgrep-devel/icgrep/kernels/kernel.cpp

    r5100 r5102  
    3939    addScalar(iBuilder->getInt64Ty(), blockNoScalar);
    4040    for (auto sSet : mStreamSetInputs) {
    41         mScalarInputs.push_back(ScalarBinding{PointerType::get(sSet.ssType.getStreamSetBlockType(iBuilder), 0), sSet.ssName + basePtrSuffix});
     41        mScalarInputs.push_back(ScalarBinding{PointerType::get(sSet.ssType.getStreamSetBlockType(), 0), sSet.ssName + basePtrSuffix});
    4242        mScalarInputs.push_back(ScalarBinding{iBuilder->getInt64Ty(), sSet.ssName + blkMaskSuffix});
    4343        //Or possibly add as internal state, with code in init function:  addScalar(iBuilder->getInt64Ty(), sSet.ssName + blkMaskSuffix);
    4444    }
    4545    for (auto sSet : mStreamSetOutputs) {
    46         mScalarInputs.push_back(ScalarBinding{PointerType::get(sSet.ssType.getStreamSetBlockType(iBuilder), 0), sSet.ssName + basePtrSuffix});
     46        mScalarInputs.push_back(ScalarBinding{PointerType::get(sSet.ssType.getStreamSetBlockType(), 0), sSet.ssName + basePtrSuffix});
    4747        mScalarInputs.push_back(ScalarBinding{iBuilder->getInt64Ty(), sSet.ssName + blkMaskSuffix});
    4848        //Or possibly add as internal state, with code in init function:  addScalar(iBuilder->getInt64Ty(), sSet.ssName + blkMaskSuffix);
  • icGREP/icgrep-devel/icgrep/kernels/p2s_kernel.h

    r5079 r5102  
    2626class p2sKernel : public KernelBuilder {
    2727public:
    28     p2sKernel(IDISA::IDISA_Builder * iBuilder) :
     28    p2sKernel(IDISA::IDISA_Builder * iBuilder, parabix::StreamSetBuffer& basisBits, parabix::StreamSetBuffer& byteStream) :
    2929    KernelBuilder(iBuilder, "p2s",
    30                   {StreamSetBinding{StreamSetType(8, 1), "basisBits"}},
    31                   {StreamSetBinding{StreamSetType(1, 8), "byteStream"}},
     30                  {StreamSetBinding{basisBits, "basisBits"}},
     31                  {StreamSetBinding{byteStream, "byteStream"}},
    3232                  {}, {}, {}) {}
    3333   
     
    3939class p2sKernel_withCompressedOutput : public KernelBuilder {
    4040public:
    41     p2sKernel_withCompressedOutput(IDISA::IDISA_Builder * iBuilder) :
     41    p2sKernel_withCompressedOutput(IDISA::IDISA_Builder * iBuilder, parabix::StreamSetBuffer& basisBits, parabix::StreamSetBuffer& deletionCounts, parabix::StreamSetBuffer& byteStream) :
    4242    KernelBuilder(iBuilder, "p2s_compress",
    43                   {StreamSetBinding{StreamSetType(8, 1), "basisBits"}, StreamSetBinding{StreamSetType(1, 1), "deletionCounts"}},
    44                   {StreamSetBinding{StreamSetType(1, 8), "byteStream"}},
     43                  {StreamSetBinding{basisBits, "basisBits"}, StreamSetBinding{deletionCounts, "deletionCounts"}},
     44                  {StreamSetBinding{byteStream, "byteStream"}},
    4545                  {}, {}, {}) {}
    4646   
     
    5353class p2s_16Kernel : public KernelBuilder {
    5454public:
    55     p2s_16Kernel(IDISA::IDISA_Builder * iBuilder) :
     55    p2s_16Kernel(IDISA::IDISA_Builder * iBuilder, parabix::StreamSetBuffer& basisBits, parabix::StreamSetBuffer& i16Stream) :
    5656    KernelBuilder(iBuilder, "p2s_16",
    57                   {StreamSetBinding{StreamSetType(16, 1), "basisBits"}},
    58                   {StreamSetBinding{StreamSetType(1, 16), "i16Stream"}},
     57                  {StreamSetBinding{basisBits, "basisBits"}},
     58                  {StreamSetBinding{i16Stream, "i16Stream"}},
    5959                  {}, {}, {}) {}
    6060   
     
    6767class p2s_16Kernel_withCompressedOutput : public KernelBuilder {
    6868public:
    69     p2s_16Kernel_withCompressedOutput(IDISA::IDISA_Builder * iBuilder) :
     69    p2s_16Kernel_withCompressedOutput(IDISA::IDISA_Builder * iBuilder, parabix::StreamSetBuffer& basisBits, parabix::StreamSetBuffer& deletionCounts, parabix::StreamSetBuffer& i16Stream) :
    7070    KernelBuilder(iBuilder, "p2s_16_compress",
    71                   {StreamSetBinding{StreamSetType(16, 1), "basisBits"}, StreamSetBinding{StreamSetType(1, 1), "deletionCounts"}},
    72                   {StreamSetBinding{StreamSetType(1, 16), "i16Stream"}},
     71                  {StreamSetBinding{basisBits, "basisBits"}, StreamSetBinding{deletionCounts, "deletionCounts"}},
     72                  {StreamSetBinding{i16Stream, "i16Stream"}},
    7373                  {}, {}, {}) {}
    7474       
  • icGREP/icgrep-devel/icgrep/kernels/s2p_kernel.cpp

    r5100 r5102  
    171171   
    172172   
    173     Value * byteStreamBlock_ptr = mByteStream.getStreamSetBlockPointer(byteStreamBase_ptr, blockNo);
    174     Value * basisBitsBlock_ptr = mBasisBits.getStreamSetBlockPointer(basisBitsBase_ptr, blockNo);
     173    Value * byteStreamBlock_ptr = mStreamSetInputs[0].ssType.getStreamSetBlockPointer(byteStreamBase_ptr, blockNo);
     174    Value * basisBitsBlock_ptr = mStreamSetOutputs[0].ssType.getStreamSetBlockPointer(basisBitsBase_ptr, blockNo);
    175175   
    176176    Value * s_bytepack[8];
  • icGREP/icgrep-devel/icgrep/kernels/s2p_kernel.h

    r5100 r5102  
    2727    s2pKernel(IDISA::IDISA_Builder * iBuilder, parabix::StreamSetBuffer& byteStream, parabix::StreamSetBuffer& basisBits) :
    2828    KernelBuilder(iBuilder, "s2p",
    29                   {StreamSetBinding{parabix::StreamSetType(1, parabix::i8), "byteStream"}},
    30                   {StreamSetBinding{parabix::StreamSetType(8, parabix::i1), "basisBits"}},
    31                   {}, {}, {}), mByteStream(byteStream), mBasisBits(basisBits) {}
     29                  {StreamSetBinding{byteStream, "byteStream"}},
     30                  {StreamSetBinding{basisBits, "basisBits"}},
     31                  {}, {}, {}) {}
    3232   
    3333   
    3434private:
    35     parabix::StreamSetBuffer& mByteStream;
    36     parabix::StreamSetBuffer& mBasisBits;
    3735    void generateDoBlockMethod() override;
    3836    void generateFinalBlockMethod() override;
  • icGREP/icgrep-devel/icgrep/kernels/scanmatchgen.h

    r5100 r5102  
    1717class scanMatchKernel : public KernelBuilder {
    1818public:
    19     scanMatchKernel(IDISA::IDISA_Builder * iBuilder, unsigned scanwordBitWidth, bool isNameExpression) :
     19    scanMatchKernel(IDISA::IDISA_Builder * iBuilder, parabix::StreamSetBuffer& matchResults, unsigned scanwordBitWidth, bool isNameExpression) :
    2020    KernelBuilder(iBuilder, "scanMatch",
    21                   {StreamSetBinding{parabix::StreamSetType(2, parabix::i1), "matchResults"}},
     21                  {StreamSetBinding{matchResults, "matchResults"}},
    2222                    {},
    2323                    {ScalarBinding{iBuilder->getInt8PtrTy(), "FileBuf"}, ScalarBinding{iBuilder->getInt64Ty(), "FileSize"}, ScalarBinding{iBuilder->getInt64Ty(), "FileIdx"}},
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r5096 r5102  
    6464     
    6565    Value * blockNo = mKernelBuilder->getScalarField(mSelf, blockNoScalar);
    66     Value * inputSet_ptr = mKernelBuilder->getCircularBufferBlockPointer(mSelf, "inputs", blockNo);
    67    
     66    Value * inputBase_ptr = mKernelBuilder->getScalarField(mSelf, mKernelBuilder->mStreamSetInputs[0].ssName + basePtrSuffix);
     67    Value * inputSet_ptr  = mKernelBuilder->mStreamSetInputs[0].ssType.getStreamSetBlockPointer(inputBase_ptr, blockNo);
     68
    6869    Value * outputSet_ptr = nullptr;
    6970    if (mPabloFunction->getNumOfResults() > 0) {
    70         outputSet_ptr = mKernelBuilder->getCircularBufferBlockPointer(mSelf, mKernelBuilder->mStreamSetOutputs[0].ssName, blockNo);
     71        Value * outputBase_ptr = mKernelBuilder->getScalarField(mSelf, mKernelBuilder->mStreamSetOutputs[0].ssName + basePtrSuffix);
     72        outputSet_ptr = mKernelBuilder->mStreamSetOutputs[0].ssType.getStreamSetBlockPointer(outputBase_ptr, blockNo);
    7173    }
    7274    for (unsigned j = 0; j < mPabloFunction->getNumOfParameters(); ++j) {
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.cpp

    r5100 r5102  
    1616                         std::string kernelName,
    1717                         PabloFunction * function,
     18                         StreamSetBuffer & inputBuffer,
     19                         StreamSetBuffer & outputBuffer,
    1820                         std::vector<std::string> accumulators) :
    1921    KernelBuilder(builder, kernelName,
    20                     {StreamSetBinding{StreamSetType(function->getNumOfParameters(), 1), "inputs"}},
     22                    {StreamSetBinding{inputBuffer, "inputs"}},
     23                    {StreamSetBinding{outputBuffer, "outputs"}},
     24                    {},
     25                    {},
     26                    {ScalarBinding{builder->getBitBlockType(), "EOFmark"}}),
     27    mPabloFunction(function) {
     28    unsigned output_streams = function->getNumOfResults();
     29    assert (output_streams > 0);
     30    mScalarOutputs = accumBindings(accumulators);
     31    pablo_compiler = new PabloCompiler(builder, this, function);
     32}
     33
     34PabloKernel::PabloKernel(IDISA::IDISA_Builder * builder,
     35                         std::string kernelName,
     36                         PabloFunction * function,
     37                         StreamSetBuffer & inputBuffer,
     38                         std::vector<std::string> accumulators) :
     39    KernelBuilder(builder, kernelName,
     40                    {StreamSetBinding{inputBuffer, "inputs"}},
    2141                    {},
    2242                    {},
     
    2545    mPabloFunction(function) {
    2646    unsigned output_streams = function->getNumOfResults();
    27     if (output_streams > 0) {
    28         mStreamSetOutputs = {StreamSetBinding{StreamSetType(output_streams, 1), "outputs"}};
    29     }
     47    assert (output_streams == 0);
    3048    mScalarOutputs = accumBindings(accumulators);
    3149    pablo_compiler = new PabloCompiler(builder, this, function);
    3250}
     51
    3352
    3453std::vector<ScalarBinding> PabloKernel::accumBindings(std::vector<std::string> accum_names) {
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.h

    r5076 r5102  
    2121                    std::string kernelName,
    2222                    PabloFunction * function,
     23                    parabix::StreamSetBuffer & inputBuffer,
     24                    parabix::StreamSetBuffer & outputBuffer,
     25                    std::vector<std::string> accumulators);
     26    // At present only population count accumulator are supported,
     27    // using the pablo.Count operation.
     28   
     29    PabloKernel(IDISA::IDISA_Builder * builder,
     30                    std::string kernelName,
     31                    PabloFunction * function,
     32                    parabix::StreamSetBuffer & inputBuffer,
    2333                    std::vector<std::string> accumulators);
    2434    // At present only population count accumulator are supported,
  • icGREP/icgrep-devel/icgrep/wc.cpp

    r5101 r5102  
    148148    s2pKernel  s2pk(iBuilder, ByteStream, BasisBits);
    149149    std::unique_ptr<Module> s2pM = s2pk.createKernelModule();
     150   
    150151    pablo_function_passes(function);
    151     pablo::PabloKernel  wck(iBuilder, "wc", function, {"lineCount", "wordCount", "charCount"});
     152    pablo::PabloKernel  wck(iBuilder, "wc", function, BasisBits, {"lineCount", "wordCount", "charCount"});
     153   
    152154    std::unique_ptr<Module> wcM = wck.createKernelModule();
    153155   
Note: See TracChangeset for help on using the changeset viewer.