Changeset 5229 for icGREP


Ignore:
Timestamp:
Dec 19, 2016, 12:58:29 PM (3 years ago)
Author:
cameron
Message:

Distinguishing between StreamType? and StreamSetType?; fixing StreamSetBlock? pointer calculations

Location:
icGREP/icgrep-devel/icgrep
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/IDISA/idisa_builder.h

    r5227 r5229  
    168168
    169169    inline Type * getStreamSetTy(const uint64_t NumElements = 1, const uint64_t FieldWidth = 1) {
    170         return StreamType::get(getContext(), NumElements, FieldWidth);
     170        return ArrayType::get(StreamType::get(getContext(), FieldWidth), NumElements);
     171    }
     172   
     173    inline Type * getStreamTy(const uint64_t FieldWidth = 1) {
     174        return StreamType::get(getContext(), FieldWidth);
    171175    }
    172176   
  • icGREP/icgrep-devel/icgrep/IDISA/types/streamtype.cpp

    r5217 r5229  
    88namespace IDISA {
    99
    10 static flat_map<std::pair<unsigned, unsigned>, StreamType *> STREAM_TYPES;
     10static flat_map<unsigned, StreamType *> STREAM_TYPES;
    1111
    12 StreamType * StreamType::get(llvm::LLVMContext & ctx, unsigned NumElements, unsigned FieldWidth) {
    13     const auto f = STREAM_TYPES.find(std::make_pair(NumElements, FieldWidth));
     12StreamType * StreamType::get(llvm::LLVMContext & ctx, unsigned FieldWidth) {
     13    const auto f = STREAM_TYPES.find(FieldWidth);
    1414    if (LLVM_LIKELY(f != STREAM_TYPES.end())) {
    1515        return f->second;
    1616    } else {
    17         StreamType * const T = new StreamType(ctx, NumElements, FieldWidth);
    18         STREAM_TYPES.emplace(std::make_pair(NumElements, FieldWidth), T);
     17        StreamType * const T = new StreamType(ctx, FieldWidth);
     18        STREAM_TYPES.emplace(FieldWidth, T);
    1919        return T;
    2020    }
     
    2222
    2323llvm::Type * StreamType::resolveType(IDISA::IDISA_Builder * const iBuilder) {
    24     return ArrayType::get(iBuilder->getBitBlockType(), mNumElements);
     24    if (mFieldWidth == 1) return iBuilder->getBitBlockType();
     25    return ArrayType::get(iBuilder->getBitBlockType(), mFieldWidth);
    2526}
    2627
    27 StreamType::StreamType(llvm::LLVMContext & C, unsigned NumElements, unsigned FieldWidth)
     28StreamType::StreamType(llvm::LLVMContext & C, unsigned FieldWidth)
    2829: llvm::Type(C, (Type::TypeID)(StreamTyId))
    29 , mNumElements(NumElements)
    3030, mFieldWidth(FieldWidth) {
    3131
  • icGREP/icgrep-devel/icgrep/IDISA/types/streamtype.h

    r5217 r5229  
    1111class StreamType : public llvm::Type {
    1212
    13     StreamType(llvm::LLVMContext & ctx, unsigned NumElements, unsigned FieldWidth);
     13    StreamType(llvm::LLVMContext & ctx, unsigned FieldWidth);
    1414
    1515public:
     
    1919    };
    2020
    21     static StreamType * get(llvm::LLVMContext & ctx, unsigned NumElements, unsigned FieldWidth);
    22 
    23     unsigned getNumElements() const {
    24         return mNumElements;
    25     }
     21    static StreamType * get(llvm::LLVMContext & ctx, unsigned FieldWidth);
    2622
    2723    unsigned getFieldWidth() const {
     
    3026
    3127    StreamType * getStreamElementType() const {
    32         return get(getContext(), 1, mFieldWidth);
     28        return get(getContext(), mFieldWidth);
    3329    }
    3430
     
    4339    }
    4440private:
    45     unsigned mNumElements;
    4641    unsigned mFieldWidth;
    4742};
  • icGREP/icgrep-devel/icgrep/kernels/kernel.h

    r5227 r5229  
    5959    }
    6060
     61    inline Type * getStreamTy(const unsigned FieldWidth = 1) {
     62        return getBuilder()->getStreamTy(FieldWidth);
     63    }
     64   
    6165    inline Type * getStreamSetTy(const unsigned NumElements = 1, const unsigned FieldWidth = 1) {
    6266        return getBuilder()->getStreamSetTy(NumElements, FieldWidth);
  • icGREP/icgrep-devel/icgrep/kernels/p2s_kernel.cpp

    r5227 r5229  
    118118    Value * hi_input[8];
    119119    for (unsigned j = 0; j < 8; ++j) {
    120         hi_input[j] = iBuilder->CreateBlockAlignedLoad(basisBitsBlock_ptr, {iBuilder->getInt32(0), iBuilder->getInt32(j)});
     120        hi_input[j] = iBuilder->CreateBlockAlignedLoad(basisBitsBlock_ptr, {iBuilder->getInt32(0), iBuilder->getInt32(0), iBuilder->getInt32(j)});
    121121    }
    122122    Value * hi_bytes[8];
     
    125125    Value * lo_input[8];
    126126    for (unsigned j = 0; j < 8; ++j) {
    127         lo_input[j] = iBuilder->CreateBlockAlignedLoad(basisBitsBlock_ptr, {iBuilder->getInt32(0), iBuilder->getInt32(j+8)});
     127        lo_input[j] = iBuilder->CreateBlockAlignedLoad(basisBitsBlock_ptr, {iBuilder->getInt32(0), iBuilder->getInt32(0), iBuilder->getInt32(j+8)});
    128128    }
    129129    Value * lo_bytes[8];
  • icGREP/icgrep-devel/icgrep/kernels/s2p_kernel.cpp

    r5217 r5229  
    163163void s2pKernel::generateDoBlockLogic(Value * self, Value * blockNo) {
    164164
    165     Value * bytePtr = iBuilder->CreateMul(blockNo, ConstantInt::get(blockNo->getType(), 8));
    166     Value * byteStream = getStreamSetBlockPtr(self, "byteStream", bytePtr);
     165    Value * byteStream = getStreamSetBlockPtr(self, "byteStream", blockNo);
    167166    Value * basisBits = getStreamSetBlockPtr(self, "basisBits", blockNo);
    168167
    169168    Value * bytepack[8];
    170169    for (unsigned i = 0; i < 8; i++) {
    171         Value * ptr = iBuilder->CreateGEP(byteStream, {iBuilder->getInt32(0), iBuilder->getInt32(i)});
     170        Value * ptr = iBuilder->CreateGEP(byteStream, {iBuilder->getInt32(0), iBuilder->getInt32(0), iBuilder->getInt32(i)});
    172171        bytepack[i] = iBuilder->CreateBlockAlignedLoad(ptr);
    173172    }
  • icGREP/icgrep-devel/icgrep/kernels/streamset.h

    r5217 r5229  
    6767    void setEndOfInput(Value * bufferStructPtr);
    6868   
     69    llvm::Type * resolveStreamTypes(llvm::Type * type) {
     70        if (auto ty = dyn_cast<ArrayType>(type)) {
     71            unsigned numElems = ty->getNumElements();
     72            auto elemTy = ty->getElementType();
     73            if (isa<IDISA::StreamType>(elemTy)) {
     74                return ArrayType::get(cast<IDISA::StreamType>(elemTy)->resolveType(iBuilder), numElems);
     75            }
     76        }
     77        else if (auto ty = dyn_cast<IDISA::StreamType>(type)) {
     78            return ty->resolveType(iBuilder);
     79        }
     80        return type;
     81    }
     82   
    6983protected:
    7084    StreamSetBuffer(BufferKind k, IDISA::IDISA_Builder * b, llvm::Type * type, unsigned blocks, unsigned AddressSpace = 0)
    7185    : mBufferKind(k)
    7286    , iBuilder(b)
    73     , mStreamSetType(isa<IDISA::StreamType>(type) ? cast<IDISA::StreamType>(type)->resolveType(b) : type)
     87    , mStreamSetType(resolveStreamTypes(type))
    7488    , mBufferBlocks(blocks)
    7589    , mAddrSpace(AddressSpace)
  • icGREP/icgrep-devel/icgrep/pablo/builder.hpp

    r5227 r5229  
    191191    }
    192192
     193    Type * getStreamTy(const uint64_t FieldWidth = 1) {
     194        return mPb->getStreamTy(FieldWidth);
     195    }
     196   
    193197    Type * getStreamSetTy(const uint64_t NumElements = 1, const uint64_t FieldWidth = 1) {
    194198        return mPb->getStreamSetTy(NumElements, FieldWidth);
    195199    }
    196 
     200   
    197201    /// Statement Iterator Wrappers
    198202
  • icGREP/icgrep-devel/icgrep/pablo/codegenstate.cpp

    r5227 r5229  
    1515inline void printType(const Type * type, raw_string_ostream & out) {
    1616    if (auto st = dyn_cast<StreamType>(type)) {
    17         out << "<" << st->getNumElements() << " x s" << st->getFieldWidth() << ">";
    18     } else {
    19         type->print(out);
    20     }
     17        out << "s" << st->getFieldWidth();
     18        return;
     19    }
     20    if (auto ty = dyn_cast<ArrayType>(type)) {
     21        unsigned numElems = ty->getNumElements();
     22        auto elemTy = ty->getElementType();
     23        if (auto st = dyn_cast<StreamType>(elemTy)) {
     24            out << "<" << numElems << " x s" << st->getFieldWidth() << ">";
     25            return;
     26        }
     27    }
     28    type->print(out);
    2129}
    2230
     
    5159Var * PabloBlock::createVar(PabloAST * name, Type * type) {
    5260    if (type == nullptr) {
    53         type = getParent()->getStreamSetTy();
     61        type = getParent()->getBuilder()->getStreamTy();
    5462    }
    5563    if (LLVM_UNLIKELY(name == nullptr || !isa<String>(name))) {
  • icGREP/icgrep-devel/icgrep/pablo/codegenstate.h

    r5227 r5229  
    261261    While * createWhile(PabloAST * condition, PabloBlock * body);
    262262
     263    Type * getStreamTy(const uint64_t FieldWidth = 1) {
     264        return mParent->getStreamTy(FieldWidth);
     265    }
     266   
    263267    Type * getStreamSetTy(const uint64_t NumElements = 1, const uint64_t FieldWidth = 1) {
    264268        return mParent->getStreamSetTy(NumElements, FieldWidth);
    265269    }
    266 
     270   
    267271    inline PabloBlock * getPredecessor() const {
    268272        return getBranch() ? getBranch()->getParent() : nullptr;
  • icGREP/icgrep-devel/icgrep/pablo/pablo_kernel.cpp

    r5227 r5229  
    2222    Var * param = new Var(mSymbolTable->make(name), type, true);
    2323    mInputs.push_back(param);
    24     if (isa<StreamType>(type)) {
     24    if (isa<ArrayType>(type) || isa<StreamType>(type)) {
    2525        mStreamSetInputs.emplace_back(type, name);
    2626    } else {
     
    3434    Var * result = new Var(mSymbolTable->make(name), type, false);
    3535    mOutputs.push_back(result);
    36     if (isa<StreamType>(type)) {
     36    if (isa<ArrayType>(type) || isa<StreamType>(type)) {
    3737        mStreamSetOutputs.emplace_back(type, name);
    3838    } else {
     
    5151Zeroes * PabloKernel::getNullValue(Type * type) {
    5252    if (type == nullptr) {
    53         type = getStreamSetTy();
     53        type = getStreamTy();
    5454    }
    5555    for (PabloAST * constant : mConstants) {
     
    6565Ones * PabloKernel::getAllOnesValue(Type * type) {
    6666    if (type == nullptr) {
    67         type = getStreamSetTy();
     67        type = getStreamTy();
    6868    }
    6969    for (PabloAST * constant : mConstants) {
Note: See TracChangeset for help on using the changeset viewer.