Ignore:
Timestamp:
Feb 10, 2017, 1:48:34 PM (2 years ago)
Author:
nmedfort
Message:

Adjusted pablo compiler to use getInputStream and getOutputStream when accessing packed stream fields.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/kernel.cpp

    r5307 r5310  
    6262    }
    6363    for (unsigned i = 0; i < mStreamSetOutputs.size(); i++) {
    64         mStreamSetNameMap.emplace(mStreamSetOutputs[i].name, mStreamSetInputs.size() + i);
     64        mStreamSetNameMap.emplace(mStreamSetOutputs[i].name, i);
    6565    }
    6666}
     
    253253}
    254254
    255 inline static uint64_t log2(const uint64_t x) {
    256     return (64 - __builtin_clzll(x)) - 1;
    257 }
    258 
    259 inline static uint32_t log2(const uint32_t x) {
    260     return (32 - __builtin_clz(x)) - 1;
    261 }
    262 
    263255inline Value * KernelBuilder::computeBlockIndex(const std::vector<Binding> & bindings, const std::string & name, Value * itemCount) const {
    264256    for (const Binding & b : bindings) {
     
    266258            const auto divisor = (b.step == 0) ? iBuilder->getBitBlockWidth() : b.step;
    267259            if (LLVM_LIKELY((divisor & (divisor - 1)) == 0)) {
    268                 return iBuilder->CreateLShr(itemCount, log2(divisor));
     260                return iBuilder->CreateLShr(itemCount, std::log2(divisor));
    269261            } else {
    270262                return iBuilder->CreateUDiv(itemCount, iBuilder->getSize(divisor));
     
    277269Value * KernelBuilder::getInputStream(const std::string & name, Value * streamIndex) const {
    278270    Value * const blockIndex = computeBlockIndex(mStreamSetInputs, name, getProcessedItemCount(name));
    279     const StreamSetBuffer * const buf = getStreamSetBuffer(name);
     271    const StreamSetBuffer * const buf = getInputStreamSetBuffer(name);
    280272    return buf->getStream(getStreamSetBufferPtr(name), streamIndex, blockIndex);
    281273}
     
    283275Value * KernelBuilder::getInputStream(const std::string & name, Value * streamIndex, Value * packIndex) const {
    284276    Value * const blockIndex = computeBlockIndex(mStreamSetInputs, name, getProcessedItemCount(name));
    285     const StreamSetBuffer * const buf = getStreamSetBuffer(name);
     277    const StreamSetBuffer * const buf = getInputStreamSetBuffer(name);
    286278    return buf->getStream(getStreamSetBufferPtr(name), streamIndex, blockIndex, packIndex);
    287279}
     
    289281Value * KernelBuilder::getOutputStream(const std::string & name, Value * streamIndex) const {
    290282    Value * const blockIndex = computeBlockIndex(mStreamSetOutputs, name, getProducedItemCount(name));
    291     const StreamSetBuffer * const buf = getStreamSetBuffer(name);
     283    const StreamSetBuffer * const buf = getOutputStreamSetBuffer(name);
    292284    return buf->getStream(getStreamSetBufferPtr(name), streamIndex, blockIndex);
    293285}
     
    295287Value * KernelBuilder::getOutputStream(const std::string & name, Value * streamIndex, Value * packIndex) const {
    296288    Value * const blockIndex = computeBlockIndex(mStreamSetOutputs, name, getProducedItemCount(name));
    297     const StreamSetBuffer * const buf = getStreamSetBuffer(name);
     289    const StreamSetBuffer * const buf = getOutputStreamSetBuffer(name);
    298290    return buf->getStream(getStreamSetBufferPtr(name), streamIndex, blockIndex, packIndex);
    299291}
    300292
    301 Value * KernelBuilder::getRawItemPointer(const std::string & name, Value * streamIndex, Value * absolutePosition) const {
    302     return getStreamSetBuffer(name)->getRawItemPointer(getStreamSetBufferPtr(name), streamIndex, absolutePosition);
     293Value * KernelBuilder::getRawInputPointer(const std::string & name, Value * streamIndex, Value * absolutePosition) const {
     294    return getInputStreamSetBuffer(name)->getRawItemPointer(getStreamSetBufferPtr(name), streamIndex, absolutePosition);
     295}
     296
     297Value * KernelBuilder::getRawOutputPointer(const std::string & name, Value * streamIndex, Value * absolutePosition) const {
     298    return getOutputStreamSetBuffer(name)->getRawItemPointer(getStreamSetBufferPtr(name), streamIndex, absolutePosition);
    303299}
    304300
     
    306302    const auto f = mStreamSetNameMap.find(name);
    307303    if (LLVM_UNLIKELY(f == mStreamSetNameMap.end())) {
    308         report_fatal_error("Kernel " + getName() + " does not contain stream set: " + name);
     304        throw std::runtime_error("Kernel " + getName() + " does not contain stream set: " + name);
    309305    }
    310306    return f->second;
    311 }
    312 
    313 const StreamSetBuffer * KernelBuilder::getStreamSetBuffer(const std::string & name) const {
    314     const unsigned structIdx = getStreamSetIndex(name);
    315     if (structIdx < mStreamSetInputs.size()) {
    316         return mStreamSetInputBuffers[structIdx];
    317     } else {
    318         return mStreamSetOutputBuffers[structIdx - mStreamSetInputs.size()];
    319     }
    320307}
    321308
     
    341328}
    342329
    343 Value * KernelBuilder::getStreamSetPtr(const std::string & name, Value * blockNo) const {
    344     return getStreamSetBuffer(name)->getStreamSetPtr(getStreamSetBufferPtr(name), blockNo);
     330Value * KernelBuilder::getInputStreamSetPtr(const std::string & name, Value * blockNo) const {
     331    return getInputStreamSetBuffer(name)->getStreamSetPtr(getStreamSetBufferPtr(name), blockNo);
    345332}
    346333
Note: See TracChangeset for help on using the changeset viewer.