NumericAL
A header-only C++20 lexer built on REAL
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Typedefs | Functions | Variables
buffer.hpp File Reference

numerical::buffer, the storage of the library's vectors, matrices and tensors: a std::vector whose elements constructed with no value are left uninitialised. More...

#include <algorithm>
#include <array>
#include <atomic>
#include <complex>
#include <concepts>
#include <cstddef>
#include <cstring>
#include <limits>
#include <new>
#include <memory>
#include <type_traits>
#include <utility>
#include <vector>
#include <mutex>
Include dependency graph for buffer.hpp:

Go to the source code of this file.

Classes

struct  numerical::detail::thread_release_steps
 The calling thread's steps that empty the workspaces it keeps between calls, each registered by the workspace when the thread first makes it (on_release), and their count. More...
 
class  numerical::detail::kept_blocks< Alignment, Places, Largest >
 Blocks freed and kept for the next buffer that fits one: a fresh block's pages are each faulted in and zeroed by the system at their first write, on the thread that writes it (glibc hands a large freed block back to the system unless the next request is of its very size; macOS's allocator likewise), where a kept block's are already in place. Places blocks at most, each under Largest bytes, the newest kept: a block freed while every place is taken frees the one kept longest. The first allocation one fits, with no more than half of it unused, takes it. Blocks aligned on Alignment. More...
 
struct  numerical::detail::kept_blocks< Alignment, Places, Largest >::block
 
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). More...
 
struct  numerical::detail::default_init_allocator< T >::rebind< U >
 The allocator of another element type, as std::allocator_traits rebinds it. More...
 

Namespaces

namespace  numerical
 The NumericAL public API.
 
namespace  numerical::detail
 

Macros

#define NUMERICAL_OUT_OF_LINE   [[gnu::noinline]]
 

Typedefs

using numerical::detail::kept_page_blocks = kept_blocks< std::size_t {4096}, 4, kept_pages_largest >
 The blocks of 4 KiB pages of default_init_allocator, from kept_pages_least bytes: four, each under kept_pages_largest.
 
template<typename T >
using numerical::buffer = std::vector< T, detail::default_init_allocator< T > >
 The storage of vector, matrix and tensor, namely a std::vector whose buffer<T>(n) and resize(n) leave a double or a complex number uninitialised, for a result about to be written in full. buffer<T>(n, T {}) zeroes, as std::vector<T>(n) does.
 

Functions

thread_release_steps & numerical::detail::thread_releases () noexcept
 The calling thread's thread_release_steps.
 
bool numerical::detail::on_release (void(*step)()) noexcept
 Registers step among the calling thread's thread_releases, while a place is left (a workspace past them is not freed by release_thread_memory).
 
void numerical::detail::release_thread_memory ()
 Empties every workspace the calling thread keeps between calls: its thread_releases, in turn.
 
template<typename T >
bool numerical::detail::operator== (const std::vector< T, default_init_allocator< T > > &buffer, const std::vector< T > &other)
 Element-wise equality of a numerical::buffer and a std::vector, found by argument-dependent lookup through the allocator: code that compared a tensor's elements with a std::vector keeps doing so.
 

Variables

constexpr std::size_t numerical::detail::thread_release_places {256}
 The most workspaces a thread registers (on_release): one per kind, scalar type and slot, a few dozen where every type is used (the C++ tests' thread: 34), so that registering allocates nothing (their accessors throw nothing).
 
constexpr std::size_t numerical::detail::kept_pages_largest {std::size_t {1} << 25U}
 The bytes under which a buffer's block is a kept one, no huge pages asked: 32 MiB, four of them at most 128 MiB kept.
 
constexpr std::size_t numerical::detail::kept_pages_least {std::size_t {1} << 20U}
 The fewest bytes a buffer takes a kept block of 4 KiB pages for (kept_page_blocks): below, the allocator's own free lists reuse what is freed.
 
template<typename T >
constexpr bool numerical::detail::is_complex_number {false}
 Whether T is a std::complex of a floating-point type.
 

Detailed Description

numerical::buffer, the storage of the library's vectors, matrices and tensors: a std::vector whose elements constructed with no value are left uninitialised.

Definition in file buffer.hpp.

Macro Definition Documentation

◆ NUMERICAL_OUT_OF_LINE

#define NUMERICAL_OUT_OF_LINE   [[gnu::noinline]]

Definition at line 30 of file buffer.hpp.