Changeset 4714


Ignore:
Timestamp:
Aug 4, 2015, 7:06:55 AM (4 years ago)
Author:
cameron
Message:

Carry data/manager paramaterization: progress towards dynamic strategy selection.

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

Legend:

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

    r4704 r4714  
    1414namespace pablo {
    1515
    16    
    17 
    1816void PabloBlockCarryData::enumerateLocal() {
    1917    for (Statement * stmt : *theScope) {
     
    2523            }
    2624            else if (shift_amount < LongAdvanceBase) {
    27 #ifdef PACKING
    28                 EnsurePackHasSpace(shortAdvance.allocatedBits, shift_amount);
    29                 adv->setLocalAdvanceIndex(shortAdvance.allocatedBits);
    30 #else
    31                 adv->setLocalAdvanceIndex(shortAdvance.entries);
    32 #endif
     25                // short Advance
     26                if (ITEMS_PER_PACK >= LongAdvanceBase) {
     27                    // Packing is possible.   We will use the allocated bit position as
     28                    // the index.
     29                    if (roomInFinalPack(shortAdvance.allocatedBits) < shift_amount) {
     30                        // Start a new pack.
     31                        shortAdvance.allocatedBits = alignCeiling(shortAdvance.allocatedBits, PACK_SIZE);
     32                    }
     33                    adv->setLocalAdvanceIndex(shortAdvance.allocatedBits);
     34                }
     35                else {
     36                    adv->setLocalAdvanceIndex(shortAdvance.entries);
     37                }
    3338                shortAdvance.entries++;
    3439                shortAdvance.allocatedBits += shift_amount;
     
    5055    }
    5156    longAdvance.frameOffset = 0;
    52 #ifdef PACKING
    53     shortAdvance.frameOffset = longAdvance.frameOffset + longAdvance.allocatedBitBlocks * BLOCK_SIZE;
    54     addWithCarry.frameOffset = shortAdvance.frameOffset + shortAdvance.allocatedBits;
    55     EnsurePackHasSpace(addWithCarry.frameOffset, addWithCarry.entries);
    56     advance1.frameOffset = addWithCarry.frameOffset + addWithCarry.entries;
    57     EnsurePackHasSpace(advance1.frameOffset, advance1.entries);
     57    shortAdvance.frameOffset = longAdvance.frameOffset + longAdvance.allocatedBitBlocks * POSITIONS_PER_BLOCK;
     58    if (ITEMS_PER_PACK == PACK_SIZE) {
     59        addWithCarry.frameOffset = shortAdvance.frameOffset + shortAdvance.allocatedBits;
     60        if (roomInFinalPack(addWithCarry.frameOffset) < addWithCarry.entries) {
     61            addWithCarry.frameOffset = alignCeiling(addWithCarry.frameOffset, PACK_SIZE);
     62        }
     63        advance1.frameOffset = addWithCarry.frameOffset + addWithCarry.entries;
     64        if (roomInFinalPack(advance1.frameOffset) < advance1.entries) {
     65            advance1.frameOffset = alignCeiling(advance1.frameOffset, PACK_SIZE);
     66        }
     67    }
     68    else {
     69        addWithCarry.frameOffset = shortAdvance.frameOffset + shortAdvance.entries;
     70        advance1.frameOffset = addWithCarry.frameOffset + addWithCarry.entries;
     71
     72    }
    5873    nested.frameOffset = advance1.frameOffset + advance1.entries;
    59 #else
    60     shortAdvance.frameOffset = longAdvance.frameOffset + longAdvance.allocatedBitBlocks;
    61     addWithCarry.frameOffset = shortAdvance.frameOffset + shortAdvance.entries;
    62     advance1.frameOffset = addWithCarry.frameOffset + addWithCarry.entries;
    63     nested.frameOffset = advance1.frameOffset + advance1.entries;
    64 #endif
    6574}
    6675       
  • icGREP/icgrep-devel/icgrep/pablo/carry_data.h

    r4713 r4714  
    3535const unsigned ITEMS_PER_PACK = 1;
    3636#endif
     37const unsigned POSITIONS_PER_BLOCK = ITEMS_PER_PACK * (BLOCK_SIZE/PACK_SIZE);
    3738
    3839
     
    5051    return alignCeiling(bits, block_size) / block_size;
    5152}
    52 
    53 #ifdef PACKING
    54 static void EnsurePackHasSpace(unsigned & packedTotalBits, unsigned addedBits) {
    55     unsigned bitsInCurrentPack = packedTotalBits % PACK_SIZE;
    56     if ((bitsInCurrentPack > 0) && (bitsInCurrentPack + addedBits > PACK_SIZE)) {
    57         packedTotalBits = alignCeiling(packedTotalBits, PACK_SIZE);
    58     }
    59 }
    60 #endif
    61 
    6253
    6354namespace pablo {
     
    8071       
    8172    friend class CarryManager;
     73   
     74    inline unsigned roomInFinalPack(unsigned allocatedBits) {
     75        return ITEMS_PER_PACK - (allocatedBits % ITEMS_PER_PACK);
     76    }
    8277   
    8378    void enumerateLocal();
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.cpp

    r4713 r4714  
    9999            const unsigned ifCarryDataBits = enumerate(&ifStatement->getBody(), ifDepth+1, whileDepth);
    100100            PabloBlockCarryData * nestedBlockData = mCarryInfoVector[ifStatement->getBody().getScopeIndex()];
    101 #ifdef PACKING
    102             EnsurePackHasSpace(nestedOffset, ifCarryDataBits);
    103 #endif
     101            if (ITEMS_PER_PACK == PACK_SIZE) {  // PACKING
     102                if (cd->roomInFinalPack(nestedOffset) < ifCarryDataBits) {
     103                    nestedOffset = alignCeiling(nestedOffset, PACK_SIZE);
     104                }
     105            }
    104106            nestedBlockData->setFramePosition(nestedOffset);
    105107
     
    115117            PabloBlockCarryData * nestedBlockData = mCarryInfoVector[whileStatement->getBody().getScopeIndex()];
    116118            //if (whileStatement->isMultiCarry()) whileCarryDataBits *= whileStatement->getMaxIterations();
    117 #ifdef PACKING
    118             EnsurePackHasSpace(nestedOffset, whileCarryDataBits);
    119 #endif
     119            if (ITEMS_PER_PACK == PACK_SIZE) {  // PACKING
     120                if (cd->roomInFinalPack(nestedOffset) < whileCarryDataBits) {
     121                    nestedOffset = alignCeiling(nestedOffset, PACK_SIZE);
     122                }
     123            }
    120124            nestedBlockData->setFramePosition(nestedOffset);
    121125            nestedOffset += whileCarryDataBits;
     
    133137        // Need extra space for the summary variable, always the last
    134138        // entry within an if block.
    135 #ifdef PACKING
    136         cd->scopeCarryDataSize = alignCeiling(cd->scopeCarryDataSize, PACK_SIZE);
     139        if (ITEMS_PER_PACK == PACK_SIZE) {  // PACKING
     140            cd->scopeCarryDataSize = alignCeiling(cd->scopeCarryDataSize, PACK_SIZE);
     141        }
    137142        cd->summary.frameOffset = cd->scopeCarryDataSize;
    138         cd->scopeCarryDataSize += PACK_SIZE;
    139 #else
    140         cd->summary.frameOffset = cd->scopeCarryDataSize;
    141         cd->scopeCarryDataSize++;
    142 #endif
     143        cd->scopeCarryDataSize += ITEMS_PER_PACK;  //  computed summary is a full pack.
    143144    }
    144145    else {
Note: See TracChangeset for help on using the changeset viewer.