Orrery
A GPU-accelerated N-body gravitational simulator
Loading...
Searching...
No Matches
direct_kernel.hpp
Go to the documentation of this file.
1#pragma once
2
72
73#include <cstdint>
74#include <span>
75#include <string_view>
76
78#include "orrery/core/types.hpp"
79#include "orrery/core/vec3.hpp"
81
82namespace orrery::solvers {
83
85enum class KernelKind : std::uint8_t {
92
96};
97
107 std::span<const core::Real> masses, core::Vec3 target,
108 core::Index begin, core::Index end,
109 core::Softening softening) noexcept;
110
118 std::span<const core::Real> masses,
119 core::Vec3 target, core::Index begin,
120 core::Index end,
121 core::Softening softening) noexcept;
122
123#ifdef ORRERY_HAS_AVX2_KERNEL
137[[nodiscard]] core::Vec3 accumulate_range_avx2(core::Vec3Span<const core::Real> positions,
138 std::span<const core::Real> masses,
139 core::Vec3 target, core::Index begin,
140 core::Index end, core::Softening softening) noexcept;
141#endif
142
152[[nodiscard]] bool kernel_available(KernelKind kind) noexcept;
153
159[[nodiscard]] KernelKind fastest_available_kernel() noexcept;
160
169
176[[nodiscard]] core::Index kernel_lane_count(KernelKind kind) noexcept;
177
179[[nodiscard]] std::string_view to_string(KernelKind kind) noexcept;
180
181} // namespace orrery::solvers
The softening length of the Plummer kernel above.
Definition softening.hpp:49
std::string_view to_string(KernelKind kind) noexcept
A short name, for benchmark tables and reports.
core::Vec3(*)(core::Vec3Span< const core::Real > positions, std::span< const core::Real > masses, core::Vec3 target, core::Index begin, core::Index end, core::Softening softening) noexcept AccumulateRange
The signature both kernels have.
Definition direct_kernel.hpp:106
KernelKind
Which implementation of the summation to use.
Definition direct_kernel.hpp:85
@ kAvx2
Four pairs at a time in double precision, eight in single, with AVX2 and FMA.
Definition direct_kernel.hpp:95
@ kScalar
One pair at a time, in index order.
Definition direct_kernel.hpp:91
KernelKind fastest_available_kernel() noexcept
The fastest kernel this machine can run.
core::Index kernel_lane_count(KernelKind kind) noexcept
How many pairs kind computes at once, in the precision this build uses.
core::Vec3 accumulate_range_scalar(core::Vec3Span< const core::Real > positions, std::span< const core::Real > masses, core::Vec3 target, core::Index begin, core::Index end, core::Softening softening) noexcept
The acceleration on a particle at target from the sources in [begin, end), without the factor of G,...
bool kernel_available(KernelKind kind) noexcept
Whether this build, on this machine, can run kind.
AccumulateRange accumulate_range_for(KernelKind kind) noexcept
The function implementing kind, or the scalar kernel where kind is not available here.
Plummer softening, defined once for everything that needs it.
A view of three component arrays of equal length.
Definition vec3_span.hpp:33
A vector in three-dimensional Euclidean space.
Definition vec3.hpp:26
The scalar and index types that every layer of the project agrees on.
std::size_t Index
The type of a particle index and of any count of particles.
Definition types.hpp:45
A three-component vector for interfaces, not for storage.
Three parallel component arrays, viewed as one sequence of 3-vectors.