source: icGREP/icgrep-devel/icgrep/toolchain/driver.cpp @ 5544

Last change on this file since 5544 was 5544, checked in by cameron, 23 months ago

Deallocating dynamic buffers

File size: 1.1 KB
Line 
1#include "driver.h"
2#include <kernels/kernel_builder.h>
3#include <kernels/streamset.h>
4#include <kernels/kernel.h>
5#include <llvm/IR/Module.h>
6
7using namespace llvm;
8using namespace parabix;
9
10using Kernel = kernel::Kernel;
11using KernelBuilder = kernel::KernelBuilder;
12
13Driver::Driver(std::string && moduleName)
14: mContext(new llvm::LLVMContext())
15, mMainModule(new Module(moduleName, *mContext))
16, iBuilder(nullptr) {
17
18}
19
20ExternalBuffer * Driver::addExternalBuffer(std::unique_ptr<ExternalBuffer> b) {
21    mOwnedBuffers.emplace_back(std::move(b));
22    return cast<ExternalBuffer>(mOwnedBuffers.back().get());
23}
24
25StreamSetBuffer * Driver::addBuffer(std::unique_ptr<StreamSetBuffer> b) {
26    b->allocateBuffer(iBuilder);
27    mOwnedBuffers.emplace_back(std::move(b));
28    return mOwnedBuffers.back().get();
29}
30
31kernel::Kernel * Driver::addKernelInstance(std::unique_ptr<kernel::Kernel> kb) {
32    mOwnedKernels.emplace_back(std::move(kb));
33    return mOwnedKernels.back().get();
34}
35
36void Driver::deallocateBuffers() {
37    for (auto &b : mOwnedBuffers) {
38        b->releaseBuffer(iBuilder);
39    }
40}
Note: See TracBrowser for help on using the repository browser.