Halide 22.0.0 Halide compiler and libraries

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

Allocator class interface for sub-allocating a contiguous memory block into smaller regions of memory. More...

`#include <region_allocator.h>`

## Classes
struct | MemoryAllocators

## Public Member Functions
| RegionAllocator (const RegionAllocator &)=delete
RegionAllocator & | operator= (const RegionAllocator &)=delete
| RegionAllocator ()=delete
| ~RegionAllocator ()=delete
MemoryRegion * | reserve (void *user_context, const MemoryRequest &request)
int | conform (void *user_context, MemoryRequest *request) const
int | release (void *user_context, MemoryRegion *memory_region)
int | reclaim (void *user_context, MemoryRegion *memory_region)
int | retain (void *user_context, MemoryRegion *memory_region)
bool | collect (void *user_context)
int | release (void *user_context)
int | destroy (void *user_context)
BlockResource * | block_resource () const

## Static Public Member Functions
static RegionAllocator * | create (void *user_context, BlockResource *block, const MemoryAllocators &ma)
static int | destroy (void *user_context, RegionAllocator *region_allocator)
static RegionAllocator * | find_allocator (void *user_context, MemoryRegion *memory_region)

## Detailed Description

Allocator class interface for sub-allocating a contiguous memory block 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 24 of file region_allocator.h.

## Constructor & Destructor Documentation

## ◆ RegionAllocator() [1/2]

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

## ◆ RegionAllocator() [2/2]

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

## ◆ ~RegionAllocator()

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

## Member Function Documentation

## ◆ operator=()

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

## ◆ create()

RegionAllocator * Halide::Runtime::Internal::RegionAllocator::create | ( | void * | user_context,
|  | BlockResource * | block,
|  | const MemoryAllocators & | ma
| ) |  |
| static

Definition at line 114 of file region_allocator.h.

References Halide::Runtime::Internal::SystemMemoryAllocatorFns::allocate, block_resource(), halide_abort_if_false, Halide::Runtime::Internal::RegionAllocator::MemoryAllocators::system, and user_context.

## ◆ destroy() [1/2]

int Halide::Runtime::Internal::RegionAllocator::destroy | ( | void * | user_context,
|  | RegionAllocator * | region_allocator
| ) |  |
| static

Definition at line 127 of file region_allocator.h.

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

Referenced by destroy().

## ◆ find_allocator()

RegionAllocator * Halide::Runtime::Internal::RegionAllocator::find_allocator | ( | void * | user_context,
|  | MemoryRegion * | memory_region
| ) |  |
| static

Definition at line 240 of file region_allocator.h.

References Halide::Runtime::Internal::BlockResource::allocator, and Halide::Runtime::Internal::BlockRegion::block_ptr.

Referenced by Halide::Runtime::Internal::Vulkan::VulkanMemoryAllocator::allocate_region(), Halide::Runtime::Internal::Vulkan::VulkanMemoryAllocator::create_crop(), Halide::Runtime::Internal::Vulkan::VulkanMemoryAllocator::destroy_crop(), Halide::Runtime::Internal::Vulkan::VulkanMemoryAllocator::map(), Halide::Runtime::Internal::BlockAllocator::reclaim(), Halide::Runtime::Internal::BlockAllocator::release(), Halide::Runtime::Internal::BlockAllocator::retain(), and Halide::Runtime::Internal::Vulkan::VulkanMemoryAllocator::unmap().

## ◆ reserve()

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

Definition at line 166 of file region_allocator.h.

References conform(), debug, error_code, halide_abort_if_false, Halide::Runtime::Internal::BlockResource::memory, Halide::Runtime::Internal::BlockRegion::memory, Halide::Runtime::Internal::BlockResource::reserved, Halide::Runtime::Internal::MemoryBlock::size, Halide::Runtime::Internal::MemoryRegion::size, Halide::Runtime::Internal::MemoryRequest::size, and user_context.

## ◆ conform()

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

Definition at line 152 of file region_allocator.h.

References Halide::Runtime::Internal::aligned_offset(), Halide::Runtime::Internal::MemoryProperties::alignment, Halide::Runtime::Internal::MemoryRequest::alignment, Halide::Runtime::Internal::MemoryRegionAllocatorFns::conform, Halide::Runtime::Internal::conform_alignment(), Halide::Runtime::Internal::conform_size(), Halide::Runtime::Internal::BlockResource::memory, Halide::Runtime::Internal::MemoryProperties::nearest_multiple, Halide::Runtime::Internal::MemoryRequest::offset, Halide::Runtime::Internal::MemoryBlock::properties, Halide::Runtime::Internal::RegionAllocator::MemoryAllocators::region, Halide::Runtime::Internal::MemoryRequest::size, and user_context.

Referenced by reserve().

## ◆ release() [1/2]

int Halide::Runtime::Internal::RegionAllocator::release | ( | void * | user_context,
|  | MemoryRegion * | memory_region
| ) |  |

Definition at line 210 of file region_allocator.h.

References Halide::Runtime::Internal::BlockRegion::block_ptr, halide_abort_if_false, Halide::Runtime::Internal::BlockRegion::usage_count, and user_context.

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

## ◆ reclaim()

int Halide::Runtime::Internal::RegionAllocator::reclaim | ( | void * | user_context,
|  | MemoryRegion * | memory_region
| ) |  |

Definition at line 220 of file region_allocator.h.

References Halide::Runtime::Internal::BlockRegion::block_ptr, halide_abort_if_false, Halide::Runtime::Internal::BlockRegion::usage_count, and user_context.

## ◆ retain()

int Halide::Runtime::Internal::RegionAllocator::retain | ( | void * | user_context,
|  | MemoryRegion * | memory_region
| ) |  |

Definition at line 232 of file region_allocator.h.

References Halide::Runtime::Internal::BlockRegion::block_ptr, halide_abort_if_false, Halide::Runtime::Internal::BlockRegion::usage_count, and user_context.

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

## ◆ collect()

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

Definition at line 692 of file region_allocator.h.

References Halide::Runtime::Internal::BlockRegion::block_ptr, debug, Halide::Runtime::Internal::BlockRegion::memory, Halide::Runtime::Internal::BlockRegion::next_ptr, Halide::Runtime::Internal::BlockResource::regions, Halide::Runtime::Internal::BlockResource::reserved, Halide::Runtime::Internal::MemoryRegion::size, Halide::Runtime::Internal::BlockRegion::status, Halide::Runtime::Internal::BlockRegion::usage_count, and user_context.

Referenced by Halide::Runtime::Internal::BlockAllocator::collect().

## ◆ release() [2/2]

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

Definition at line 675 of file region_allocator.h.

References debug, Halide::Runtime::Internal::BlockRegion::next_ptr, Halide::Runtime::Internal::BlockResource::regions, and user_context.

## ◆ destroy() [2/2]

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

Definition at line 771 of file region_allocator.h.

References Halide::Runtime::Internal::BlockResource::allocator, debug, Halide::Runtime::Internal::MemoryArena::destroy(), Halide::Runtime::Internal::BlockRegion::next_ptr, Halide::Runtime::Internal::BlockResource::regions, Halide::Runtime::Internal::BlockResource::reserved, and user_context.

## ◆ block_resource()

BlockResource * Halide::Runtime::Internal::RegionAllocator::block_resource | ( |  | ) | const

Definition at line 832 of file region_allocator.h.

Referenced by create(), Halide::Runtime::Internal::Vulkan::VulkanMemoryAllocator::map(), and Halide::Runtime::Internal::Vulkan::VulkanMemoryAllocator::unmap().

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

- src/runtime/internal/region_allocator.h