Chisei v1.0
Lightweight AI/ML Framework
Loading...
Searching...
No Matches
chisei::CPUFeatureOptimizer Class Reference

Provides utilities to optimize computations using CPU-specific features, such as FMA and AVX. More...

#include <cpu_feature_optimizer.hpp>

Static Public Member Functions

static void init_cpu_features (std::mt19937 gen)
 Initializes CPU-specific features for optimization.
 
static double dot_product_fma (const double *a, const double *b, int size)
 Computes the dot product of two arrays using FMA (Fused Multiply-Add) instructions.
 

Detailed Description

This class includes methods to initialize CPU-specific features and perform optimized mathematical operations such as dot products. It utilizes hardware acceleration where available for improved performance.

Definition at line 60 of file cpu_feature_optimizer.hpp.

Member Function Documentation

◆ dot_product_fma()

static double chisei::CPUFeatureOptimizer::dot_product_fma ( const double *  a,
const double *  b,
int  size 
)
inlinestatic

If FMA or AVX instructions are available, this method will leverage hardware acceleration for computing the dot product of two arrays. FMA reduces rounding errors and improves performance by combining multiplication and addition in a single instruction.

Parameters
aPointer to the first array of double-precision floating-point numbers.
bPointer to the second array of double-precision floating-point numbers.
sizeThe size of the arrays (number of elements in each array).
Returns
The computed dot product of the two arrays.
Note
The arrays a and b must have at least size elements to avoid undefined behavior.

◆ init_cpu_features()

static void chisei::CPUFeatureOptimizer::init_cpu_features ( std::mt19937  gen)
static

This method is used to initialize and configure CPU features based on the available hardware capabilities. It can utilize features such as RDRAND, RDSEED, and AVX if supported by the CPU.

Parameters
genA random number generator of type std::mt19937, which may be used internally for testing or feature initialization.

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