Changeset 4951


Ignore:
Timestamp:
Mar 3, 2016, 9:02:22 AM (4 years ago)
Author:
cameron
Message:

Removing compile-time BLOCK_SIZE from pablo compiler/carry manager

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

Legend:

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

    r4942 r4951  
    4848public:
    4949
    50     CarryData(PabloBlock * b, unsigned PACK_SIZE, unsigned ITEMS_PER_PACK):
    51        mPackSize(PACK_SIZE),
    52        mItemsPerPack(ITEMS_PER_PACK),
    53        mPositionsPerBlock(mItemsPerPack * (BLOCK_SIZE/mPackSize)),
     50    CarryData(PabloBlock * b, unsigned packSize, unsigned itemsPerPack, unsigned blockSize):
     51       mPackSize(packSize),
     52       mItemsPerPack(itemsPerPack),
     53       mBlockSize(blockSize),
     54       mPositionsPerBlock(mItemsPerPack * (blockSize/mPackSize)),
    5455       theScope(b),
    5556       framePosition(0),
     
    103104   
    104105    unsigned longAdvanceEntries(unsigned shift_amount) const {
    105         return fullOrPartialBlocks(shift_amount, BLOCK_SIZE);
     106        return fullOrPartialBlocks(shift_amount, mBlockSize);
    106107    }
    107108   
     
    132133protected:
    133134
    134     unsigned mPackSize, mItemsPerPack, mPositionsPerBlock;
     135    unsigned mPackSize, mItemsPerPack, mBlockSize, mPositionsPerBlock;
    135136   
    136137    PabloBlock * theScope;
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.cpp

    r4945 r4951  
    1515#include <llvm/IR/Function.h>
    1616
    17 #if (BLOCK_SIZE==256)
    18 #define USING_LONG_ADD
    19 #endif
    2017#define DSSLI_FIELDWIDTH 64
    2118
     
    134131        Value * carry_out_strm = iBuilder->simd_or(carrygen, iBuilder->simd_and(carryprop, iBuilder->CreateNot(sum)));
    135132        setCarryOut(localIndex, carry_out_strm);
    136     } else {
    137         #ifndef USING_LONG_ADD
    138         Value * carryq_value = getCarryIn(localIndex);
    139         Value * carrygen = iBuilder->simd_and(e1, e2);
    140         Value * carryprop = iBuilder->simd_or(e1, e2);
    141         sum = iBuilder->simd_add(mBitBlockWidth, iBuilder->simd_add(mBitBlockWidth, e1, e2), carryq_value);
    142         Value * carry_out_strm = iBuilder->simd_or(carrygen, iBuilder->simd_and(carryprop, iBuilder->CreateNot(sum)));
    143         setCarryOut(localIndex, carry_out_strm);
    144         #else
     133    } else if (mBitBlockWidth == 256) {
     134        // using LONG_ADD
    145135        Value * carryq_value = getCarryIn(localIndex);
    146136        Value * carryin = iBuilder->mvmd_extract(32, carryq_value, 0);
     
    158148        Value * carry_out_strm = iBuilder->CreateZExt(iBuilder->CreateLShr(incrementMask, mBitBlockWidth / 64), iBuilder->getIntNTy(mBitBlockWidth));
    159149        setCarryOut(localIndex, iBuilder->bitCast(carry_out_strm));
    160         #endif
     150    }
     151    else {
     152        Value * carryq_value = getCarryIn(localIndex);
     153        Value * carrygen = iBuilder->simd_and(e1, e2);
     154        Value * carryprop = iBuilder->simd_or(e1, e2);
     155        sum = iBuilder->simd_add(mBitBlockWidth, iBuilder->simd_add(mBitBlockWidth, e1, e2), carryq_value);
     156        Value * carry_out_strm = iBuilder->simd_or(carrygen, iBuilder->simd_and(carryprop, iBuilder->CreateNot(sum)));
     157        setCarryOut(localIndex, carry_out_strm);
    161158    }
    162159    return sum;
     
    402399void CarryManager::setCarryOut(const unsigned localIndex, Value * carryOut) {
    403400    const unsigned index = addPosition(localIndex);
    404     #ifndef USING_LONG_ADD
    405     Value * carry_bit = iBuilder->CreateLShr(iBuilder->CreateBitCast(carryOut, iBuilder->getIntNTy(mBitBlockWidth)), mBitBlockWidth-1);
    406     carryOut = iBuilder->CreateBitCast(carry_bit, mBitBlockType);
    407     #endif
     401    if (mBitBlockWidth < 256) { // #ifndef USING_LONG_ADD
     402        Value * carry_bit = iBuilder->CreateLShr(iBuilder->CreateBitCast(carryOut, iBuilder->getIntNTy(mBitBlockWidth)), mBitBlockWidth-1);
     403        carryOut = iBuilder->CreateBitCast(carry_bit, mBitBlockType);
     404    }
    408405    mCarryOutPack[index] = carryOut;
    409406    if (LLVM_LIKELY(hasSummary())) {
     
    420417unsigned CarryManager::enumerate(PabloBlock * blk, unsigned ifDepth, unsigned whileDepth) {
    421418    unsigned idx = blk->getScopeIndex();
    422     CarryData * cd = new CarryData(blk, mBitBlockWidth, 1);
     419    CarryData * cd = new CarryData(blk, mBitBlockWidth, 1, mBitBlockWidth);
    423420    mCarryInfoVector[idx] = cd;
    424421
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.h

    r4939 r4951  
    11/*
    2  *  Copyright (c) 2014 International Characters.
     2 *  Copyright (c) 2016 International Characters.
    33 *  This software is licensed to the public under the Open Software License 3.0.
    44 *  icgrep is a trademark of International Characters.
     
    88#define PABLO_COMPILER_H
    99
    10 //indicates that we use llvm.uadd.with.overflow.carryin for genAddWithCarry
    11 //#define USE_UADD_OVERFLOW
    12 //#define USE_LONG_INTEGER_SHIFT
    13 //#define USE_TWO_UADD_OVERFLOW
    1410
    15 #if defined(USE_TWO_UADD_OVERFLOW) && !defined(USE_UADD_OVERFLOW)
    16 static_assert(false, "Need to turn on them together.");
    17 #endif
    18 
    19 //Pablo Expressions
    2011#include <string>
    2112#include <list>
     
    5849class While;
    5950
    60 #if (BLOCK_SIZE==256)
    61 #define USE_UADD_OVERFLOW
    62 #define USE_TWO_UADD_OVERFLOW
    63 #endif
    64 
    6551class PabloCompiler {
    66     #ifdef USE_UADD_OVERFLOW
    67     struct SumWithOverflowPack {
    68         Value * sum;
    69         Value * obit;
    70     };
    71     #endif
    7252
    7353    typedef std::unordered_map<const pablo::PabloAST *, Value *>   ASTToValueMap;
     
    121101}
    122102
    123 #endif // LLVM_GENERATOR_H
     103#endif // PABLO_COMPILER_H
Note: See TracChangeset for help on using the changeset viewer.