Ignore:
Timestamp:
Feb 25, 2017, 12:50:29 PM (2 years ago)
Author:
nmedfort
Message:

Added enable asserts (-ea) command line flag + restructured BlockOrientedKernels? to allow for inlined code.

Location:
icGREP/icgrep-devel/icgrep/pablo
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/carry_data.h

    r5267 r5347  
    5555    }
    5656
     57    bool hasVariableLength() const {
     58        return variableLength;
     59    }
     60
    5761   
    5862protected:
    5963
    60     SummaryType     summaryType;
    61     bool            variableLength;
     64    SummaryType             summaryType;
     65    bool                    variableLength;
    6266
    6367};
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.cpp

    r5340 r5347  
    8585
    8686/** ------------------------------------------------------------------------------------------------------------- *
    87  * @brief allocateCarryData
    88  ** ------------------------------------------------------------------------------------------------------------- */
    89 void CarryManager::allocateCarryData(PabloKernel * const kernel) {
    90 //    mKernel = kernel;
    91 //    mCarryScopes = 0;
    92 //    mCarryScopeIndex.push_back(0);
    93 //    mCurrentFrame = kernel->getScalarFieldPtr("carries");
    94 //    allocateCarryData (mCurrentFrame->getType());
    95 }
    96 
    97 ///** ------------------------------------------------------------------------------------------------------------- *
    98 // * @brief allocateCarryData
    99 // ** ------------------------------------------------------------------------------------------------------------- */
    100 //void CarryManager::allocateCarryData(Type * const type) {
    101 //    assert (type->isStructTy());
    102 
    103 //    const auto scopeIndex = mCarryScopes++;
    104 
    105 //    const unsigned vl = mCarryMetadata[scopeIndex].variableLength ? 4 : 0;
    106 
    107 //    if (LLVM_UNLIKELY(vl != 0)) {
    108 
    109 
    110 //        ConstantInt * const capacity = iBuilder->getSize(vl);
    111 //        Value * capacityPtr = iBuilder->CreateGEP(mCurrentFrame, {iBuilder->getInt32(0), iBuilder->getInt32(0)});
    112 //        iBuilder->CreateStore(capacity, capacityPtr, false);
    113 //        Value * arrayPtr = iBuilder->CreateGEP(mCurrentFrame, {iBuilder->getInt32(0), iBuilder->getInt32(1)});
    114 //        Value * carryStateType = arrayPtr->getType()->getPointerElementType();
    115 //        Value * array = iBuilder->CreateAlignedMalloc(carryStateType, capacity, iBuilder->getCacheAlignment());
    116 //        Constant * typeWidth = ConstantExpr::getIntegerCast(ConstantExpr::getSizeOf(carryStateType), iBuilder->getSizeTy(), false);
    117 //        iBuilder->CreateMemZero(array, iBuilder->CreateMul(capacity, typeWidth), iBuilder->getCacheAlignment());
    118 //        iBuilder->CreateStore(array, arrayPtr, false);
    119 
    120 
    121 
    122 
    123 //    } else {
    124 
    125 
    126 //        for (unsigned i = 0; i < type->getStructNumElements(); ++i) {
    127 
    128 
    129 
    130 //        }
    131 
    132 
    133 
    134 //    }
    135 
    136 
    137 
    138 
    139 
    140 
    141 //}
    142 
    143 
    144 /** ------------------------------------------------------------------------------------------------------------- *
    14587 * @brief initializeCodeGen
    14688 ** ------------------------------------------------------------------------------------------------------------- */
     
    207149    }
    208150
    209     if (LLVM_UNLIKELY(mCarryInfo->variableLength)) {
     151    if (LLVM_UNLIKELY(mCarryInfo->hasVariableLength())) {
    210152        // Check whether we need to resize the carry state
    211153        PHINode * index = iBuilder->CreatePHI(iBuilder->getSizeTy(), 2);
     
    230172
    231173        Constant * carryStateWidth = ConstantExpr::getIntegerCast(ConstantExpr::getSizeOf(carryStateType), capacity->getType(), false);
    232 
    233         Value * newCapacity = iBuilder->CreateMul(iBuilder->CreateAdd(index, iBuilder->getSize(1)), iBuilder->getSize(2));
     174        Value * newCapacity = iBuilder->CreateSelect(iBuilder->CreateICmpNE(index, ConstantInt::getNullValue(index->getType())), iBuilder->CreateMul(index, iBuilder->getSize(2)), iBuilder->getSize(4));
    234175        Value * newArray = iBuilder->CreateAlignedMalloc(carryStateType, newCapacity, iBuilder->getCacheAlignment());
    235176
     
    241182        iBuilder->CreateCondBr(isNullCarryState, zeroBlock, cleanUpBlock);
    242183        iBuilder->SetInsertPoint(cleanUpBlock);
     184
     185
    243186
    244187        iBuilder->CreateMemCpy(newArray, array, iBuilder->CreateMul(capacity, carryStateWidth), iBuilder->getCacheAlignment());
     
    275218        mCarrySummary.pop_back();
    276219    }
    277     if (LLVM_UNLIKELY(mCarryInfo->variableLength)) {
     220    if (LLVM_UNLIKELY(mCarryInfo->hasVariableLength())) {
    278221        assert (!mLoopIndicies.empty());
    279222        PHINode * index = mLoopIndicies.back();
     
    592535 ** ------------------------------------------------------------------------------------------------------------- */
    593536bool CarryManager::inCollapsingCarryMode() const {
    594     return (mCurrentScope->getBranch() && isa<While>(mCurrentScope->getBranch()) && !mCarryInfo->variableLength);
     537    return (mCurrentScope->getBranch() && isa<While>(mCurrentScope->getBranch()) && !mCarryInfo->hasVariableLength());
    595538}
    596539
     
    641584StructType * CarryManager::analyse(PabloBlock * const scope, const unsigned ifDepth, const unsigned loopDepth) {
    642585
     586    assert (scope != mKernel->getEntryBlock() || mCarryScopes == 0);
     587    assert (mCarryScopes < mCarryMetadata.size());
     588    assert (mCarryPackType);
     589
     590    CarryData & cd = mCarryMetadata[mCarryScopes++];
     591
    643592    std::vector<Type *> state;
    644593
    645     assert (mCarryPackType);
    646 
    647594    Type * const carryPackType = (loopDepth == 0) ? mCarryPackType : ArrayType::get(mCarryPackType, 2);
    648 
    649     const auto scopeIndex = mCarryScopes++;
    650 
    651     assert (scopeIndex < mCarryMetadata.size());
    652595
    653596    bool hasLongAdvances = false;
     
    678621    }
    679622
    680     CarryData & cd = mCarryMetadata[scopeIndex];
    681 
    682623    StructType * carryState = nullptr;
    683624
     
    705646        carryState = StructType::get(iBuilder->getContext(), state);
    706647        // If we in a loop and cannot use collapsing carry mode, convert the struct into a capacity and pointer pair.
    707         if (LLVM_UNLIKELY(cd.variableLength)) {
     648        if (LLVM_UNLIKELY(cd.hasVariableLength())) {
     649            mHasVariableLengthCarryData = true;
    708650            carryState = StructType::get(iBuilder->getSizeTy(), carryState->getPointerTo(), nullptr);
    709651        }
     
    730672, mIfDepth(0)
    731673, mHasLongAdvance(false)
     674, mHasVariableLengthCarryData(false)
    732675, mHasLoop(false)
    733676, mLoopDepth(0)
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.h

    r5340 r5347  
    4646    void initializeCarryData(PabloKernel * const kernel);
    4747
    48     void allocateCarryData(PabloKernel * const kernels);
    49 
    5048    void initializeCodeGen();
    5149
     
    8583
    8684    static unsigned getScopeCount(PabloBlock * const scope, unsigned index = 0);
     85
    8786    static bool requiresVariableLengthMode(const PabloBlock * const scope);
     87
    8888    llvm::StructType * analyse(PabloBlock * const scope, const unsigned ifDepth = 0, const unsigned whileDepth = 0);
    8989
     
    123123    bool                                            mHasLongAdvance;
    124124
     125    bool                                            mHasVariableLengthCarryData;
     126
    125127    bool                                            mHasLoop;
    126128    unsigned                                        mLoopDepth;
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r5342 r5347  
    6161    examineBlock(mKernel->getEntryBlock());
    6262    mCarryManager->initializeCarryData(mKernel);
    63 }
    64 
    65 void PabloCompiler::allocateKernelData() {
    66     mCarryManager->allocateCarryData(mKernel);
    6763}
    6864
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.h

    r5340 r5347  
    3838    void initializeKernelData();
    3939
    40     void allocateKernelData();
    41 
    4240    void compile();
    4341
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.cpp

    r5340 r5347  
    116116}
    117117
    118 void PabloKernel::generateInitMethod() {
    119     mPabloCompiler->allocateKernelData();
    120 }
    121 
    122118void PabloKernel::generateDoBlockMethod() {
    123119    mPabloCompiler->compile();
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.h

    r5340 r5347  
    131131    void prepareKernel()  override final;
    132132
    133     void generateInitMethod() override final;
    134 
    135133    void generateDoBlockMethod() override final;
    136134
Note: See TracChangeset for help on using the changeset viewer.