PACMAN 0.1.0
Portable Algorithms for Coupling, Mapping, and Adaptive iNterpolation
Loading...
Searching...
No Matches
team_ops.hpp
Go to the documentation of this file.
1//
2// This file is subject to the terms and conditions defined in
3// file 'LICENSE', which is part of this source code package.
4//
5
6#pragma once
7
8#include <Kokkos_Core.hpp>
9
10#include "common/concepts.hpp"
11#include "common/types.hpp"
12
13namespace PACMAN {
14
15namespace RbfPum {
16
35template <typename TeamHandleType, KokkosViewRank<2> AViewType,
36 KokkosViewRank<1> XType, KokkosViewRank<1> XOffsType,
37 RBFFunction RbfFuncType>
38KOKKOS_FORCEINLINE_FUNCTION void
40 const XOffsType &XOffs, const RbfFuncType &func) {
41 const int_t N = A.extent_int(0);
42 Kokkos::parallel_for(
43 Kokkos::TeamThreadRange(teamHandle, N), [&](const int_t &i) {
44 const auto x = X(XOffs(i));
45 Kokkos::parallel_for(
46 Kokkos::ThreadVectorRange(teamHandle, i, N), [&](const int &j) {
47 const auto val = func.Eval(DistanceNoCheck(x, X(XOffs(j))));
48 A(i, j) = val;
49 A(j, i) = val;
50 });
51 });
52}
53
78template <typename TeamHandleType, KokkosViewRank<2> AViewType,
79 KokkosViewRank<1> XType, KokkosViewRank<1> XOffsType,
80 KokkosViewRank<1> YType, KokkosViewRank<1> YOffsType,
81 RBFFunction RbfFuncType>
84 const XOffsType &XOffs, const YType &Y, const YOffsType &YOffs,
85 const RbfFuncType &func) {
86 const int_t N = A.extent_int(0);
87 const int_t M = A.extent_int(1);
88
89 Kokkos::parallel_for(
90 Kokkos::TeamThreadRange(teamHandle, N), [&](const int_t &i) {
91 const auto y = Y(YOffs(i));
92 Kokkos::parallel_for(
93 Kokkos::ThreadVectorRange(teamHandle, M), [&](const int_t &j) {
94 A(i, j) = func.Eval(DistanceNoCheck(y, X(XOffs(j))));
95 });
96 });
97}
98
113template <typename TeamHandleType, KokkosViewRank<1> BViewType,
114 KokkosViewRank<1> XType, KokkosViewRank<1> XOffsType>
116 BViewType &B, const XType &X,
117 const XOffsType &XOffs) {
118 const int_t N = B.extent_int(0);
119 Kokkos::parallel_for(Kokkos::TeamVectorRange(teamHandle, N),
120 [&](const int_t &i) { B(i) = X(XOffs(i)); });
121}
122
123} // namespace RbfPum
124
125} // namespace PACMAN
KOKKOS_FORCEINLINE_FUNCTION void TeamFillA(const TeamHandleType &teamHandle, const AViewType &A, const XType &X, const XOffsType &XOffs, const RbfFuncType &func)
Fills the RBF matrix A in parallel.
Definition team_ops.hpp:39
KOKKOS_FORCEINLINE_FUNCTION void TeamFillB(const TeamHandleType &teamHandle, BViewType &B, const XType &X, const XOffsType &XOffs)
Fills the vector of known source values B in parallel.
Definition team_ops.hpp:115
KOKKOS_INLINE_FUNCTION fp_t DistanceNoCheck(const ::ArborX::Point< Dim, coordinates_t > &lhs, const ::ArborX::Point< Dim, coordinates_t > &rhs)
Returns the euclidian norm between two points by performing a square root operation on the SquaredDif...
KOKKOS_FORCEINLINE_FUNCTION void TeamFillE(const TeamHandleType &teamHandle, AViewType &A, const XType &X, const XOffsType &XOffs, const YType &Y, const YOffsType &YOffs, const RbfFuncType &func)
Fills the RBF evaluation matrix E in parallel.
Definition team_ops.hpp:83