Intel® oneAPI Threading Building Blocks Developer Guide and API Reference
ID
772616
Date
3/31/2025
Public
A newer version of this document is available. Customers should click here to go to the newest version.
Package Contents
Parallelizing Simple Loops
Parallelizing Complex Loops
Parallelizing Data Flow and Dependence Graphs
Work Isolation
Exceptions and Cancellation
Containers
Mutual Exclusion
Timing
Memory Allocation
The Task Scheduler
Design Patterns
Migrating from Threading Building Blocks (TBB)
Constrained APIs
Appendix A Costs of Time Slicing
Appendix B Mixing With Other Threading Packages
References
parallel_for_each Body semantics and requirements
parallel_sort ranges interface extension
TBB_malloc_replacement_log Function
Parallel Reduction for rvalues
Type-specified message keys for join_node
Scalable Memory Pools
Helper Functions for Expressing Graphs
concurrent_lru_cache
task_group extensions
The customizing mutex type for concurrent_hash_map
Waiting for Single Messages in Flow Graph
parallel_phase Interface for Task Arena
Deduction Guides for blocked_nd_range
fixed_pool
NOTE:
To enable this feature, set the TBB_PREVIEW_MEMORY_POOL macro to 1.
A class for scalable memory allocation from a buffer of fixed size.
Description
fixed_pool allocates and frees memory in a way that scales with the number of processors. All the memory available for the allocation is initially passed through arguments of the constructor. fixed_pool meet the Memory Pool named requirement.
API
Header
#include "oneapi/tbb/memory_pool.h"
Synopsis
namespace oneapi {
namespace tbb {
class fixed_pool {
public:
fixed_pool(void *buffer, size_t size);
fixed_pool(const fixed_pool& other) = delete;
fixed_pool& operator=(const fixed_pool& other) = delete;
~fixed_pool();
void recycle();
void* malloc(size_t size);
void free(void* ptr);
void* realloc(void* ptr, size_t size);
};
} // namespace tbb
} // namespace oneapi
Member Functions
fixed_pool(void*buffer, size_tsize)
Effects: Constructs a memory pool to manage the memory of size size pointed to by buffer. Throws the bad_alloc exception if the library fails to construct an instance of the class.
Examples
The code below provides a simple example of allocation from a fixed pool.
#define TBB_PREVIEW_MEMORY_POOL 1
#include "oneapi/tbb/memory_pool.h"
int main() {
char buf[1024];
oneapi::tbb::fixed_pool my_pool(buf, 1024);
void* my_ptr = my_pool.malloc(10);
my_pool.free(my_ptr);
}