Correlation 4.10.0
An Analysis Tool for Liquids and for Amorphous Solids
Loading...
Searching...
No Matches
SIMDTypes.hpp
Go to the documentation of this file.
1
8
9#pragma once
10
11#include "math/Precision.hpp"
12#include "math/SIMDConfig.hpp"
13
14#include <cstddef>
15#include <vector>
16
17namespace correlation::math {
18
19// ---------------------------------------------------------------------------
20// SoA block of atom positions
21// ---------------------------------------------------------------------------
27template <typename T = real_t> struct PositionBlockT {
28 T *x{nullptr};
29 T *y{nullptr};
30 T *z{nullptr};
31 std::size_t count{0};
32};
33
36
37// ---------------------------------------------------------------------------
38// Scalar helper
39// ---------------------------------------------------------------------------
45template <typename T = real_t> struct Point3T {
46 T x{static_cast<T>(0.0)};
47 T y{static_cast<T>(0.0)};
48 T z{static_cast<T>(0.0)};
49};
50
53
58template <typename T> struct SincIntegralParams {
59 T q_magnitude{static_cast<T>(0.0)};
60 const T *CORRELATION_RESTRICT integrand{nullptr};
61 const T *CORRELATION_RESTRICT radial_bins{nullptr};
62 T *CORRELATION_RESTRICT sinqr_scratch{nullptr};
63 std::size_t count{0};
64};
65
70template <typename T> struct RDFNormalizationParams {
71 const T *CORRELATION_RESTRICT hist_data{nullptr};
72 const T *CORRELATION_RESTRICT radial_bins{nullptr};
73 T g_norm{static_cast<T>(0.0)};
74 T inv_Ni_dr{static_cast<T>(0.0)};
75 T inv_Nj_dr{static_cast<T>(0.0)};
76 T pi4_rho_j{static_cast<T>(0.0)};
77 T *CORRELATION_RESTRICT g_out{nullptr};
78 T *CORRELATION_RESTRICT G_out{nullptr};
79 T *CORRELATION_RESTRICT J_out{nullptr};
80 T *CORRELATION_RESTRICT Jinv_out{nullptr};
81 std::size_t count{0};
82};
83
88template <typename T> struct ScaleBinsParams {
89 T *arr{nullptr};
90 T scale_factor{static_cast<T>(1.0)};
91 std::size_t count{0};
92};
93
98template <typename T> struct MillerPhaseSumParams {
99 const T *CORRELATION_RESTRICT cos1{nullptr};
100 const T *CORRELATION_RESTRICT sin1{nullptr};
101 const T *CORRELATION_RESTRICT cos2{nullptr};
102 const T *CORRELATION_RESTRICT sin2{nullptr};
103 const T *CORRELATION_RESTRICT cos3{nullptr};
104 const T *CORRELATION_RESTRICT sin3{nullptr};
105 std::size_t count{0};
106};
107
112template <typename T = real_t> struct MillerExpSumParams {
113 T q_x{static_cast<T>(0.0)};
114 T q_y{static_cast<T>(0.0)};
115 T q_z{static_cast<T>(0.0)};
116 const T *CORRELATION_RESTRICT x_s{nullptr};
117 const T *CORRELATION_RESTRICT y_s{nullptr};
118 const T *CORRELATION_RESTRICT z_s{nullptr};
119 std::size_t count{0};
120};
121
123template <typename T = real_t> using ComplexExpSumParams = MillerExpSumParams<T>;
124
129template <typename T = real_t> struct ComplexExpSumResult {
130 T cos_sum{static_cast<T>(0.0)};
131 T sin_sum{static_cast<T>(0.0)};
132};
133
135template <typename T = real_t> using PhaseSumResult = ComplexExpSumResult<T>;
136
138template <typename T = real_t> using MillerPhaseSumResult = ComplexExpSumResult<T>;
139
145template <typename AtomRange, typename T = real_t> struct FillPositionBlockParams {
146 const AtomRange *atoms{nullptr};
147 std::size_t begin_idx{0};
148 std::size_t end_idx{0};
149 std::vector<T> *x_s{nullptr};
150 std::vector<T> *y_s{nullptr};
151 std::vector<T> *z_s{nullptr};
152};
153
161template <typename T>
162[[nodiscard]] inline T distSqScalar(Point3T<T> point_a, Point3T<T> point_b) noexcept {
163 const T dist_x = point_b.x - point_a.x;
164 const T dist_y = point_b.y - point_a.y;
165 const T dist_z = point_b.z - point_a.z;
166 return dist_x * dist_x + dist_y * dist_y + dist_z * dist_z;
167}
168
175[[nodiscard]] inline real_t distSqScalar(Point3 point_a, Point3 point_b) noexcept {
176 return distSqScalar<real_t>(point_a, point_b);
177}
178
179} // namespace correlation::math
Floating point precision type definitions for Correlation.
Configuration macros for SIMD instruction sets and compiler specifics.
Defines universal mathematical and physical constants.
MillerExpSumParams< T > ComplexExpSumParams
Alias for MillerExpSumParams used with complexExpSum kernel invocations.
Definition SIMDTypes.hpp:123
ComplexExpSumResult< T > PhaseSumResult
Alias for PhaseSumResult used with phase sum kernel invocations.
Definition SIMDTypes.hpp:135
PositionBlockT< real_t > PositionBlock
Backward-compatible type alias for default real_t precision PositionBlock.
Definition SIMDTypes.hpp:35
T distSqScalar(Point3T< T > point_a, Point3T< T > point_b) noexcept
Computes the squared distance between two 3D points.
Definition SIMDTypes.hpp:162
ComplexExpSumResult< T > MillerPhaseSumResult
Alias for MillerPhaseSumResult used with millerPhaseSum kernel invocations.
Definition SIMDTypes.hpp:138
Point3T< real_t > Point3
Backward-compatible type alias for default real_t precision Point3.
Definition SIMDTypes.hpp:52
double real_t
Definition Precision.hpp:18
Output result container holding cosine and sine phase sums.
Definition SIMDTypes.hpp:129
T cos_sum
Definition SIMDTypes.hpp:130
T sin_sum
Definition SIMDTypes.hpp:131
Parameter container for fillPositionBlock kernel invocations.
Definition SIMDTypes.hpp:145
std::vector< T > * z_s
Definition SIMDTypes.hpp:151
std::vector< T > * x_s
Definition SIMDTypes.hpp:149
std::vector< T > * y_s
Definition SIMDTypes.hpp:150
std::size_t begin_idx
Definition SIMDTypes.hpp:147
std::size_t end_idx
Definition SIMDTypes.hpp:148
const AtomRange * atoms
Definition SIMDTypes.hpp:146
Parameter container for millerExpSum / complexExpSum kernel invocations.
Definition SIMDTypes.hpp:112
T q_z
Definition SIMDTypes.hpp:115
std::size_t count
Definition SIMDTypes.hpp:119
const T * z_s
Definition SIMDTypes.hpp:118
T q_x
Definition SIMDTypes.hpp:113
const T * y_s
Definition SIMDTypes.hpp:117
const T * x_s
Definition SIMDTypes.hpp:116
T q_y
Definition SIMDTypes.hpp:114
Parameter container for millerPhaseSum kernel invocations.
Definition SIMDTypes.hpp:98
const T * cos1
Definition SIMDTypes.hpp:99
const T * sin2
Definition SIMDTypes.hpp:102
const T * cos3
Definition SIMDTypes.hpp:103
const T * sin3
Definition SIMDTypes.hpp:104
const T * cos2
Definition SIMDTypes.hpp:101
const T * sin1
Definition SIMDTypes.hpp:100
std::size_t count
Definition SIMDTypes.hpp:105
Lightweight POD for passing 3D coordinates to scalar SIMD helpers.
Definition SIMDTypes.hpp:45
real_t z
Definition SIMDTypes.hpp:48
real_t y
Definition SIMDTypes.hpp:47
real_t x
Definition SIMDTypes.hpp:46
Represents a Structure of Arrays (SoA) block of atom positions for SIMD processing.
Definition SIMDTypes.hpp:27
real_t * z
Definition SIMDTypes.hpp:30
real_t * y
Definition SIMDTypes.hpp:29
real_t * x
Definition SIMDTypes.hpp:28
std::size_t count
Definition SIMDTypes.hpp:31
Parameter container for normalizeRdfBins kernel invocations.
Definition SIMDTypes.hpp:70
T pi4_rho_j
Definition SIMDTypes.hpp:76
std::size_t count
Definition SIMDTypes.hpp:81
T * G_out
Definition SIMDTypes.hpp:78
const T * hist_data
Definition SIMDTypes.hpp:71
T inv_Ni_dr
Definition SIMDTypes.hpp:74
T * g_out
Definition SIMDTypes.hpp:77
T * Jinv_out
Definition SIMDTypes.hpp:80
T g_norm
Definition SIMDTypes.hpp:73
const T * radial_bins
Definition SIMDTypes.hpp:72
T * J_out
Definition SIMDTypes.hpp:79
T inv_Nj_dr
Definition SIMDTypes.hpp:75
Parameter container for scaleBins kernel invocations.
Definition SIMDTypes.hpp:88
T * arr
Definition SIMDTypes.hpp:89
std::size_t count
Definition SIMDTypes.hpp:91
T scale_factor
Definition SIMDTypes.hpp:90
Parameter container for sincIntegral kernel invocations.
Definition SIMDTypes.hpp:58
T * sinqr_scratch
Definition SIMDTypes.hpp:62
const T * integrand
Definition SIMDTypes.hpp:60
T q_magnitude
Definition SIMDTypes.hpp:59
std::size_t count
Definition SIMDTypes.hpp:63
const T * radial_bins
Definition SIMDTypes.hpp:61