Ignore:
Timestamp:
Mar 11, 2016, 4:44:53 PM (3 years ago)
Author:
nmedfort
Message:

Added ability to name internal state types; removed unnecessary predefined states. Some progress towards supporting segment size > 1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r4968 r4970  
    7373, mPabloFunction(nullptr)
    7474, mPabloBlock(nullptr)
    75 , mKBuilder(nullptr)
     75, mKernelBuilder(nullptr)
    7676, mWhileDepth(0)
    7777, mIfDepth(0)
    7878, mFunction(nullptr)
    79 , mMaxWhileDepth(0)
    80 , mFilePosIdx(2) {
     79, mMaxWhileDepth(0) {
    8180   
    8281}
    8382
    8483void PabloCompiler::setKernel(KernelBuilder * kBuilder){
    85     mKBuilder = kBuilder;   
     84    mKernelBuilder = kBuilder;
    8685}
    8786
     
    124123
    125124    for (unsigned i = 0; i < function->getNumOfParameters(); ++i) {
    126         mKBuilder->addInputStream(1, function->getParameter(i)->getName()->to_string());
     125        mKernelBuilder->addInputStream(1, function->getParameter(i)->getName()->to_string());
    127126    }
    128127    for (unsigned i = 0; i < function->getNumOfResults(); ++i) {
    129         mKBuilder->addOutputStream(1);
    130     }
    131 
    132     mCarryManager->initialize(function, mKBuilder);
    133 
    134     mKBuilder->prepareFunction();
    135 
    136     mFunction = mKBuilder->getDoBlockFunction();
    137 
    138     mCarryManager->initialize_setPtrs(mKBuilder);
    139 
    140     for(unsigned i = 0; i < mKBuilder->getSegmentBlocks(); i++){
     128        mKernelBuilder->addOutputStream(1);
     129    }
     130
     131    mCarryManager->initialize(function, mKernelBuilder);
     132
     133    mKernelBuilder->prepareFunction();
     134
     135    mFunction = mKernelBuilder->getDoBlockFunction();
     136
     137    for(unsigned i = 0; i < mKernelBuilder->getSegmentBlocks(); ++i){
     138
     139        mCarryManager->reset();
    141140
    142141        for (unsigned j = 0; j < function->getNumOfParameters(); ++j) {
    143             mMarkerMap.insert(std::make_pair(function->getParameter(j), mKBuilder->getInputStream(j)));
     142            mMarkerMap.insert(std::make_pair(function->getParameter(j), mKernelBuilder->getInputStream(j)));
    144143        }
    145144
    146145        compileBlock(function->getEntryBlock());
    147 
    148         Value * filePos = mKBuilder->getInternalState(mFilePosIdx);
    149         filePos = iBuilder->CreateBlockAlignedLoad(filePos);
    150         filePos = iBuilder->CreateAdd(filePos, iBuilder->getInt64(iBuilder->getBitBlockWidth()));
    151         mKBuilder->setInternalState(mFilePosIdx, filePos);
    152 
    153         mCarryManager->setBlockNo(mKBuilder);
    154146
    155147        for (unsigned j = 0; j < function->getNumOfResults(); ++j) {
     
    161153                result = f->second;
    162154            }
    163             iBuilder->CreateBlockAlignedStore(result, mKBuilder->getOutputStream(j));
     155            iBuilder->CreateBlockAlignedStore(result, mKernelBuilder->getOutputStream(j));
    164156        }
    165157
    166158        mMarkerMap.clear();
    167159
    168         mKBuilder->increment();
     160        mKernelBuilder->increment();
    169161    }   
    170162
    171     mKBuilder->finalize();
     163    mKernelBuilder->finalize();
    172164}
    173165
     
    178170    Examine(function.getEntryBlock());
    179171}
    180 
    181172
    182173void PabloCompiler::Examine(PabloBlock * block) {
     
    192183}
    193184
    194 void PabloCompiler::compileBlock(PabloBlock * block) {
     185void PabloCompiler::compileBlock(const PabloBlock * const block) {
    195186    mPabloBlock = block;
    196187    for (const Statement * statement : *block) {
     
    436427        const unsigned offset = l->getAmount() / iBuilder->getBitBlockWidth();
    437428        const unsigned shift = (l->getAmount() % iBuilder->getBitBlockWidth());
    438         Value * const b0 = iBuilder->CreateBitCast(iBuilder->CreateBlockAlignedLoad(mKBuilder->getInputStream(offset), index), streamType);
    439         Value * const b1 = iBuilder->CreateBitCast(iBuilder->CreateBlockAlignedLoad(mKBuilder->getInputStream(offset + 1), index), streamType);
     429        Value * const b0 = iBuilder->CreateBitCast(iBuilder->CreateBlockAlignedLoad(mKernelBuilder->getInputStream(offset), index), streamType);
     430        Value * const b1 = iBuilder->CreateBitCast(iBuilder->CreateBlockAlignedLoad(mKernelBuilder->getInputStream(offset + 1), index), streamType);
    440431        Value * result = iBuilder->CreateOr(iBuilder->CreateLShr(b0, shift), iBuilder->CreateShl(b1, iBuilder->getBitBlockWidth() - shift), "lookahead");
    441432        expr = iBuilder->CreateBitCast(result, iBuilder->getBitBlockType());
Note: See TracChangeset for help on using the changeset viewer.