Ignore:
Timestamp:
Jan 19, 2017, 2:41:02 PM (2 years ago)
Author:
nmedfort
Message:

Code clean-up. Removed Pablo Call, SetIthBit? and Prototype.

Location:
icGREP/icgrep-devel/icgrep/kernels
Files:
19 edited

Legend:

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

    r5260 r5267  
    1414using namespace pablo;
    1515using namespace re;
     16using namespace llvm;
    1617
    1718void DirectCharacterClassKernelBuilder::generateDoBlockMethod() const {
  • icGREP/icgrep-devel/icgrep/kernels/cc_kernel.h

    r5246 r5267  
    66#define CC_KERNEL_H
    77
    8 #include "streamset.h"
    9 #include "interface.h"
    10 #include "kernel.h"
    11 #include <pablo/pablo_kernel.h>
    12 
    13 namespace re {
    14     class CC;
    15 }
     8#include <pablo/pablo_kernel.h>  // for PabloKernel
     9#include "kernel.h"              // for KernelBuilder
     10#include <vector>                // for vector
     11#include <string>                // for string
     12namespace IDISA { class IDISA_Builder; }
     13namespace re { class CC; }
    1614
    1715namespace kernel {
     
    2321   
    2422    DirectCharacterClassKernelBuilder(IDISA::IDISA_Builder * iBuilder, std::string ccSetName, std::vector<re::CC *> charClasses, unsigned codeUnitSize)
    25     : KernelBuilder(iBuilder, "cc",
     23    : KernelBuilder(iBuilder, std::move(ccSetName),
    2624                  {Binding{iBuilder->getStreamSetTy(1, 8 * codeUnitSize), "codeUnitStream"}},
    2725                  {Binding{iBuilder->getStreamSetTy(charClasses.size(), 1), "ccStream"}},
  • icGREP/icgrep-devel/icgrep/kernels/deletion.h

    r5260 r5267  
    66#define DELETION_H
    77
    8 #include "streamset.h"
    9 #include "interface.h"
    108#include "kernel.h"
    11 
    12 
    13 namespace llvm { class Module; class Value;}
    14 
    159namespace IDISA { class IDISA_Builder; }
    1610
     
    2519// algorithm.
    2620//
    27 
    28 using namespace parabix;
    2921
    3022namespace kernel {
     
    4234
    4335private:
    44     unsigned mDeletionFieldWidth;
    45     unsigned mStreamCount;
     36    const unsigned mDeletionFieldWidth;
     37    const unsigned mStreamCount;
    4638};
    4739
  • icGREP/icgrep-devel/icgrep/kernels/interface.cpp

    r5263 r5267  
    1616using namespace llvm;
    1717
    18 void KernelInterface::addKernelDeclarations(Module * client) {
     18void KernelInterface::addKernelDeclarations(Module * client) const {
    1919    Module * saveModule = iBuilder->getModule();
    2020    auto savePoint = iBuilder->saveIP();
  • icGREP/icgrep-devel/icgrep/kernels/interface.h

    r5263 r5267  
    4040     */
    4141   
    42     std::string getName() const { return mKernelName;}
     42    const std::string & getName() const { return mKernelName;}
    4343       
    44     std::vector<Binding> getStreamInputs() {return mStreamSetInputs;}
    45     std::vector<Binding> getStreamOutputs() {return mStreamSetOutputs;}
    46     std::vector<Binding> getScalarInputs() { return mScalarInputs;}
    47     std::vector<Binding> getScalarOutputs() { return mScalarOutputs;}
     44    const std::vector<Binding> & getStreamInputs() const {return mStreamSetInputs;}
     45    const std::vector<Binding> & getStreamOutputs() const {return mStreamSetOutputs;}
     46    const std::vector<Binding> & getScalarInputs() const { return mScalarInputs;}
     47    const std::vector<Binding> & getScalarOutputs() const { return mScalarOutputs;}
    4848   
    4949   
    5050    // Add ExternalLinkage method declarations for the kernel to a given client module.
    51     void addKernelDeclarations(llvm::Module * client);
     51    void addKernelDeclarations(llvm::Module * client) const;
    5252    virtual void createInstance() = 0;
    5353    void setInitialArguments(std::vector<llvm::Value *> args);
     
    7979
    8080    KernelInterface(IDISA::IDISA_Builder * builder,
    81                     std::string kernelName,
     81                    std::string && kernelName,
    8282                    std::vector<Binding> stream_inputs,
    8383                    std::vector<Binding> stream_outputs,
    8484                    std::vector<Binding> scalar_inputs,
    8585                    std::vector<Binding> scalar_outputs,
    86                     std::vector<Binding> internal_scalars) :
    87     iBuilder(builder),
    88     mKernelName(kernelName),
    89     mStreamSetInputs(stream_inputs),
    90     mStreamSetOutputs(stream_outputs),
    91     mScalarInputs(scalar_inputs),
    92     mScalarOutputs(scalar_outputs),
    93     mInternalScalars(internal_scalars),
    94     mKernelStateType(nullptr),
    95     mKernelInstance(nullptr),
    96     mLookAheadPositions(0) {}
     86                    std::vector<Binding> internal_scalars)
     87    : iBuilder(builder)
     88    , mKernelName(kernelName)
     89    , mStreamSetInputs(stream_inputs)
     90    , mStreamSetOutputs(stream_outputs)
     91    , mScalarInputs(scalar_inputs)
     92    , mScalarOutputs(scalar_outputs)
     93    , mInternalScalars(internal_scalars)
     94    , mKernelStateType(nullptr)
     95    , mKernelInstance(nullptr)
     96    , mLookAheadPositions(0) {
     97
     98    }
    9799   
    98100protected:
    99101   
    100102    IDISA::IDISA_Builder * const iBuilder;
    101     std::string mKernelName;
     103    const std::string mKernelName;
    102104    std::vector<llvm::Value *> mInitialArguments;
    103105    std::vector<Binding> mStreamSetInputs;
  • icGREP/icgrep-devel/icgrep/kernels/kernel.cpp

    r5266 r5267  
    88#include <llvm/Support/ErrorHandling.h>  // for report_fatal_error
    99#include <toolchain.h>                   // for BufferSegments, SegmentSize
    10 #include "IR_Gen/idisa_builder.h"        // for IDISA_Builder
    11 #include "kernels/streamset.h"           // for StreamSetBuffer
    12 #include "llvm/ADT/StringRef.h"          // for StringRef, operator==
    13 #include "llvm/IR/CallingConv.h"         // for ::C
    14 #include "llvm/IR/Constant.h"            // for Constant
    15 #include "llvm/IR/Constants.h"           // for ConstantInt
    16 #include "llvm/IR/Function.h"            // for Function, Function::arg_iter...
    17 #include "llvm/IR/Instructions.h"        // for LoadInst (ptr only), PHINode
    18 #include "llvm/Support/Compiler.h"       // for LLVM_UNLIKELY
     10#include <kernels/streamset.h>           // for StreamSetBuffer
     11#include <llvm/ADT/StringRef.h>          // for StringRef, operator==
     12#include <llvm/IR/CallingConv.h>         // for ::C
     13#include <llvm/IR/Constant.h>            // for Constant
     14#include <llvm/IR/Constants.h>           // for ConstantInt
     15#include <llvm/IR/Function.h>            // for Function, Function::arg_iter...
     16#include <llvm/IR/Instructions.h>        // for LoadInst (ptr only), PHINode
     17#include <llvm/IR/Module.h>
     18#include <llvm/Support/Compiler.h>       // for LLVM_UNLIKELY
     19#include <llvm/Support/raw_ostream.h>
    1920namespace llvm { class BasicBlock; }
    20 namespace llvm { class Module; }
    2121namespace llvm { class Type; }
    2222
     
    2626
    2727KernelBuilder::KernelBuilder(IDISA::IDISA_Builder * builder,
    28                              std::string kernelName,
     28                             std::string && kernelName,
    2929                             std::vector<Binding> stream_inputs,
    3030                             std::vector<Binding> stream_outputs,
     
    3232                             std::vector<Binding> scalar_outputs,
    3333                             std::vector<Binding> internal_scalars)
    34 : KernelInterface(builder, kernelName, stream_inputs, stream_outputs, scalar_parameters, scalar_outputs, internal_scalars),
    35 mNoTerminateAttribute(false),
    36 mDoBlockUpdatesProducedItemCountsAttribute(false) {
     34: KernelInterface(builder, std::move(kernelName), stream_inputs, stream_outputs, scalar_parameters, scalar_outputs, internal_scalars)
     35, mNoTerminateAttribute(false)
     36, mDoBlockUpdatesProducedItemCountsAttribute(false) {
    3737
    3838}
     
    442442    Module * m = iBuilder->getModule();
    443443    Type * const voidTy = iBuilder->getVoidTy();
    444     Type * const voidPtrTy = iBuilder->getVoidPtrTy();
    445     Type * const int8PtrTy = iBuilder->getInt8PtrTy();
    446     Type * const int1ty = iBuilder->getInt1Ty();
     444    PointerType * const voidPtrTy = iBuilder->getVoidPtrTy();
     445    PointerType * const int8PtrTy = iBuilder->getInt8PtrTy();
     446    IntegerType * const int1ty = iBuilder->getInt1Ty();
    447447   
    448448    Function * const threadFunc = cast<Function>(m->getOrInsertFunction(name, voidTy, int8PtrTy, nullptr));
  • icGREP/icgrep-devel/icgrep/kernels/kernel.h

    r5266 r5267  
    9191    // Constructor
    9292    KernelBuilder(IDISA::IDISA_Builder * builder,
    93                     std::string kernelName,
     93                    std::string && kernelName,
    9494                    std::vector<Binding> stream_inputs,
    9595                    std::vector<Binding> stream_outputs,
  • icGREP/icgrep-devel/icgrep/kernels/mmap_kernel.cpp

    r5266 r5267  
    5656
    5757
    58 MMapSourceKernel::MMapSourceKernel(IDISA::IDISA_Builder * iBuilder, unsigned blocksPerSegment, unsigned codeUnitWidth) :
    59 KernelBuilder(iBuilder, "mmap_source",
    60               {}, {Binding{iBuilder->getStreamSetTy(1, codeUnitWidth), "sourceBuffer"}},
    61               {Binding{iBuilder->getSizeTy(), "fileSize"}}, {}, {})
     58MMapSourceKernel::MMapSourceKernel(IDISA::IDISA_Builder * iBuilder, unsigned blocksPerSegment, unsigned codeUnitWidth)
     59: KernelBuilder(iBuilder, "mmap_source", {}, {Binding{iBuilder->getStreamSetTy(1, codeUnitWidth), "sourceBuffer"}}, {Binding{iBuilder->getSizeTy(), "fileSize"}}, {}, {})
    6260, mSegmentBlocks(blocksPerSegment)
    6361, mCodeUnitWidth(codeUnitWidth) {
  • icGREP/icgrep-devel/icgrep/kernels/mmap_kernel.h

    r5265 r5267  
    2020   
    2121private:
    22     unsigned mSegmentBlocks;
    23     unsigned mCodeUnitWidth;
    24  
     22
    2523    void generateDoSegmentMethod() const override;
     24
     25private:
     26    const unsigned mSegmentBlocks;
     27    const unsigned mCodeUnitWidth;
    2628   
    2729};
  • icGREP/icgrep-devel/icgrep/kernels/p2s_kernel.cpp

    r5261 r5267  
    11#include "p2s_kernel.h"
    2 #include "kernels/kernel.h"
    3 #include "IR_Gen/idisa_builder.h"
    4 #include <llvm/IR/Type.h>
     2#include "IR_Gen/idisa_builder.h"  // for IDISA_Builder
     3#include "llvm/IR/Constant.h"      // for Constant
     4#include "llvm/IR/Constants.h"     // for ConstantInt
     5#include "llvm/IR/DerivedTypes.h"  // for PointerType, VectorType
     6#include "llvm/IR/Function.h"      // for Function, Function::arg_iterator
    57#include <llvm/IR/Module.h>
    6 #include <iostream>
    7 #include <stdint.h>
    8 #include <llvm/Support/FileSystem.h>
    9 #include <llvm/Support/raw_ostream.h>
     8#include <kernels/streamset.h>
     9namespace llvm { class Value; }
    1010
    1111using namespace llvm;
     
    116116}
    117117   
    118 P2SKernelWithCompressedOutput::P2SKernelWithCompressedOutput(IDISA::IDISA_Builder * iBuilder) :
    119     KernelBuilder(iBuilder, "p2s_compress",
    120                   {Binding{iBuilder->getStreamSetTy(8, 1), "basisBits"}, Binding{iBuilder->getStreamSetTy(1, 1), "deletionCounts"}},
    121                   {Binding{iBuilder->getStreamSetTy(1, 8), "byteStream"}},
    122                   {}, {}, {}) {
    123         setDoBlockUpdatesProducedItemCountsAttribute(true);
    124 
    125     }
     118P2SKernelWithCompressedOutput::P2SKernelWithCompressedOutput(IDISA::IDISA_Builder * iBuilder)
     119: KernelBuilder(iBuilder, "p2s_compress",
     120              {Binding{iBuilder->getStreamSetTy(8, 1), "basisBits"}, Binding{iBuilder->getStreamSetTy(1, 1), "deletionCounts"}},
     121              {Binding{iBuilder->getStreamSetTy(1, 8), "byteStream"}},
     122              {}, {}, {}) {
     123    setDoBlockUpdatesProducedItemCountsAttribute(true);
     124}
    126125   
    127126   
     
    178177    auto savePoint = iBuilder->saveIP();
    179178    Module * m = iBuilder->getModule();
    180     Type * i32 = iBuilder->getIntNTy(32);
    181     Type * bitBlockPtrTy = llvm::PointerType::get(iBuilder->getBitBlockType(), 0);
     179    Type * i32Ty = iBuilder->getInt32Ty();
     180    Type * bitBlockPtrTy = iBuilder->getBitBlockType()->getPointerTo();
    182181
    183182    Function * doBlockFunction = m->getFunction(mKernelName + doBlock_suffix);
     
    212211    Value * i16BlockNo = iBuilder->CreateUDiv(i16UnitsGenerated, stride);
    213212    Value * u16_output_ptr = getStreamView(int16PtrTy, self, "i16Stream", i16BlockNo, iBuilder->CreateURem(i16UnitsGenerated, stride));
    214     Value * offset = ConstantInt::get(i32, 0);
     213    Value * offset = ConstantInt::get(i32Ty, 0);
    215214    for (unsigned j = 0; j < 8; ++j) {
    216215        Value * merge0 = iBuilder->bitCast(iBuilder->esimd_mergel(8, hi_bytes[j], lo_bytes[j]));
    217216        Value * merge1 = iBuilder->bitCast(iBuilder->esimd_mergeh(8, hi_bytes[j], lo_bytes[j]));
    218217        iBuilder->CreateAlignedStore(merge0, iBuilder->CreateBitCast(iBuilder->CreateGEP(u16_output_ptr, offset), bitBlockPtrTy), 1);
    219         offset = iBuilder->CreateZExt(iBuilder->CreateExtractElement(unit_counts, iBuilder->getInt32(2 * j)), i32);
     218        offset = iBuilder->CreateZExt(iBuilder->CreateExtractElement(unit_counts, iBuilder->getInt32(2 * j)), i32Ty);
    220219        iBuilder->CreateAlignedStore(merge1, iBuilder->CreateBitCast(iBuilder->CreateGEP(u16_output_ptr, offset), bitBlockPtrTy), 1);
    221         offset = iBuilder->CreateZExt(iBuilder->CreateExtractElement(unit_counts, iBuilder->getInt32(2 * j + 1)), i32);
     220        offset = iBuilder->CreateZExt(iBuilder->CreateExtractElement(unit_counts, iBuilder->getInt32(2 * j + 1)), i32Ty);
    222221    }
    223222    i16UnitsGenerated = iBuilder->CreateAdd(i16UnitsGenerated, iBuilder->CreateZExt(offset, iBuilder->getSizeTy()));
  • icGREP/icgrep-devel/icgrep/kernels/p2s_kernel.h

    r5261 r5267  
    66#define P2S_KERNEL_H
    77
    8 #include "streamset.h"
    9 #include "interface.h"
    10 #include "kernel.h"
    11 
    12 namespace llvm { class Module; }
    13 
     8#include "kernel.h"  // for KernelBuilder
    149namespace IDISA { class IDISA_Builder; }
    1510
  • icGREP/icgrep-devel/icgrep/kernels/pipeline.cpp

    r5266 r5267  
    66#include "pipeline.h"
    77#include <toolchain.h>
    8 #include <IR_Gen/idisa_builder.h>
    9 #include <kernels/interface.h>
    108#include <kernels/kernel.h>
    11 #include <iostream>
     9#include <llvm/IR/Module.h>
    1210#include <unordered_map>
    1311
     
    8179    Type * const size_ty = iBuilder->getSizeTy();
    8280    Type * const voidTy = iBuilder->getVoidTy();
    83     Type * const voidPtrTy = iBuilder->getVoidPtrTy();
    84     Type * const int8PtrTy = iBuilder->getInt8PtrTy();
     81    PointerType * const voidPtrTy = iBuilder->getVoidPtrTy();
     82    PointerType * const int8PtrTy = iBuilder->getInt8PtrTy();
    8583
    8684    Function * const threadFunc = cast<Function>(m->getOrInsertFunction(name, voidTy, int8PtrTy, nullptr));
     
    185183    Module * m = iBuilder->getModule();
    186184   
    187     Type * const size_ty = iBuilder->getSizeTy();
    188     Type * const voidPtrTy = iBuilder->getVoidPtrTy();
    189     Type * const int8PtrTy = iBuilder->getInt8PtrTy();
     185    IntegerType * const size_ty = iBuilder->getSizeTy();
     186    PointerType * const voidPtrTy = iBuilder->getVoidPtrTy();
     187    PointerType * const int8PtrTy = iBuilder->getInt8PtrTy();
    190188   
    191189    for (auto k : kernels) k->createInstance();
     
    238236void generatePipelineParallel(IDISA::IDISA_Builder * iBuilder, const std::vector<KernelBuilder *> & kernels) {
    239237   
    240     Type * pthreadTy = iBuilder->getSizeTy();
    241     Type * const voidPtrTy = iBuilder->getVoidPtrTy();
    242     Type * const int8PtrTy = iBuilder->getInt8PtrTy();
    243    
    244     Type * const pthreadsTy = ArrayType::get(pthreadTy, kernels.size());
     238    IntegerType * pthreadTy = iBuilder->getSizeTy();
     239    PointerType * const voidPtrTy = iBuilder->getVoidPtrTy();
     240    PointerType * const int8PtrTy = iBuilder->getInt8PtrTy();
     241   
     242    ArrayType * const pthreadsTy = ArrayType::get(pthreadTy, kernels.size());
    245243   
    246244    for (auto k : kernels) k->createInstance();
  • icGREP/icgrep-devel/icgrep/kernels/radix64.cpp

    r5261 r5267  
    44 */
    55#include "radix64.h"
    6 //#include "expand3_4.h"
    7 #include <kernels/kernel.h>
     6#include <kernels/streamset.h>
    87#include <IR_Gen/idisa_builder.h>
    98#include <llvm/IR/Module.h>
  • icGREP/icgrep-devel/icgrep/kernels/radix64.h

    r5261 r5267  
    66#define RADIX64_H
    77
    8 #include "streamset.h"
    9 #include "interface.h"
    108#include "kernel.h"
    119
  • icGREP/icgrep-devel/icgrep/kernels/s2p_kernel.h

    r5260 r5267  
    2626};
    2727
    28    
    29 
    3028}
    3129#endif
  • icGREP/icgrep-devel/icgrep/kernels/scanmatchgen.cpp

    r5260 r5267  
    44 */
    55
    6 #include "kernel.h"
    76#include "scanmatchgen.h"
    87#include <llvm/IR/Intrinsics.h>
    98#include <IR_Gen/idisa_builder.h>
    109#include <llvm/IR/Module.h>
    11 #include <llvm/Support/raw_os_ostream.h>
    1210
    1311using namespace llvm;
  • icGREP/icgrep-devel/icgrep/kernels/scanmatchgen.h

    r5246 r5267  
    66#define SCANMATCHGEN_H
    77
    8 #include "streamset.h"
    9 #include "kernel.h"
    10 #include "grep_type.h"
    11 #include <llvm/Support/Host.h>
    12 #include <llvm/ADT/Triple.h>
    13 
    14 namespace llvm { class Module; class Function;}
    15 
    16 namespace IDISA { class IDISA_Builder; }
     8#include "grep_type.h"  // for GrepType
     9#include "kernel.h"     // for KernelBuilder
     10namespace IDISA { class IDISA_Builder; }  // lines 16-16
     11namespace llvm { class Function; }  // lines 14-14
     12namespace llvm { class Module; }  // lines 14-14
    1713
    1814namespace kernel {
     
    3127       
    3228private:
     29
    3330    void generateDoBlockMethod() const override;
     31
    3432    llvm::Function * generateScanWordRoutine(llvm::Module * m) const;
    35        
     33
     34private:
    3635    GrepType mGrepType;
    3736};
  • icGREP/icgrep-devel/icgrep/kernels/stdout_kernel.cpp

    r5265 r5267  
    66#include <llvm/IR/Module.h>
    77#include <IR_Gen/idisa_builder.h>
     8#include <kernels/streamset.h>
     9// #include <llvm/IR/Type.h>
     10namespace llvm { class Type; }
    811
    912using namespace llvm;
     
    2730    /* unused Value * doFinal = &*(args++);*/ args++;
    2831    Value * producerPos = &*(args++);
    29     ////iBuilder->CallPrintInt("blocksToDo", blocksToDo);
    3032    Value * streamStructPtr = getStreamSetStructPtr(self, "codeUnitBuffer");
    31     //iBuilder->CallPrintInt("streamStructPtr", iBuilder->CreatePtrToInt(streamStructPtr, iBuilder->getInt64Ty()));
    32 
    33     //iBuilder->CallPrintInt("producerPos", producerPos);
    3433    Value * processed = getProcessedItemCount(self, "codeUnitBuffer");
    3534    Value * itemsToDo = iBuilder->CreateSub(producerPos, processed);
     
    4948}
    5049
     50StdOutKernel::StdOutKernel(IDISA::IDISA_Builder * iBuilder, unsigned codeUnitWidth)
     51: KernelBuilder(iBuilder, "stdout", {Binding{iBuilder->getStreamSetTy(1, codeUnitWidth), "codeUnitBuffer"}}, {}, {}, {}, {})
     52, mCodeUnitWidth(codeUnitWidth) {
     53    setNoTerminateAttribute(true);
    5154}
     55
     56}
  • icGREP/icgrep-devel/icgrep/kernels/stdout_kernel.h

    r5265 r5267  
    66#define STDOUT_KERNEL_H
    77
    8 #include "streamset.h"
    98#include "kernel.h"
    10 #include <llvm/IR/Type.h>
    119
    1210namespace IDISA { class IDISA_Builder; }
     
    1614class StdOutKernel : public KernelBuilder {
    1715public:
    18     StdOutKernel(IDISA::IDISA_Builder * iBuilder, unsigned codeUnitWidth) :
    19     KernelBuilder(iBuilder, "stdout",
    20                   {Binding{iBuilder->getStreamSetTy(1, codeUnitWidth), "codeUnitBuffer"}}, {}, {}, {}, {}),
    21     mCodeUnitWidth(codeUnitWidth) {
    22         setNoTerminateAttribute(true);
    23     }
     16
     17    StdOutKernel(IDISA::IDISA_Builder * iBuilder, unsigned codeUnitWidth);
    2418   
    2519private:
    26     unsigned mCodeUnitWidth;
    2720 
    2821    void generateDoSegmentMethod() const override;
     22
     23private:
     24    const unsigned mCodeUnitWidth;
    2925   
    3026};
Note: See TracChangeset for help on using the changeset viewer.