Changeset 5544


Ignore:
Timestamp:
Jul 2, 2017, 10:35:03 AM (23 months ago)
Author:
cameron
Message:

Deallocating dynamic buffers

Location:
icGREP/icgrep-devel/icgrep
Files:
4 edited

Legend:

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

    r5543 r5544  
    156156}
    157157
    158 void StreamSetBuffer::releaseBuffer(IDISA::IDISA_Builder * const /* iBuilder */, Value * /* self */) const {
     158void StreamSetBuffer::releaseBuffer(const std::unique_ptr<kernel::KernelBuilder> & /* kb */) const {
    159159    /* do nothing: memory is stack allocated */
    160160}
     
    515515}
    516516
    517 void ExpandableBuffer::releaseBuffer(IDISA::IDISA_Builder * const iBuilder, Value * self) const {
    518     iBuilder->CreateFree(getBaseAddress(iBuilder, self));
     517void ExpandableBuffer::releaseBuffer(const std::unique_ptr<kernel::KernelBuilder> & b) const {
     518    b->CreateFree(getBaseAddress(b.get(), mStreamSetBufferPtr));
    519519}
    520520
     
    643643}
    644644
    645 void DynamicBuffer::releaseBuffer(IDISA::IDISA_Builder * const b, Value * handle) const {
     645void DynamicBuffer::releaseBuffer(const std::unique_ptr<kernel::KernelBuilder> & b) const {
    646646    /* Free the dynamically allocated buffer, but not the stack-allocated buffer struct. */
    647     b->CreateFree(b->CreateLoad(b->CreateGEP(handle, {b->getInt32(0), b->getInt32(int(DynamicBuffer::Field::BaseAddress))})));
     647    b->CreateFree(b->CreateLoad(b->CreateGEP(mStreamSetBufferPtr, {b->getInt32(0), b->getInt32(int(DynamicBuffer::Field::BaseAddress))})));
    648648}
    649649
  • icGREP/icgrep-devel/icgrep/kernels/streamset.h

    r5542 r5544  
    6060    virtual llvm::Type * getStreamSetBlockType() const;
    6161   
    62     virtual void allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
    63 
    64     virtual void releaseBuffer(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self) const;
     62    virtual void allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & kb);
     63
     64    virtual void releaseBuffer(const std::unique_ptr<kernel::KernelBuilder> & kb) const;
    6565
    6666    virtual llvm::Value * getStreamBlockPtr(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self, llvm::Value * streamIndex, llvm::Value * blockIndex, const bool readOnly) const;
     
    280280    llvm::Value * getStreamSetCount(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self) const override;
    281281
    282     void releaseBuffer(IDISA::IDISA_Builder * const iBuilder, llvm::Value * self) const override;
     282    void releaseBuffer(const std::unique_ptr<kernel::KernelBuilder> & kb) const override;
    283283
    284284protected:
     
    311311    void allocateBuffer(const std::unique_ptr<kernel::KernelBuilder> & b) override;
    312312
    313     void releaseBuffer(IDISA::IDISA_Builder * const b, llvm::Value * handle) const override;
     313    void releaseBuffer(const std::unique_ptr<kernel::KernelBuilder> & kb) const override;
    314314
    315315    llvm::Value * getRawItemPointer(IDISA::IDISA_Builder * const b, llvm::Value * handle, llvm::Value * streamIndex, llvm::Value * absolutePosition) const override;
  • icGREP/icgrep-devel/icgrep/toolchain/driver.cpp

    r5474 r5544  
    3434}
    3535
     36void Driver::deallocateBuffers() {
     37    for (auto &b : mOwnedBuffers) {
     38        b->releaseBuffer(iBuilder);
     39    }
     40}
  • icGREP/icgrep-devel/icgrep/toolchain/driver.h

    r5493 r5544  
    4242    virtual bool hasExternalFunction(const llvm::StringRef functionName) const = 0;
    4343
     44    void deallocateBuffers();
     45   
    4446    virtual void finalizeObject() = 0;
    45 
     47   
    4648    virtual void * getMain() = 0; // "main" exists until the driver is deleted
    4749
Note: See TracChangeset for help on using the changeset viewer.