Memory Allocation

## Classes

class | tbb::cache_aligned_allocator< T >
| Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5. More...
class | tbb::cache_aligned_allocator< void >
| Analogous to std::allocator<void>, as defined in ISO C++ Standard, Section 20.4.1. More...
class | tbb::interface6::memory_pool_allocator< T, P >
| Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5. More...
class | tbb::interface6::memory_pool_allocator< void, P >
| Analogous to std::allocator<void>, as defined in ISO C++ Standard, Section 20.4.1. More...
class | tbb::tbb_allocator< T >
| Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5. More...
class | tbb::tbb_allocator< void >
| Analogous to std::allocator<void>, as defined in ISO C++ Standard, Section 20.4.1. More...
class | tbb::zero_allocator< T, Allocator >
| Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5. More...
class | tbb::zero_allocator< void, Allocator >
| Analogous to std::allocator<void>, as defined in ISO C++ Standard, Section 20.4.1. More...

## Functions

template<typename T , size_t N = 1>
class | tbb::__TBB_DEPRECATED_VERBOSE_MSG ("tbb::aligned_space is deprecated, use std::aligned_storage") aligned_space
| Block of space aligned sufficiently to construct an array T with N elements. More...
size_t __TBB_EXPORTED_FUNC | tbb::internal::NFS_GetLineSize ()
| Cache/sector line size. More...
void *__TBB_EXPORTED_FUNC | tbb::internal::NFS_Allocate (size_t n_element, size_t element_size, void *hint)
| Allocate memory on cache/sector line boundary. More...
void __TBB_EXPORTED_FUNC | tbb::internal::NFS_Free (void *)
| Free memory allocated by NFS_Allocate. More...
void *__TBB_EXPORTED_FUNC | scalable_malloc (size_t size)
void __TBB_EXPORTED_FUNC | scalable_free (void *ptr)
void *__TBB_EXPORTED_FUNC | scalable_realloc (void *ptr, size_t size)
void *__TBB_EXPORTED_FUNC | scalable_calloc (size_t nobj, size_t size)
int __TBB_EXPORTED_FUNC | scalable_posix_memalign (void **memptr, size_t alignment, size_t size)
void *__TBB_EXPORTED_FUNC | scalable_aligned_malloc (size_t size, size_t alignment)
void *__TBB_EXPORTED_FUNC | scalable_aligned_realloc (void *ptr, size_t size, size_t alignment)
void __TBB_EXPORTED_FUNC | scalable_aligned_free (void *ptr)
size_t __TBB_EXPORTED_FUNC | scalable_msize (void *ptr)
int __TBB_EXPORTED_FUNC | scalable_allocation_mode (int param, intptr_t value)
int __TBB_EXPORTED_FUNC | scalable_allocation_command (int cmd, void *param)

## Variables

const size_t | tbb::internal::NFS_MaxLineSize = 128
| Compile-time constant that is upper bound on cache line/sector size. More...

## Detailed Description

## Function Documentation

## __TBB_DEPRECATED_VERBOSE_MSG()

template<typename T , size_t N = 1>

class tbb::__TBB_DEPRECATED_VERBOSE_MSG | ( | "tbb::aligned_space is | deprecated,
|  | use std::aligned_storage" |
| ) |  |

Block of space aligned sufficiently to construct an array T with N elements.

The elements are not constructed or destroyed by this class.

Pointer to beginning of array

Pointer to one past last element in array.

Definition at line 43 of file aligned_space.h.

{
private:
typedef __TBB_TypeWithAlignmentAtLeastAsStrict(T) element_type;
element_type array[(sizeof(T)*N+sizeof(element_type)-1)/sizeof(element_type)];
public:
T* begin() const {return internal::punned_cast<T*>(this);}
T* end() const {return begin()+N;}
};

References __TBB_TypeWithAlignmentAtLeastAsStrict, begin, and end.

## NFS_Allocate()

void * tbb::internal::NFS_Allocate | ( | size_t | n_element,
|  | size_t | element_size,
|  | void * | hint
| ) |  |

Allocate memory on cache/sector line boundary.

Definition at line 176 of file cache_aligned_allocator.cpp.

{
//TODO: make this functionality available via an adaptor over generic STL like allocator
const size_t nfs_cache_line_size = NFS_LineSize;
__TBB_ASSERT( nfs_cache_line_size <= NFS_MaxLineSize, "illegal value for NFS_LineSize" );
__TBB_ASSERT( is_power_of_two(nfs_cache_line_size), "must be power of two" );
size_t bytes = n*element_size;
if (bytes<n || bytes+nfs_cache_line_size<bytes) {
// Overflow
throw_exception(eid_bad_alloc);
}
// scalable_aligned_malloc considers zero size request an error, and returns NULL
if (bytes==0) bytes = 1;
void* result = (*padded_allocate_handler)( bytes, nfs_cache_line_size );
if (!result)
throw_exception(eid_bad_alloc);
__TBB_ASSERT( is_aligned(result, nfs_cache_line_size), "The address returned isn't aligned to cache line size" );
return result;
}

References __TBB_ASSERT, tbb::internal::eid_bad_alloc, tbb::internal::is_aligned(), tbb::internal::is_power_of_two(), tbb::internal::NFS_LineSize, tbb::internal::NFS_MaxLineSize, and tbb::internal::throw_exception().

Referenced by tbb::cache_aligned_allocator< T >::allocate(), tbb::internal::arena::allocate_arena(), tbb::internal::custom_scheduler< SchedulerTraits >::allocate_scheduler(), tbb::internal::generic_scheduler::allocate_task(), tbb::internal::arena_slot::allocate_task_pool(), tbb::internal::arena::arena(), tbb::internal::generic_scheduler::create_master(), tbb::internal::concurrent_vector_base_v3::helper::extend_segment_table(), tbb::internal::cpu_ctl_env::get_env(), tbb::internal::market::global_market(), tbb::internal::cpu_ctl_env::operator=(), tbb::internal::fast_reverse_vector< T, max_segments >::push_back(), and tbb::internal::affinity_partitioner_base_v3::resize().

Here is the call graph for this function:
Here is the caller graph for this function:

## NFS_Free()

void tbb::internal::NFS_Free | ( | void * | p | ) |

Free memory allocated by NFS_Allocate.

Freeing a NULL pointer is allowed, but has no effect.

Definition at line 198 of file cache_aligned_allocator.cpp.

{
(*padded_free_handler)( p );
}

References p.

Referenced by tbb::internal::generic_scheduler::cleanup_master(), tbb::cache_aligned_allocator< T >::deallocate(), tbb::internal::generic_scheduler::deallocate_task(), tbb::internal::market::destroy(), tbb::internal::generic_scheduler::destroy(), tbb::internal::mail_outbox::drain(), tbb::internal::concurrent_vector_base_v3::helper::extend_segment_table(), tbb::internal::arena::free_arena(), tbb::internal::arena_slot::free_task_pool(), tbb::internal::generic_scheduler::prepare_task_pool(), tbb::internal::affinity_partitioner_base_v3::resize(), tbb::internal::concurrent_vector_base_v3::~concurrent_vector_base_v3(), tbb::internal::cpu_ctl_env::~cpu_ctl_env(), and tbb::internal::fast_reverse_vector< T, max_segments >::~fast_reverse_vector().

Here is the caller graph for this function:

## NFS_GetLineSize()

size_t tbb::internal::NFS_GetLineSize | ( |  | ) |

Cache/sector line size.

Definition at line 167 of file cache_aligned_allocator.cpp.

{
return NFS_LineSize;
}

References tbb::internal::NFS_LineSize.

Referenced by tbb::internal::arena::allocate_arena(), tbb::internal::arena::arena(), tbb::strict_ppl::internal::concurrent_queue_base_v3< Value >::concurrent_queue_base_v3(), and tbb::internal::concurrent_queue_base_v3::concurrent_queue_base_v3().

Here is the caller graph for this function:

## scalable_aligned_free()

void __TBB_EXPORTED_FUNC scalable_aligned_free | ( | void * | ptr | ) |

The "_aligned_free" analogue.

## scalable_aligned_malloc()

void* __TBB_EXPORTED_FUNC scalable_aligned_malloc | ( | size_t | size,
|  | size_t | alignment
| ) |  |

The "_aligned_malloc" analogue.

## scalable_aligned_realloc()

void* __TBB_EXPORTED_FUNC scalable_aligned_realloc | ( | void * | ptr,
|  | size_t | size,
|  | size_t | alignment
| ) |  |

The "_aligned_realloc" analogue.

## scalable_allocation_command()

int __TBB_EXPORTED_FUNC scalable_allocation_command | ( | int | cmd,
|  | void * | param
| ) |  |

Call TBB allocator-specific commands.

## scalable_allocation_mode()

int __TBB_EXPORTED_FUNC scalable_allocation_mode | ( | int | param,
|  | intptr_t | value
| ) |  |

Set TBB allocator-specific allocation modes.

## scalable_calloc()

void* __TBB_EXPORTED_FUNC scalable_calloc | ( | size_t | nobj,
|  | size_t | size
| ) |  |

The "calloc" analogue complementing scalable_malloc.

## scalable_free()

void __TBB_EXPORTED_FUNC scalable_free | ( | void * | ptr | ) |

The "free" analogue to discard a previously allocated piece of memory.

## scalable_malloc()

void* __TBB_EXPORTED_FUNC scalable_malloc | ( | size_t | size | ) |

The "malloc" analogue to allocate block of memory of size bytes.

## scalable_msize()

size_t __TBB_EXPORTED_FUNC scalable_msize | ( | void * | ptr | ) |

The analogue of msize/malloc_size/malloc_usable_size. Returns the usable size of a memory block previously allocated by scalable*, or 0 (zero) if ptr does not point to such a block.

## scalable_posix_memalign()

int __TBB_EXPORTED_FUNC scalable_posix_memalign | ( | void ** | memptr,
|  | size_t | alignment,
|  | size_t | size
| ) |  |

The "posix_memalign" analogue.

## scalable_realloc()

void* __TBB_EXPORTED_FUNC scalable_realloc | ( | void * | ptr,
|  | size_t | size
| ) |  |

The "realloc" analogue complementing scalable_malloc.

## Variable Documentation

## NFS_MaxLineSize

const size_t tbb::internal::NFS_MaxLineSize = 128

Compile-time constant that is upper bound on cache line/sector size.

It should be used only in situations where having a compile-time upper bound is more useful than a run-time exact answer.

Definition at line 216 of file tbb_stddef.h.

Referenced by tbb::internal::arena::allocate_arena(), tbb::internal::arena_slot::allocate_task_pool(), tbb::internal::mail_outbox::construct(), tbb::cache_aligned_allocator< T >::max_size(), and tbb::internal::NFS_Allocate().

end
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp end
Definition: ittnotify_static.h:182
__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
tbb::internal::throw_exception
void throw_exception(exception_id eid)
Versionless convenience wrapper for throw_exception_v4()
Definition: tbb_exception.h:105
begin
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp begin
Definition: ittnotify_static.h:182
tbb::internal::is_power_of_two
bool is_power_of_two(integer_type arg)
A function to check if passed integer is a power of 2.
Definition: tbb_stddef.h:376
tbb::internal::NFS_MaxLineSize
const size_t NFS_MaxLineSize
Compile-time constant that is upper bound on cache line/sector size.
Definition: tbb_stddef.h:216
tbb::internal::NFS_LineSize
static size_t NFS_LineSize
Definition: cache_aligned_allocator.cpp:165
tbb::internal::is_aligned
bool is_aligned(T *pointer, uintptr_t alignment)
A function to check if passed in pointer is aligned on a specific border.
Definition: tbb_stddef.h:370
__TBB_TypeWithAlignmentAtLeastAsStrict
#define __TBB_TypeWithAlignmentAtLeastAsStrict(T)
Definition: tbb_machine.h:819
tbb::internal::eid_bad_alloc
Definition: tbb_exception.h:68
p
void const char const char int ITT_FORMAT __itt_group_sync p
Definition: ittnotify_static.h:91

Copyright © 2005-2020 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.