batmat 0.0.15
Batched linear algebra routines
Loading...
Searching...
No Matches
Utilities

Detailed Description

Various utilities.

Classes

class  batmat::thread_pool

Enumerations

enum class  batmat::LoopDir { batmat::LoopDir::Forward , batmat::LoopDir::Backward }

Functions

void batmat::foreach_chunked (index_t i_begin, index_t i_end, auto chunk_size, auto func_chunk, auto func_rem, LoopDir dir=LoopDir::Forward)
 Iterate over the range [i_begin, i_end) in chunks of size chunk_size, calling func_chunk for each full chunk and func_rem for the remaining elements (if any).
void batmat::foreach_chunked_merged (index_t i_begin, index_t i_end, auto chunk_size, auto func_chunk, LoopDir dir=LoopDir::Forward)
 Iterate over the range [i_begin, i_end) in chunks of size chunk_size, calling func_chunk for each chunk (including the last chunk, which may be smaller than chunk_size).
template<int R, int C, class F>
consteval auto batmat::make_2d_lut (F f)
 Returns a 2D array of the form:
template<int N, class F>
consteval auto batmat::make_1d_lut (F f)
 Returns an array of the form:
void batmat::pool_set_num_threads (size_t num_threads)
 Set the number of threads in the global thread pool.
template<class I = size_t, class F>
void batmat::pool_sync_run_all (F &&f)
 Run a function on all threads in the global thread pool, synchronously waiting for all threads.
template<class I = size_t, class F>
void batmat::pool_sync_run_n (I n, F &&f)
 Run a function on the first n threads in the global thread pool, synchronously waiting for those threads.

Enumeration Type Documentation

◆ LoopDir

enum class batmat::LoopDir
strong

#include <batmat/loop.hpp>

Enumerator
Forward 
Backward 

Definition at line 12 of file loop.hpp.

Function Documentation

◆ foreach_chunked()

void batmat::foreach_chunked ( index_t i_begin,
index_t i_end,
auto chunk_size,
auto func_chunk,
auto func_rem,
LoopDir dir = LoopDir::Forward )
inline

#include <batmat/loop.hpp>

Iterate over the range [i_begin, i_end) in chunks of size chunk_size, calling func_chunk for each full chunk and func_rem for the remaining elements (if any).

Definition at line 20 of file loop.hpp.

◆ foreach_chunked_merged()

void batmat::foreach_chunked_merged ( index_t i_begin,
index_t i_end,
auto chunk_size,
auto func_chunk,
LoopDir dir = LoopDir::Forward )
inline

#include <batmat/loop.hpp>

Iterate over the range [i_begin, i_end) in chunks of size chunk_size, calling func_chunk for each chunk (including the last chunk, which may be smaller than chunk_size).

Definition at line 43 of file loop.hpp.

◆ make_2d_lut()

template<int R, int C, class F>
auto batmat::make_2d_lut ( F f)
consteval

#include <batmat/lut.hpp>

Returns a 2D array of the form:

{{ f(0, 0), f(0, 1), ..., f(0, C - 1) },
{ f(1, 0), f(1, 1), ..., f(1, C - 1) },
{ ..., ..., ..., ... },
{ f(R - 1, 0), f(R - 1, 1)}, ..., f(R - 1, C - 1) }}

The argument f should be a function (or callable) that accepts two arguments of type index_constant.

Definition at line 25 of file lut.hpp.

◆ make_1d_lut()

template<int N, class F>
auto batmat::make_1d_lut ( F f)
consteval

#include <batmat/lut.hpp>

Returns an array of the form:

{ f(0), f(1), ..., f(C - 1) }

The argument f should be a function (or callable) that accepts an argument of type index_constant.

Definition at line 39 of file lut.hpp.

◆ pool_set_num_threads()

void batmat::pool_set_num_threads ( size_t num_threads)

#include <batmat/thread-pool.hpp>

Set the number of threads in the global thread pool.

Definition at line 11 of file thread-pool.cpp.

◆ pool_sync_run_all()

template<class I = size_t, class F>
void batmat::pool_sync_run_all ( F && f)

#include <batmat/thread-pool.hpp>

Run a function on all threads in the global thread pool, synchronously waiting for all threads.

Definition at line 117 of file thread-pool.hpp.

◆ pool_sync_run_n()

template<class I = size_t, class F>
void batmat::pool_sync_run_n ( I n,
F && f )

#include <batmat/thread-pool.hpp>

Run a function on the first n threads in the global thread pool, synchronously waiting for those threads.

If n is greater than the number of threads in the pool, the pool is expanded.

Definition at line 129 of file thread-pool.hpp.