Ignore:
Timestamp:
Jul 17, 2015, 1:41:26 PM (4 years ago)
Author:
cameron
Message:

Carry Manager progress and bug fix

File:
1 edited

Legend:

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

    r4676 r4682  
    2121unsigned const LongAdvanceBase = 64;
    2222
     23#ifdef PACKING
     24const unsigned PACK_SIZE = 64;
     25#else
     26const unsigned PACK_SIZE = BLOCK_SIZE;
     27#endif
     28
     29
    2330static unsigned power2ceil (unsigned v) {
    2431    unsigned ceil = 1;
    2532    while (ceil < v) ceil *= 2;
    2633    return ceil;
     34}
     35
     36static unsigned alignCeiling(unsigned toAlign, unsigned alignment) {
     37    return ((toAlign - 1) | (alignment - 1)) + 1;
     38}
     39
     40static unsigned fullOrPartialBlocks(unsigned bits, unsigned block_size) {
     41    return alignCeiling(bits, block_size) / block_size;
    2742}
    2843
     
    5974       
    6075    unsigned longAdvanceCarryDataOffset(unsigned advanceIndex)  const {
    61         return longAdvance.frameOffsetinBits / BLOCK_SIZE + advanceIndex;
     76        return fullOrPartialBlocks(longAdvance.frameOffsetinBits, BLOCK_SIZE) + advanceIndex;
    6277    }
    6378   
    6479    unsigned longAdvanceEntries(unsigned shift_amount) const {
    65         return (shift_amount + BLOCK_SIZE - 1)/BLOCK_SIZE;
     80        return fullOrPartialBlocks(shift_amount, BLOCK_SIZE);
    6681    }
    6782   
     
    7388   
    7489    unsigned shortAdvanceCarryDataOffset(unsigned advanceIndex)  const {
    75         return shortAdvance.frameOffsetinBits / BLOCK_SIZE + advanceIndex;
     90        return fullOrPartialBlocks(shortAdvance.frameOffsetinBits, PACK_SIZE) + advanceIndex;
    7691    }
    7792   
    7893    unsigned unitAdvanceCarryDataOffset(unsigned advanceIndex)  const {
    79         return advance1.frameOffsetinBits / BLOCK_SIZE + advanceIndex;
     94        return fullOrPartialBlocks(advance1.frameOffsetinBits, PACK_SIZE) + advanceIndex;
    8095    }
    8196   
    8297    unsigned carryOpCarryDataOffset(unsigned idx)  const {
    83         return addWithCarry.frameOffsetinBits / BLOCK_SIZE + idx;
     98        return fullOrPartialBlocks(addWithCarry.frameOffsetinBits, PACK_SIZE) + idx;
    8499    }
    85100   
    86101    unsigned summaryCarryDataIndex()  const {
    87         return summary.frameOffsetinBits / BLOCK_SIZE;
     102        return fullOrPartialBlocks(summary.frameOffsetinBits, PACK_SIZE);
    88103    }
    89104   
    90     unsigned getLocalCarryDataSize () { return nested.frameOffsetinBits / BLOCK_SIZE; }
     105    unsigned getLocalCarryPackIndex () { return shortAdvance.frameOffsetinBits / PACK_SIZE; }
    91106
    92     unsigned getScopeCarryDataSize () { return scopeCarryDataBits / BLOCK_SIZE; }
     107    unsigned getLocalCarryDataSize () { return fullOrPartialBlocks(nested.frameOffsetinBits - shortAdvance.frameOffsetinBits, PACK_SIZE); }
     108
     109    unsigned getScopeCarryDataSize () { return fullOrPartialBlocks(scopeCarryDataBits, PACK_SIZE); }
    93110   
    94111    bool blockHasCarries() const { return scopeCarryDataBits > 0;}
    95112   
    96     bool explicitSummaryRequired() const { return (ifDepth > 0) && (scopeCarryDataBits > BLOCK_SIZE);}
     113    bool explicitSummaryRequired() const { return (ifDepth > 0) && (scopeCarryDataBits > PACK_SIZE);}
    97114   
    98115private:
Note: See TracChangeset for help on using the changeset viewer.