7#include <ginkgo/extensions/kokkos.hpp>
8#include <ginkgo/ginkgo.hpp>
13using gko::ext::kokkos::map_data;
19#ifdef KOKKOS_ENABLE_SERIAL
20 if (execName ==
"reference-executor") {
21 return gko::ext::kokkos::create_executor(Kokkos::Serial{});
24#ifdef PRECICE_WITH_OPENMP
25 if (execName ==
"omp-executor") {
26 return gko::ext::kokkos::create_executor(Kokkos::OpenMP{});
29#ifdef PRECICE_WITH_CUDA
30 if (execName ==
"cuda-executor") {
31 if (enableUnifiedMemory) {
32 return gko::ext::kokkos::create_executor(Kokkos::Cuda{}, Kokkos::CudaUVMSpace{});
34 return gko::ext::kokkos::create_executor(Kokkos::Cuda{}, Kokkos::CudaSpace{});
38#ifdef PRECICE_WITH_HIP
39 if (execName ==
"hip-executor") {
40 if (enableUnifiedMemory) {
41 return gko::ext::kokkos::create_executor(Kokkos::HIP{}, Kokkos::HIPManagedSpace{});
43 return gko::ext::kokkos::create_executor(Kokkos::HIP{}, Kokkos::HIPSpace{});
52template <
typename MemorySpace,
typename EvalFunctionType>
54 gko::ptr_param<GinkgoMatrix> mtx,
56 gko::ptr_param<GinkgoMatrix> supportPoints,
57 gko::ptr_param<GinkgoMatrix> targetPoints,
61 unsigned int extraDims)
63 auto k_mtx = map_data<MemorySpace>(mtx.get());
64 auto k_supportPoints = map_data<MemorySpace>(supportPoints.get());
65 auto k_targetPoints = map_data<MemorySpace>(targetPoints.get());
72 "create_rbf_system_matrix_row_major",
73 Kokkos::MDRangePolicy<
typename MemorySpace::execution_space, Kokkos::Rank<2>>{{0, 0}, {mtx->get_size()[0], mtx->get_size()[1]}},
74 KOKKOS_LAMBDA(
const int &i,
const int &j) {
82 const bool *deviceActiveAxis = activeAxis.
data();
85 for (
size_t k = 0; k < activeAxis.
size(); ++k) {
86 if (deviceActiveAxis[k]) {
87 double diff = k_supportPoints(j, k) - k_targetPoints(i, k);
91 dist = Kokkos::sqrt(dist);
92 k_mtx(i, j) = f(dist, rbf_params);
97 "create_rbf_system_matrix_col_major",
98 Kokkos::MDRangePolicy<
typename MemorySpace::execution_space, Kokkos::Rank<2>>{{0, 0}, {mtx->get_size()[0], mtx->get_size()[1]}},
99 KOKKOS_LAMBDA(
const int &i,
const int &j) {
104 const bool *deviceActiveAxis = activeAxis.
data();
107 for (
size_t k = 0; k < activeAxis.
size(); ++k) {
108 if (deviceActiveAxis[k]) {
109 double diff = k_supportPoints(k, j) - k_targetPoints(k, i);
113 dist = Kokkos::sqrt(dist);
114 k_mtx(i, j) = f(dist, rbf_params);
119template <
typename EvalFunctionType>
122 gko::ptr_param<GinkgoMatrix> mtx,
124 gko::ptr_param<GinkgoMatrix> supportPoints,
125 gko::ptr_param<GinkgoMatrix> targetPoints,
129 unsigned int extraDims)
131#ifdef KOKKOS_ENABLE_SERIAL
137#ifdef PRECICE_WITH_OPENMP
143#ifdef PRECICE_WITH_CUDA
153#ifdef PRECICE_WITH_HIP
166#define PRECICE_INSTANTIATE_CREATE_RBF_SYSTEM_MATRIX(_function_type) \
167 template void create_rbf_system_matrix<_function_type>(std::shared_ptr<const gko::Executor> exec, \
168 bool unifiedMemory, \
169 gko::ptr_param<GinkgoMatrix> mtx, const std::array<bool, 3> activeAxis, \
170 gko::ptr_param<GinkgoMatrix> supportPoints, gko::ptr_param<GinkgoMatrix> targetPoints, \
171 _function_type f, RadialBasisParameters rbf_params, bool addPolynomial, unsigned int extraDims)
184#undef PRECICE_INSTANTIATE_CREATE_RBF_SYSTEM_MATRIX
186template <
typename MemorySpace>
188 gko::ptr_param<GinkgoMatrix> mtx,
189 gko::ptr_param<const GinkgoMatrix> x,
190 const unsigned int dims)
193 auto k_mtx = map_data<MemorySpace>(mtx.get());
194 auto k_x = map_data<MemorySpace>(x.get());
197 Kokkos::parallel_for(
198 "fill_polynomial_matrix_row_major",
199 Kokkos::MDRangePolicy<
typename MemorySpace::execution_space, Kokkos::Rank<2>>{{0, 0}, {mtx->get_size()[0], mtx->get_size()[1]}},
200 KOKKOS_LAMBDA(
const int &i,
const int &j) {
210 Kokkos::parallel_for(
211 "fill_polynomial_matrix_col_major",
212 Kokkos::MDRangePolicy<
typename MemorySpace::execution_space, Kokkos::Rank<2>>{{0, 0}, {mtx->get_size()[0], mtx->get_size()[1]}},
213 KOKKOS_LAMBDA(
const int &i,
const int &j) {
227 gko::ptr_param<GinkgoMatrix> mtx,
228 gko::ptr_param<const GinkgoMatrix> x,
229 const unsigned int dims)
231#ifdef KOKKOS_ENABLE_SERIAL
237#ifdef PRECICE_WITH_OPENMP
243#ifdef PRECICE_WITH_CUDA
253#ifdef PRECICE_WITH_HIP
#define PRECICE_INSTANTIATE_CREATE_RBF_SYSTEM_MATRIX(_function_type)
#define PRECICE_UNREACHABLE(...)
Wendland radial basis function with compact support.
Wendland radial basis function with compact support.
Wendland radial basis function with compact support.
Wendland radial basis function with compact support.
Wendland radial basis function with compact support.
Radial basis function with compact support.
Radial basis function with global and compact support.
Radial basis function with global support.
Radial basis function with global support.
Radial basis function with global support.
Radial basis function with global support.
void fill_polynomial_matrix(std::shared_ptr< const gko::Executor > exec, bool unifiedMemory, gko::ptr_param< GinkgoMatrix > mtx, gko::ptr_param< const GinkgoMatrix > x, const unsigned int dims)
void fill_polynomial_matrix_impl(std::shared_ptr< const gko::Executor > exec, gko::ptr_param< GinkgoMatrix > mtx, gko::ptr_param< const GinkgoMatrix > x, const unsigned int dims)
void create_rbf_system_matrix(std::shared_ptr< const gko::Executor > exec, bool unifiedMemory, gko::ptr_param< GinkgoMatrix > mtx, const std::array< bool, 3 > activeAxis, gko::ptr_param< GinkgoMatrix > supportPoints, gko::ptr_param< GinkgoMatrix > targetPoints, EvalFunctionType f, ::precice::mapping::RadialBasisParameters rbf_params, bool addPolynomial, unsigned int extraDims)
void create_rbf_system_matrix_impl(std::shared_ptr< const gko::Executor > exec, gko::ptr_param< GinkgoMatrix > mtx, const std::array< bool, 3 > activeAxis, gko::ptr_param< GinkgoMatrix > supportPoints, gko::ptr_param< GinkgoMatrix > targetPoints, EvalFunctionType f, ::precice::mapping::RadialBasisParameters rbf_params, bool addPolynomial, unsigned int extraDims)
contains data mapping from points to meshes.
std::shared_ptr< gko::Executor > create_device_executor(const std::string &execName, bool enableUnifiedMemory)
constexpr T pow_int(const T base)
Computes the power of a given number by an integral exponent given at compile time,...
T dynamic_pointer_cast(T... args)
Wrapper struct that is used to transfer RBF-specific parameters to the GPU.