Ignore:
Timestamp:
Jan 18, 2018, 1:34:55 PM (15 months ago)
Author:
cameron
Message:

Pablo packh/packl and transposition with -enable-pablo-s2p

File:
1 edited

Legend:

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

    r5822 r5837  
    11/*
    2  *  Copyright (c) 2016 International Characters.
     2 *  Copyright (c) 2018 International Characters.
    33 *  This software is licensed to the public under the Open Software License 3.0.
    44 */
     
    66#include "s2p_kernel.h"
    77#include <kernels/kernel_builder.h>
     8#include <pablo/pabloAST.h>
     9#include <pablo/builder.hpp>
     10#include <pablo/pe_pack.h>
     11
    812#include <llvm/Support/raw_ostream.h>
    913
     
    212216    }
    213217}
    214 #ifdef PABLO_PACKING
    215218void S2P_PabloKernel::generatePabloMethod() {
    216     auto pb = this->getEntryBlock();
     219    pablo::PabloBlock * const pb = getEntryScope();
    217220    const unsigned steps = std::log2(mCodeUnitWidth);
    218221    std::vector<PabloAST *> streamSet[steps + 1];
    219     streamSet[0].push_back(pb->createExtract(getInputStreamVar("codeUnitStream"), pb->getInteger(0)));
     222    for (unsigned i = 0; i <= steps; i++) {
     223        streamSet[i].resize(1<<i);
     224    }
     225    streamSet[0][0] = pb->createExtract(getInputStreamVar("codeUnitStream"), pb->getInteger(0));
    220226    unsigned streamWidth = mCodeUnitWidth;
    221     for (unsigned step = 1; step <= steps; step++) {
    222         for (auto strm : streamSet[i-1]) {
    223             streamSet[i].push_back(pb.createPackL(streamWidth, strm));
    224             streamSet[i].push_back(pb.createPackH(streamWidth, strm));
     227    for (unsigned i = 1; i <= steps; i++) {
     228        for (unsigned j = 0; j < streamSet[i-1].size(); j++) {
     229            auto strm = streamSet[i-1][j];
     230            streamSet[i][2*j] = pb->createPackL(pb->getInteger(streamWidth), strm);
     231            streamSet[i][2*j+1] = pb->createPackH(pb->getInteger(streamWidth), strm);
    225232        }
    226233        streamWidth = streamWidth/2;
    227234    }
    228     for (unsigned bit = 0; bit <= mCodeUnitWidth, bit++) {
    229         pb.createAssign(pb.createExtract(getInputStreamVar("basisBits"), pb.getInteger(bit)), streamSet[steps][bit]);
     235    for (unsigned bit = 0; bit < mCodeUnitWidth; bit++) {
     236        pb->createAssign(pb->createExtract(getOutputStreamVar("basisBits"), pb->getInteger(bit)), streamSet[steps][mCodeUnitWidth-1-bit]);
    230237    }
    231238}
     
    234241: PabloKernel(b, "s2p_pablo" + std::to_string(codeUnitWidth),
    235242    {Binding{b->getStreamSetTy(1, codeUnitWidth), "codeUnitStream"}},
    236     {Binding{b->getStreamSetTy(codeUnitWidth, 1), "basisBits"}}, {}, {}, {}),
     243    {Binding{b->getStreamSetTy(codeUnitWidth, 1), "basisBits"}}),
    237244  mCodeUnitWidth(codeUnitWidth) {
    238245}
    239246
    240 #endif
    241 
    242 }
     247
     248}
Note: See TracChangeset for help on using the changeset viewer.