Ignore:
Timestamp:
Mar 7, 2016, 3:37:30 PM (4 years ago)
Author:
nmedfort
Message:

Initial modifications to Pablo Compiler and Kernel Builder to support circular buffers for Lookahead.

File:
1 edited

Legend:

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

    r4957 r4959  
    11/*
    2  *  Copyright (c) 2015 International Characters.
     2 *  Copyright (c) 2016 International Characters.
    33 *  This software is licensed to the public under the Open Software License 3.0.
    44 */
    5 #include "kernel.h"
    65#include "s2p_kernel.h"
    7 #include <iostream>
     6#include <kernels/kernel.h>
     7#include <IDISA/idisa_builder.h>
    88
    99const int PACK_LANES = 1;
     
    2626}
    2727
    28 void s2p(IDISA::IDISA_Builder * iBuilder, std::vector<Value*> s, Value* p[]) {
     28inline void s2p(IDISA::IDISA_Builder * iBuilder, Value * input, Value * output[]) {
    2929    Value * bit00224466[4];
    3030    Value * bit11335577[4];
    3131    for (unsigned i = 0; i<4; i++) {
    32         s2p_step(iBuilder, s[2*i], s[2*i+1], iBuilder->simd_himask(2), 1, bit00224466[i], bit11335577[i]);
     32        Value * s0 = iBuilder->CreateBlockAlignedLoad(input, {iBuilder->getInt32(0), iBuilder->getInt32(2 * i)});
     33        Value * s1 = iBuilder->CreateBlockAlignedLoad(input, {iBuilder->getInt32(0), iBuilder->getInt32(2 * i + 1)});
     34        s2p_step(iBuilder, s0, s1, iBuilder->simd_himask(2), 1, bit00224466[i], bit11335577[i]);
    3335    }
    3436    Value * bit00004444[2];
     
    4244                 iBuilder->simd_himask(4), 2, bit11115555[j], bit33337777[j]);
    4345    }
    44     s2p_step(iBuilder, bit00004444[0], bit00004444[1], iBuilder->simd_himask(8), 4, p[0], p[4]);
    45     s2p_step(iBuilder, bit11115555[0], bit11115555[1], iBuilder->simd_himask(8), 4, p[1], p[5]);
    46     s2p_step(iBuilder, bit22226666[0], bit22226666[1], iBuilder->simd_himask(8), 4, p[2], p[6]);
    47     s2p_step(iBuilder, bit33337777[0], bit33337777[1], iBuilder->simd_himask(8), 4, p[3], p[7]);
     46    s2p_step(iBuilder, bit00004444[0], bit00004444[1], iBuilder->simd_himask(8), 4, output[0], output[4]);
     47    s2p_step(iBuilder, bit11115555[0], bit11115555[1], iBuilder->simd_himask(8), 4, output[1], output[5]);
     48    s2p_step(iBuilder, bit22226666[0], bit22226666[1], iBuilder->simd_himask(8), 4, output[2], output[6]);
     49    s2p_step(iBuilder, bit33337777[0], bit33337777[1], iBuilder->simd_himask(8), 4, output[3], output[7]);
    4850}
    4951
    50 
    51 void generateS2PKernel(Module * m, IDISA::IDISA_Builder * iBuilder, KernelBuilder * kBuilder){
    52 
    53     kBuilder->addKernelInputStream(8, "byte_pack");
    54     for(int i=0; i<8; i++)
    55         kBuilder->addKernelOutputStream(1);
    56 
    57     int segBlocks = kBuilder->getSegmentBlocks();
    58 
    59     kBuilder->PrepareDoBlockFunction();   
    60     struct Inputs inputs = kBuilder->openDoBlock();
    61     struct Outputs outputs;
    62 
    63     valptr basis_bit[segBlocks][8];
    64     for(int i=0; i<segBlocks; i++){
    65         s2p(iBuilder, inputs.streams[i], basis_bit[i]);
    66         outputs.streams.push_back(basis_bit[i]);
     52void generateS2PKernel(Module *, IDISA::IDISA_Builder * iBuilder, KernelBuilder * kBuilder) {
     53    kBuilder->addInputStream(8, "byte_pack");
     54    for(unsigned i = 0; i < 8; ++i) {
     55        kBuilder->addOutputStream(1);
    6756    }
    68 
    69     kBuilder->closeDoBlock(outputs);
    70 
    71     kBuilder->finalizeMethods();
    72 
     57    kBuilder->prepareFunction();
     58    for(unsigned i = 0; i < kBuilder->getSegmentBlocks(); ++i){
     59        Value * output[8];
     60        s2p(iBuilder, kBuilder->getInputStream(0), output);
     61        for (unsigned j = 0; j < 8; ++j) {
     62            iBuilder->CreateBlockAlignedStore(output[j], kBuilder->getOutputStream(j));
     63        }
     64        kBuilder->increment();
     65    }
     66    kBuilder->finalize();
    7367}
    7468
     
    8377
    8478
     79
Note: See TracChangeset for help on using the changeset viewer.