Ignore:
Timestamp:
May 7, 2017, 4:34:48 PM (2 years ago)
Author:
nmedfort
Message:

Continued refactoring work. PabloKernel? now abstract base type with a 'generatePabloMethod' hook to generate Pablo code.

File:
1 edited

Legend:

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

    r5435 r5436  
    55
    66#include "streamset.h"
    7 #include <IR_Gen/idisa_builder.h>  // for IDISA_Builder
    8 #include <llvm/IR/BasicBlock.h>    // for BasicBlock
    9 #include <llvm/IR/Constants.h>     // for ConstantInt
    10 #include <llvm/IR/DataLayout.h>    // for DataLayout
    11 #include <llvm/IR/DerivedTypes.h>  // for IntegerType (ptr only), PointerType
    12 #include <llvm/IR/Module.h>        // for Module
    13 #include <llvm/IR/Value.h>         // for Value
     7#include <llvm/IR/Module.h>
    148#include <llvm/Support/raw_ostream.h>
    15 #include <llvm/IR/CFG.h>
    169#include <kernels/kernel.h>
     10#include <kernels/kernel_builder.h>
    1711#include <toolchain/toolchain.h>
    1812
     
    2418using namespace IDISA;
    2519
    26 ArrayType * resolveStreamSetType(const std::unique_ptr<IDISA_Builder> &b, Type * type);
    27 
    28 StructType * resolveExpandableStreamSetType(const std::unique_ptr<IDISA::IDISA_Builder> & b, Type * type);
    29 
    30 void StreamSetBuffer::allocateBuffer(const std::unique_ptr<IDISA_Builder> & iBuilder) {
     20ArrayType * resolveStreamSetType(const std::unique_ptr<kernel::KernelBuilder> & b, Type * type);
     21
     22StructType * resolveExpandableStreamSetType(const std::unique_ptr<kernel::KernelBuilder> & b, Type * type);
     23
     24void StreamSetBuffer::allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) {
    3125    if (LLVM_LIKELY(mStreamSetBufferPtr == nullptr)) {
    3226        Type * const ty = getType();
     
    139133}
    140134
    141 Value * StreamSetBuffer::getBaseAddress(IDISA::IDISA_Builder * const iBuilder, Value * self) const {
     135Value * StreamSetBuffer::getBaseAddress(IDISA::IDISA_Builder * const /* iBuilder */, Value * self) const {
    142136    return self;
    143137}
    144138
    145 void StreamSetBuffer::releaseBuffer(IDISA::IDISA_Builder * const iBuilder, Value * /* self */) const {
     139void StreamSetBuffer::releaseBuffer(IDISA::IDISA_Builder * const /* iBuilder */, Value * /* self */) const {
    146140    /* do nothing: memory is stack allocated */
    147141}
     
    220214
    221215// External File Buffer
    222 void ExternalBuffer::allocateBuffer(const std::unique_ptr<IDISA_Builder> &) {
     216void ExternalBuffer::allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> &) {
    223217    report_fatal_error("External buffers cannot be allocated.");
    224218}
     
    238232
    239233// CircularCopybackBuffer Buffer
    240 void CircularCopybackBuffer::allocateBuffer(const std::unique_ptr<IDISA_Builder> & iBuilder) {
     234void CircularCopybackBuffer::allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) {
    241235    mStreamSetBufferPtr = iBuilder->CreateCacheAlignedAlloca(getType(), iBuilder->getSize(mBufferBlocks + mOverflowBlocks));
    242236}
     
    261255// SwizzledCopybackBuffer Buffer
    262256
    263 void SwizzledCopybackBuffer::allocateBuffer(const std::unique_ptr<IDISA_Builder> & iBuilder) {
     257void SwizzledCopybackBuffer::allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) {
    264258    mStreamSetBufferPtr = iBuilder->CreateCacheAlignedAlloca(getType(), iBuilder->getSize(mBufferBlocks + mOverflowBlocks));
    265259}
     
    318312// Expandable Buffer
    319313
    320 void ExpandableBuffer::allocateBuffer(const std::unique_ptr<IDISA_Builder> & iBuilder) {
     314void ExpandableBuffer::allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & iBuilder) {
    321315    mStreamSetBufferPtr = iBuilder->CreateCacheAlignedAlloca(getType());
    322316    Value * const capacityPtr = iBuilder->CreateGEP(mStreamSetBufferPtr, {iBuilder->getInt32(0), iBuilder->getInt32(0)});
     
    469463
    470464// Constructors
    471 SingleBlockBuffer::SingleBlockBuffer(const std::unique_ptr<IDISA::IDISA_Builder> &  b, Type * type)
     465SingleBlockBuffer::SingleBlockBuffer(const std::unique_ptr<kernel::KernelBuilder> &  b, Type * type)
    472466: StreamSetBuffer(BufferKind::BlockBuffer, type, resolveStreamSetType(b, type), 1, 0) {
    473467    mUniqueID = "S";
     
    475469}
    476470
    477 SourceBuffer::SourceBuffer(const std::unique_ptr<IDISA_Builder> & b, Type * type, unsigned AddressSpace)
     471SourceBuffer::SourceBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, Type * type, unsigned AddressSpace)
    478472: StreamSetBuffer(BufferKind::SourceBuffer, type, StructType::get(resolveStreamSetType(b, type)->getPointerTo(), b->getSizeTy(), nullptr), 0, AddressSpace) {
    479473    mUniqueID = "M"; // + std::to_string(bufferBlocks);
     
    481475}
    482476
    483 ExternalBuffer::ExternalBuffer(const std::unique_ptr<IDISA_Builder> & b, Type * type, llvm::Value * addr, unsigned AddressSpace)
     477ExternalBuffer::ExternalBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, Type * type, llvm::Value * addr, unsigned AddressSpace)
    484478: StreamSetBuffer(BufferKind::ExternalBuffer, type, resolveStreamSetType(b, type), 0, AddressSpace) {
    485479    mUniqueID = "E";
     
    488482}
    489483
    490 CircularBuffer::CircularBuffer(const std::unique_ptr<IDISA::IDISA_Builder> & b, Type * type, size_t bufferBlocks, unsigned AddressSpace)
     484CircularBuffer::CircularBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, Type * type, size_t bufferBlocks, unsigned AddressSpace)
    491485: StreamSetBuffer(BufferKind::CircularBuffer, type, resolveStreamSetType(b, type), bufferBlocks, AddressSpace) {
    492486    mUniqueID = "C" + std::to_string(bufferBlocks);
     
    494488}
    495489
    496 CircularCopybackBuffer::CircularCopybackBuffer(const std::unique_ptr<IDISA::IDISA_Builder> & b, Type * type, size_t bufferBlocks, size_t overflowBlocks, unsigned AddressSpace)
     490CircularCopybackBuffer::CircularCopybackBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, Type * type, size_t bufferBlocks, size_t overflowBlocks, unsigned AddressSpace)
    497491: StreamSetBuffer(BufferKind::CircularCopybackBuffer, type, resolveStreamSetType(b, type), bufferBlocks, AddressSpace), mOverflowBlocks(overflowBlocks) {
    498492    mUniqueID = "CC" + std::to_string(bufferBlocks);
     
    501495}
    502496
    503 ExpandableBuffer::ExpandableBuffer(const std::unique_ptr<IDISA_Builder> & b, Type * type, size_t bufferBlocks, unsigned AddressSpace)
     497ExpandableBuffer::ExpandableBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, Type * type, size_t bufferBlocks, unsigned AddressSpace)
    504498: StreamSetBuffer(BufferKind::ExpandableBuffer, type, resolveExpandableStreamSetType(b, type), bufferBlocks, AddressSpace)
    505499, mInitialCapacity(type->getArrayNumElements()) {
     
    508502}
    509503
    510 SwizzledCopybackBuffer::SwizzledCopybackBuffer(const std::unique_ptr<IDISA::IDISA_Builder> & b, Type * type, size_t bufferBlocks, size_t overflowBlocks, unsigned fieldwidth, unsigned AddressSpace)
     504SwizzledCopybackBuffer::SwizzledCopybackBuffer(const std::unique_ptr<kernel::KernelBuilder> & b, Type * type, size_t bufferBlocks, size_t overflowBlocks, unsigned fieldwidth, unsigned AddressSpace)
    511505: StreamSetBuffer(BufferKind::SwizzledCopybackBuffer, type, resolveStreamSetType(b, type), bufferBlocks, AddressSpace), mOverflowBlocks(overflowBlocks), mFieldWidth(fieldwidth) {
    512506    mUniqueID = "SW" + std::to_string(fieldwidth) + ":" + std::to_string(bufferBlocks);
     
    533527
    534528// Helper routines
    535 ArrayType * resolveStreamSetType(const std::unique_ptr<IDISA::IDISA_Builder> & b, Type * type) {
     529ArrayType * resolveStreamSetType(const std::unique_ptr<kernel::KernelBuilder> & b, Type * type) {
    536530    unsigned numElements = 1;
    537531    if (LLVM_LIKELY(type->isArrayTy())) {
     
    557551}
    558552
    559 StructType * resolveExpandableStreamSetType(const std::unique_ptr<IDISA_Builder> & b, Type * type) {
     553StructType * resolveExpandableStreamSetType(const std::unique_ptr<kernel::KernelBuilder> & b, Type * type) {
    560554    if (LLVM_LIKELY(type->isArrayTy())) {
    561555        type = type->getArrayElementType();
Note: See TracChangeset for help on using the changeset viewer.