Halide 22.0.0 Halide compiler and libraries

Classes | Public Member Functions | Static Public Member Functions | List of all members
Halide::Runtime::Internal::BlockAllocator Class Reference

Allocator class interface for managing large contiguous blocks of memory, which are then sub-allocated into smaller regions of memory. More...

`#include <block_allocator.h>`

## Classes
struct | Config
struct | MemoryAllocators

## Public Member Functions
| BlockAllocator (const BlockAllocator &)=delete
BlockAllocator & | operator= (const BlockAllocator &)=delete
| BlockAllocator ()=delete
| ~BlockAllocator ()=delete
MemoryRegion * | reserve (void *user_context, const MemoryRequest &request)
int | conform (void *user_context, MemoryRequest *request) const
int | release (void *user_context, MemoryRegion *region)
int | reclaim (void *user_context, MemoryRegion *region)
int | retain (void *user_context, MemoryRegion *region)
bool | collect (void *user_context)
int | release (void *user_context)
int | destroy (void *user_context)
const MemoryAllocators & | current_allocators () const
const Config & | current_config () const
const Config & | default_config () const
size_t | block_count () const
size_t | pool_size () const

## Static Public Member Functions
static BlockAllocator * | create (void *user_context, const Config &config, const MemoryAllocators &allocators)
static void | destroy (void *user_context, BlockAllocator *block_allocator)

## Detailed Description

Allocator class interface for managing large contiguous blocks of memory, which are then sub-allocated into smaller regions of memory.

This class only manages the address creation for the regions – allocation callback functions are used to request the memory from the necessary system or API calls. This class is intended to be used inside of a higher level memory management class that provides thread safety, policy management and API integration for a specific runtime API (eg Vulkan, OpenCL, etc)

Definition at line 25 of file block_allocator.h.

## Constructor & Destructor Documentation

## ◆ BlockAllocator() [1/2]

Halide::Runtime::Internal::BlockAllocator::BlockAllocator | ( | const BlockAllocator & |  | ) |
| delete

## ◆ BlockAllocator() [2/2]

Halide::Runtime::Internal::BlockAllocator::BlockAllocator | ( |  | ) |
| delete

## ◆ ~BlockAllocator()

Halide::Runtime::Internal::BlockAllocator::~BlockAllocator | ( |  | ) |
| delete

## Member Function Documentation

## ◆ operator=()

BlockAllocator & Halide::Runtime::Internal::BlockAllocator::operator= | ( | const BlockAllocator & |  | ) |
| delete

## ◆ create()

BlockAllocator * Halide::Runtime::Internal::BlockAllocator::create | ( | void * | user_context,
|  | const Config & | config,
|  | const MemoryAllocators & | allocators
| ) |  |
| static

Definition at line 124 of file block_allocator.h.

References Halide::Runtime::Internal::SystemMemoryAllocatorFns::allocate, halide_abort_if_false, Halide::Runtime::Internal::BlockAllocator::MemoryAllocators::system, and user_context.

## ◆ destroy() [1/2]

void Halide::Runtime::Internal::BlockAllocator::destroy | ( | void * | user_context,
|  | BlockAllocator * | block_allocator
| ) |  |
| static

Definition at line 138 of file block_allocator.h.

References Halide::Runtime::Internal::SystemMemoryAllocatorFns::deallocate, destroy(), halide_abort_if_false, Halide::Runtime::Internal::BlockAllocator::MemoryAllocators::system, and user_context.

Referenced by Halide::Runtime::Internal::Vulkan::VulkanMemoryAllocator::destroy(), and destroy().

## ◆ reserve()

MemoryRegion * Halide::Runtime::Internal::BlockAllocator::reserve | ( | void * | user_context,
|  | const MemoryRequest & | request
| ) |  |

Definition at line 155 of file block_allocator.h.

References Halide::Runtime::Internal::BlockResource::allocator, Halide::Runtime::Internal::MemoryProperties::caching, debug, Halide::Runtime::Internal::MemoryRequest::dedicated, halide_abort_if_false, halide_memory_caching_name(), halide_memory_usage_name(), halide_memory_visibility_name(), Halide::Runtime::Internal::MemoryRequest::offset, Halide::Runtime::Internal::MemoryRequest::properties, Halide::Runtime::Internal::MemoryRequest::size, Halide::Runtime::Internal::MemoryProperties::usage, user_context, Halide::Runtime::Internal::LinkedList::EntryType::value, and Halide::Runtime::Internal::MemoryProperties::visibility.

Referenced by Halide::Runtime::Internal::Vulkan::VulkanMemoryAllocator::reserve().

## ◆ conform()

int Halide::Runtime::Internal::BlockAllocator::conform | ( | void * | user_context,
|  | MemoryRequest * | request
| ) |  | const

Definition at line 580 of file block_allocator.h.

References Halide::Runtime::Internal::BlockAllocator::MemoryAllocators::block, Halide::Runtime::Internal::MemoryBlockAllocatorFns::conform, Halide::max(), Halide::Runtime::Internal::BlockAllocator::Config::maximum_block_size, Halide::Runtime::Internal::BlockAllocator::Config::minimum_block_size, Halide::Runtime::Internal::BlockAllocator::Config::nearest_multiple, Halide::Runtime::Internal::MemoryProperties::nearest_multiple, Halide::Runtime::Internal::MemoryRequest::properties, Halide::Runtime::Internal::MemoryRequest::size, and user_context.

## ◆ release() [1/2]

int Halide::Runtime::Internal::BlockAllocator::release | ( | void * | user_context,
|  | MemoryRegion * | region
| ) |  |

Definition at line 200 of file block_allocator.h.

References allocator, Halide::Runtime::Internal::RegionAllocator::find_allocator(), halide_error_code_internal_error, and user_context.

Referenced by Halide::Runtime::Internal::Vulkan::VulkanMemoryAllocator::release().

## ◆ reclaim()

int Halide::Runtime::Internal::BlockAllocator::reclaim | ( | void * | user_context,
|  | MemoryRegion * | region
| ) |  |

Definition at line 211 of file block_allocator.h.

References allocator, Halide::Runtime::Internal::RegionAllocator::find_allocator(), halide_error_code_internal_error, and user_context.

Referenced by Halide::Runtime::Internal::Vulkan::VulkanMemoryAllocator::reclaim().

## ◆ retain()

int Halide::Runtime::Internal::BlockAllocator::retain | ( | void * | user_context,
|  | MemoryRegion * | region
| ) |  |

Definition at line 222 of file block_allocator.h.

References allocator, Halide::Runtime::Internal::RegionAllocator::find_allocator(), halide_error_code_internal_error, and user_context.

Referenced by Halide::Runtime::Internal::Vulkan::VulkanMemoryAllocator::retain().

## ◆ collect()

bool Halide::Runtime::Internal::BlockAllocator::collect | ( | void * | user_context | ) |

Definition at line 233 of file block_allocator.h.

References Halide::Runtime::Internal::BlockResource::allocator, Halide::Runtime::Internal::LinkedList::back(), Halide::Runtime::Internal::RegionAllocator::collect(), debug, Halide::Runtime::Internal::LinkedList::EntryType::prev_ptr, Halide::Runtime::Internal::BlockResource::reserved, user_context, and Halide::Runtime::Internal::LinkedList::EntryType::value.

Referenced by Halide::Runtime::Internal::Vulkan::VulkanMemoryAllocator::collect().

## ◆ release() [2/2]

int Halide::Runtime::Internal::BlockAllocator::release | ( | void * | user_context | ) |

Definition at line 268 of file block_allocator.h.

References Halide::Runtime::Internal::LinkedList::back(), Halide::Runtime::Internal::LinkedList::EntryType::prev_ptr, and user_context.

## ◆ destroy() [2/2]

int Halide::Runtime::Internal::BlockAllocator::destroy | ( | void * | user_context | ) |

Definition at line 278 of file block_allocator.h.

References Halide::Runtime::Internal::LinkedList::back(), Halide::Runtime::Internal::LinkedList::destroy(), Halide::Runtime::Internal::LinkedList::EntryType::prev_ptr, and user_context.

## ◆ current_allocators()

const BlockAllocator::MemoryAllocators & Halide::Runtime::Internal::BlockAllocator::current_allocators | ( |  | ) | const

Definition at line 629 of file block_allocator.h.

Referenced by Halide::Runtime::Internal::Vulkan::VulkanMemoryAllocator::create_crop(), Halide::Runtime::Internal::Vulkan::VulkanMemoryAllocator::destroy(), and Halide::Runtime::Internal::Vulkan::VulkanMemoryAllocator::destroy_crop().

## ◆ current_config()

const BlockAllocator::Config & Halide::Runtime::Internal::BlockAllocator::current_config | ( |  | ) | const

Definition at line 633 of file block_allocator.h.

## ◆ default_config()

const BlockAllocator::Config & Halide::Runtime::Internal::BlockAllocator::default_config | ( |  | ) | const

Definition at line 637 of file block_allocator.h.

## ◆ block_count()

size_t Halide::Runtime::Internal::BlockAllocator::block_count | ( |  | ) | const

Definition at line 642 of file block_allocator.h.

References Halide::Runtime::Internal::LinkedList::size().

## ◆ pool_size()

size_t Halide::Runtime::Internal::BlockAllocator::pool_size | ( |  | ) | const

Definition at line 646 of file block_allocator.h.

References Halide::Runtime::Internal::LinkedList::front(), Halide::Runtime::Internal::BlockResource::memory, Halide::Runtime::Internal::LinkedList::EntryType::next_ptr, Halide::Runtime::Internal::MemoryBlock::size, and Halide::Runtime::Internal::LinkedList::EntryType::value.

The documentation for this class was generated from the following file:

- src/runtime/internal/block_allocator.h