Ignore:
Timestamp:
Nov 2, 2018, 7:18:31 PM (12 months ago)
Author:
nmedfort
Message:

Initial version of PipelineKernel? + revised StreamSet? model.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/toolchain/driver.cpp

    r5998 r6184  
    11#include "driver.h"
    22#include <kernels/kernel_builder.h>
    3 #include <kernels/streamset.h>
    4 #include <kernels/kernel.h>
     3#include <kernels/pipeline_builder.h>
    54#include <llvm/IR/Module.h>
     5#include <toolchain/toolchain.h>
     6#include <toolchain/object_cache.h>
     7#include <llvm/Support/raw_ostream.h>
    68
    7 using namespace llvm;
    8 using namespace parabix;
     9using namespace kernel;
    910
    10 using Kernel = kernel::Kernel;
    11 using KernelBuilder = kernel::KernelBuilder;
     11using RelationshipAllocator = Relationship::Allocator;
    1212
    13 Driver::Driver(std::string && moduleName)
    14 : mContext(new llvm::LLVMContext())
    15 , mMainModule(new Module(moduleName, *mContext))
    16 , iBuilder(nullptr) {
    17 
     13/** ------------------------------------------------------------------------------------------------------------- *
     14 * @brief makePipelineWithIO
     15 ** ------------------------------------------------------------------------------------------------------------- */
     16std::unique_ptr<PipelineBuilder> BaseDriver::makePipelineWithIO(Bindings stream_inputs, Bindings stream_outputs, Bindings scalar_inputs, Bindings scalar_outputs) {
     17    return llvm::make_unique<PipelineBuilder>(*this, std::move(stream_inputs), std::move(stream_outputs), std::move(scalar_inputs), std::move(scalar_outputs));
    1818}
    1919
    20 void Driver::deallocateBuffers() {
    21     for (const auto & b : mOwnedBuffers) {
    22         b->releaseBuffer(iBuilder);
     20/** ------------------------------------------------------------------------------------------------------------- *
     21 * @brief makePipeline
     22 ** ------------------------------------------------------------------------------------------------------------- */
     23std::unique_ptr<kernel::PipelineBuilder> BaseDriver::makePipeline(Bindings scalar_inputs, Bindings scalar_outputs) {
     24    return llvm::make_unique<PipelineBuilder>(*this, Bindings{}, Bindings{}, std::move(scalar_inputs), std::move(scalar_outputs));
     25}
     26
     27/** ------------------------------------------------------------------------------------------------------------- *
     28 * @brief CreateStreamSet
     29 ** ------------------------------------------------------------------------------------------------------------- */
     30StreamSet * BaseDriver::CreateStreamSet(const unsigned NumElements, const unsigned FieldWidth) {
     31    RelationshipAllocator A(mAllocator);
     32    return new (A) StreamSet(getContext(), NumElements, FieldWidth);
     33}
     34
     35/** ------------------------------------------------------------------------------------------------------------- *
     36 * @brief CreateConstant
     37 ** ------------------------------------------------------------------------------------------------------------- */
     38Scalar * BaseDriver::CreateScalar(llvm::Type * scalarType) {
     39    RelationshipAllocator A(mAllocator);
     40    return new (A) Scalar(scalarType);
     41}
     42
     43/** ------------------------------------------------------------------------------------------------------------- *
     44 * @brief CreateConstant
     45 ** ------------------------------------------------------------------------------------------------------------- */
     46Scalar * BaseDriver::CreateConstant(llvm::Constant * const value) {
     47    RelationshipAllocator A(mAllocator);
     48    return new (A) ScalarConstant(value);
     49}
     50
     51/** ------------------------------------------------------------------------------------------------------------- *
     52 * @brief makeCache
     53 ** ------------------------------------------------------------------------------------------------------------- */
     54void BaseDriver::addKernel(Kernel * const kernel) {
     55    if (ObjectCacheManager::checkForCachedKernel(iBuilder, kernel)) {
     56        assert (kernel->getModule());
     57        mCachedKernel.emplace_back(kernel);
     58    } else {
     59        if (kernel->getModule() == nullptr) {
     60            kernel->makeModule(iBuilder);
     61        }
     62        mUncachedKernel.emplace_back(kernel);
    2363    }
    2464}
    2565
    26 Driver::~Driver() {}
     66/** ------------------------------------------------------------------------------------------------------------- *
     67 * @brief constructor
     68 ** ------------------------------------------------------------------------------------------------------------- */
     69BaseDriver::BaseDriver(std::string && moduleName)
     70: mContext(new llvm::LLVMContext())
     71, mMainModule(new llvm::Module(moduleName, *mContext))
     72, iBuilder(nullptr) {
     73    ObjectCacheManager::initializeCacheSystems();
     74}
     75
     76/** ------------------------------------------------------------------------------------------------------------- *
     77 * @brief deconstructor
     78 ** ------------------------------------------------------------------------------------------------------------- */
     79BaseDriver::~BaseDriver() {
     80
     81}
Note: See TracChangeset for help on using the changeset viewer.