Special Relativity in Financial Modeling 1.0.0
Lorentz transforms, spacetime classification, and geodesic price paths for quantitative finance
Loading...
Searching...
No Matches
Namespaces | Functions | Variables
gamma_avx2.cpp File Reference

AVX2 (256-bit, 4-wide) implementation of the gamma batch kernel. More...

#include "simd_batch_detail.hpp"
#include "momentum/momentum.hpp"
#include <immintrin.h>
#include <cmath>
#include <cstddef>

Go to the source code of this file.

Namespaces

namespace  srfm
 
namespace  srfm::simd
 
namespace  srfm::simd::detail
 

Functions

void srfm::simd::detail::compute_gamma_avx2 (const double *__restrict__ betas, std::size_t n, double *__restrict__ out) noexcept
 AVX2 (256-bit, 4-wide) gamma batch kernel.
 

Variables

static constexpr double srfm::simd::detail::BETA_CLAMP_LIMIT
 

Detailed Description

AVX2 (256-bit, 4-wide) implementation of the gamma batch kernel.

Module: src/simd/ Owner: AGT-08 — 2026-03-01

Responsibility

Vectorised gamma_i = 1.0 / sqrt(1.0 - betas[i]^2) for machines with AVX2 but without AVX-512F. Processes 4 doubles per SIMD cycle.

Algorithm

For each 4-element chunk:

  1. Load 4 betas: _mm256_loadu_pd
  2. Clamp to BETA_CLAMP_LIMIT: _mm256_min_pd
  3. Square: _mm256_mul_pd(b, b)
  4. Subtract from 1.0: _mm256_sub_pd(ones, b2) → denom ∈ (0,1]
  5. sqrt: _mm256_sqrt_pd(denom)
  6. Divide 1.0 by sqrt: _mm256_div_pd(ones, sqrt_d) → gamma
  7. Store: _mm256_storeu_pd Tail (n % 4 != 0): scalar fallback.

Note: This file must be compiled with -mavx2 / /arch:AVX2.

Definition in file gamma_avx2.cpp.