NumericAL
A header-only C++20 lexer built on REAL
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
numerical::detail::default_init_allocator< T > Struct Template Reference

The allocator of numerical::buffer. An element constructed with no value is default-initialised, so a double keeps whatever its memory held, where std::allocator zeroes it; one constructed with a value is constructed from it. A result written in full is then written once, by the threads that compute it, not zeroed first on one of them (a product of order 512 on eight arm64 threads spent a fifth of its time in that zeroing). More...

#include <buffer.hpp>

Inheritance diagram for numerical::detail::default_init_allocator< T >:
[legend]
Collaboration diagram for numerical::detail::default_init_allocator< T >:
[legend]

Classes

struct  rebind
 The allocator of another element type, as std::allocator_traits rebinds it. More...
 

Public Types

using value_type = T
 The element type.
 

Public Member Functions

 default_init_allocator () noexcept=default
 
template<typename U >
false default_init_allocator (const default_init_allocator< U > &) noexcept
 From the allocator of another element type: stateless, as std::allocator.
 
T * allocate (std::size_t n)
 n elements: on huge pages from their least bytes on Linux, in a kept block of 4 KiB pages from kept_pages_least, else std::allocator's; a block's size and the data's distance from its start kept before the data.
 
void deallocate (T *at, std::size_t n) noexcept
 Frees what allocate gave for n elements.
 
template<typename U >
requires (!is_complex_number<U>)
void construct (U *at) noexcept(std::is_nothrow_default_constructible_v< U >)
 Default-initialises the element at at.
 
template<typename U >
requires is_complex_number<U>
void construct (U *at) noexcept
 construct of a complex number, whose default constructor zeroes: left as its memory holds it, as a double is (an implicit-lifetime type: trivial copies and destructor), so that a complex result written in full is written once (a complex128 product of 914 × 337 spent 172 of its 414 µs zeroing it). Built without NDEBUG, it holds NaN parts instead, so that code that relied on zeros fails.
 
template<typename U , typename ... Args>
void construct (U *at, Args &&... args)
 Constructs the element at at from args.
 

Static Public Member Functions

static constexpr bool on_kept_pages (std::size_t n) noexcept
 Whether n elements take a block of 4 KiB pages kept when freed (kept_page_blocks): from kept_pages_least bytes and under kept_pages_largest (from it, on Linux, huge pages).
 
static T * placed (std::byte *start, std::size_t offset, std::size_t bytes) noexcept
 The data at offset into the block at start of bytes, the offset and the size kept before it.
 
template<typename Kept >
static void deallocate_kept (T *at) noexcept
 Frees the block allocate gave from at, kept by Kept where it takes it. Out of line: inlined where a small buffer's size is known (a QR's columns of 40 complex numbers), GCC 14 took the read before at for one past the buffer's bounds (-Warray-bounds), though a buffer of that size never comes here.
 

Static Public Attributes

static constexpr std::size_t page_colours {16}
 The data's offset past a kept block's start goes round 16 multiples of 256 bytes past a cache line that holds the block's size and the offset: blocks all page-aligned fall on the same cache sets.
 

Detailed Description

template<typename T>
struct numerical::detail::default_init_allocator< T >

The allocator of numerical::buffer. An element constructed with no value is default-initialised, so a double keeps whatever its memory held, where std::allocator zeroes it; one constructed with a value is constructed from it. A result written in full is then written once, by the threads that compute it, not zeroed first on one of them (a product of order 512 on eight arm64 threads spent a fifth of its time in that zeroing).

Definition at line 253 of file buffer.hpp.

Member Typedef Documentation

◆ value_type

The element type.

Definition at line 255 of file buffer.hpp.

Constructor & Destructor Documentation

◆ default_init_allocator() [1/2]

template<typename T >
numerical::detail::default_init_allocator< T >::default_init_allocator ( )
defaultnoexcept

◆ default_init_allocator() [2/2]

template<typename T >
template<typename U >
false numerical::detail::default_init_allocator< T >::default_init_allocator ( const default_init_allocator< U > &  )
inlineexplicitnoexcept

From the allocator of another element type: stateless, as std::allocator.

Definition at line 269 of file buffer.hpp.

Member Function Documentation

◆ allocate()

template<typename T >
T * numerical::detail::default_init_allocator< T >::allocate ( std::size_t  n)
inline

n elements: on huge pages from their least bytes on Linux, in a kept block of 4 KiB pages from kept_pages_least, else std::allocator's; a block's size and the data's distance from its start kept before the data.

Definition at line 312 of file buffer.hpp.

◆ construct() [1/3]

template<typename T >
template<typename U >
requires is_complex_number<U>
void numerical::detail::default_init_allocator< T >::construct ( U *  at)
inlinenoexcept

construct of a complex number, whose default constructor zeroes: left as its memory holds it, as a double is (an implicit-lifetime type: trivial copies and destructor), so that a complex result written in full is written once (a complex128 product of 914 × 337 spent 172 of its 414 µs zeroing it). Built without NDEBUG, it holds NaN parts instead, so that code that relied on zeros fails.

Definition at line 406 of file buffer.hpp.

◆ construct() [2/3]

template<typename T >
template<typename U >
requires (!is_complex_number<U>)
void numerical::detail::default_init_allocator< T >::construct ( U *  at)
inlinenoexcept

Default-initialises the element at at.

Definition at line 395 of file buffer.hpp.

◆ construct() [3/3]

template<typename T >
template<typename U , typename ... Args>
void numerical::detail::default_init_allocator< T >::construct ( U *  at,
Args &&...  args 
)
inline

Constructs the element at at from args.

Definition at line 418 of file buffer.hpp.

◆ deallocate()

template<typename T >
void numerical::detail::default_init_allocator< T >::deallocate ( T *  at,
std::size_t  n 
)
inlinenoexcept

Frees what allocate gave for n elements.

Definition at line 346 of file buffer.hpp.

◆ deallocate_kept()

template<typename T >
template<typename Kept >
static void numerical::detail::default_init_allocator< T >::deallocate_kept ( T *  at)
inlinestaticnoexcept

Frees the block allocate gave from at, kept by Kept where it takes it. Out of line: inlined where a small buffer's size is known (a QR's columns of 40 complex numbers), GCC 14 took the read before at for one past the buffer's bounds (-Warray-bounds), though a buffer of that size never comes here.

Definition at line 379 of file buffer.hpp.

◆ on_kept_pages()

template<typename T >
static constexpr bool numerical::detail::default_init_allocator< T >::on_kept_pages ( std::size_t  n)
inlinestaticconstexprnoexcept

Whether n elements take a block of 4 KiB pages kept when freed (kept_page_blocks): from kept_pages_least bytes and under kept_pages_largest (from it, on Linux, huge pages).

Definition at line 304 of file buffer.hpp.

◆ placed()

template<typename T >
static T * numerical::detail::default_init_allocator< T >::placed ( std::byte *  start,
std::size_t  offset,
std::size_t  bytes 
)
inlinestaticnoexcept

The data at offset into the block at start of bytes, the offset and the size kept before it.

Definition at line 363 of file buffer.hpp.

Member Data Documentation

◆ page_colours

template<typename T >
constexpr std::size_t numerical::detail::default_init_allocator< T >::page_colours {16}
staticconstexpr

The data's offset past a kept block's start goes round 16 multiples of 256 bytes past a cache line that holds the block's size and the offset: blocks all page-aligned fall on the same cache sets.

Definition at line 300 of file buffer.hpp.


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