44 #ifndef TPETRA_KOKKOS_REFACTOR_DETAILS_MULTI_VECTOR_DIST_OBJECT_KERNELS_MP_VECTOR_HPP 45 #define TPETRA_KOKKOS_REFACTOR_DETAILS_MULTI_VECTOR_DIST_OBJECT_KERNELS_MP_VECTOR_HPP 51 #include "Tpetra_KokkosRefactor_Details_MultiVectorDistObjectKernels.hpp" 56 namespace KokkosRefactor {
59 #if defined( KOKKOS_HAVE_CUDA ) 61 struct device_is_cuda :
public Kokkos::Impl::is_same<D,Kokkos::Cuda> {};
70 template <
typename DS,
typename ... DP,
71 typename SS,
typename ... SP,
73 struct PackArraySingleColumn<
74 Kokkos::View<Sacado::MP::Vector<DS>*,DP...>,
75 Kokkos::View<const Sacado::MP::Vector<SS>**,SP...>,
78 typedef Kokkos::View<Sacado::MP::Vector<DS>*,DP...>
DstView;
79 typedef Kokkos::View<const Sacado::MP::Vector<SS>**,SP...>
SrcView;
81 typedef typename execution_space::size_type
size_type;
92 dst(dst_), src(src_), idx(idx_), col(col_) {}
94 KOKKOS_INLINE_FUNCTION
96 dst(k) = src(idx(k), col);
99 KOKKOS_INLINE_FUNCTION
101 dst(k).fastAccessCoeff(tidx) = src(idx(k), col).fastAccessCoeff(tidx);
109 Kokkos::parallel_for(
111 PackArraySingleColumn(dst,src,idx,col) );
113 Kokkos::parallel_for( idx.size(),
114 PackArraySingleColumn(dst,src,idx,col) );
118 template <
typename DS,
typename ... DP,
119 typename SS,
typename ... SP,
121 struct PackArrayMultiColumn<
122 Kokkos::View<Sacado::MP::Vector<DS>*,DP...>,
123 Kokkos::View<const Sacado::MP::Vector<SS>**,SP...>,
126 typedef Kokkos::View<Sacado::MP::Vector<DS>*,DP...>
DstView;
127 typedef Kokkos::View<const Sacado::MP::Vector<SS>**,SP...>
SrcView;
140 dst(dst_), src(src_), idx(idx_), numCols(numCols_) {}
142 KOKKOS_INLINE_FUNCTION
145 const size_t offset = k*numCols;
146 for (
size_t j = 0;
j < numCols; ++
j)
147 dst(offset +
j) = src(localRow,
j);
150 KOKKOS_INLINE_FUNCTION
153 const size_t offset = k*numCols;
154 for (
size_t j = 0;
j < numCols; ++
j)
155 dst(offset +
j).fastAccessCoeff(tidx) =
156 src(localRow,
j).fastAccessCoeff(tidx);
164 Kokkos::parallel_for(
166 PackArrayMultiColumn(dst,src,idx,numCols) );
168 Kokkos::parallel_for( idx.size(),
169 PackArrayMultiColumn(dst,src,idx,numCols) );
173 template <
typename DS,
typename ... DP,
174 typename SS,
typename ... SP,
177 struct PackArrayMultiColumnVariableStride<
178 Kokkos::View<Sacado::MP::Vector<DS>*,DP...>,
179 Kokkos::View<const Sacado::MP::Vector<SS>**,SP...>,
183 typedef Kokkos::View<Sacado::MP::Vector<DS>*,DP...>
DstView;
184 typedef Kokkos::View<const Sacado::MP::Vector<SS>**,SP...>
SrcView;
199 dst(dst_), src(src_), idx(idx_), col(col_), numCols(numCols_) {}
201 KOKKOS_INLINE_FUNCTION
204 const size_t offset = k*numCols;
205 for (
size_t j = 0;
j < numCols; ++
j)
206 dst(offset +
j) = src(localRow, col(
j));
209 KOKKOS_INLINE_FUNCTION
212 const size_t offset = k*numCols;
213 for (
size_t j = 0;
j < numCols; ++
j)
214 dst(offset +
j).fastAccessCoeff(tidx) =
215 src(localRow, col(
j)).fastAccessCoeff(tidx);
224 Kokkos::parallel_for(
226 PackArrayMultiColumnVariableStride(dst,src,idx,col,numCols) );
228 Kokkos::parallel_for( idx.size(),
229 PackArrayMultiColumnVariableStride(
230 dst,src,idx,col,numCols) );
234 template <
typename DS,
typename ... DP,
235 typename SS,
typename ... SP,
236 typename IdxView,
typename Op>
237 struct UnpackArrayMultiColumn<
238 Kokkos::View<Sacado::MP::Vector<DS>**,DP...>,
239 Kokkos::View<const Sacado::MP::Vector<SS>*,SP...>,
243 typedef Kokkos::View<Sacado::MP::Vector<DS>**,DP...>
DstView;
244 typedef Kokkos::View<const Sacado::MP::Vector<SS>*,SP...>
SrcView;
259 dst(dst_), src(src_), idx(idx_), op(op_), numCols(numCols_) {}
261 KOKKOS_INLINE_FUNCTION
264 const size_t offset = k*numCols;
265 for (
size_t j = 0;
j < numCols; ++
j)
266 op( dst(localRow,
j), src(offset+
j) );
269 KOKKOS_INLINE_FUNCTION
272 const size_t offset = k*numCols;
273 for (
size_t j = 0;
j < numCols; ++
j)
274 op( dst(localRow,
j).fastAccessCoeff(tidx),
275 src(offset+
j).fastAccessCoeff(tidx) );
284 Kokkos::parallel_for(
286 UnpackArrayMultiColumn(dst,src,idx,op,numCols) );
288 Kokkos::parallel_for( idx.size(),
289 UnpackArrayMultiColumn(dst,src,idx,op,numCols) );
293 template <
typename DS,
typename ... DP,
294 typename SS,
typename ... SP,
295 typename IdxView,
typename ColView,
typename Op>
296 struct UnpackArrayMultiColumnVariableStride<
297 Kokkos::View<Sacado::MP::Vector<DS>**,DP...>,
298 Kokkos::View<const Sacado::MP::Vector<SS>*,SP...>,
303 typedef Kokkos::View<Sacado::MP::Vector<DS>**,DP...>
DstView;
304 typedef Kokkos::View<const Sacado::MP::Vector<SS>*,SP...>
SrcView;
321 dst(dst_), src(src_), idx(idx_), col(col_), op(op_), numCols(numCols_) {}
323 KOKKOS_INLINE_FUNCTION
326 const size_t offset = k*numCols;
327 for (
size_t j = 0;
j < numCols; ++
j)
328 op( dst(localRow,col(
j)), src(offset+
j) );
331 KOKKOS_INLINE_FUNCTION
334 const size_t offset = k*numCols;
335 for (
size_t j = 0;
j < numCols; ++
j)
336 op( dst(localRow,col(
j)).fastAccessCoeff(tidx),
337 src(offset+
j).fastAccessCoeff(tidx) );
347 Kokkos::parallel_for(
349 UnpackArrayMultiColumnVariableStride(dst,src,idx,col,op,numCols) );
351 Kokkos::parallel_for( idx.size(),
352 UnpackArrayMultiColumnVariableStride(
353 dst,src,idx,col,op,numCols) );
357 template <
typename DS,
typename ... DP,
358 typename SS,
typename ... SP,
359 typename DstIdxView,
typename SrcIdxView>
360 struct PermuteArrayMultiColumn<
361 Kokkos::View<Sacado::MP::Vector<DS>**,DP...>,
362 Kokkos::View<const Sacado::MP::Vector<SS>**,SP...>,
366 typedef Kokkos::View<Sacado::MP::Vector<DS>**,DP...>
DstView;
367 typedef Kokkos::View<const Sacado::MP::Vector<SS>**,SP...>
SrcView;
379 const DstIdxView& dst_idx_,
380 const SrcIdxView& src_idx_,
382 dst(dst_), src(src_), dst_idx(dst_idx_), src_idx(src_idx_),
385 KOKKOS_INLINE_FUNCTION
389 for (
size_t j = 0;
j < numCols; ++
j)
390 dst(toRow,
j) = src(fromRow,
j);
393 KOKKOS_INLINE_FUNCTION
397 for (
size_t j = 0;
j < numCols; ++
j)
398 dst(toRow,
j).fastAccessCoeff(tidx) =
399 src(fromRow,
j).fastAccessCoeff(tidx);
404 const DstIdxView& dst_idx,
405 const SrcIdxView& src_idx,
409 Kokkos::parallel_for(
411 PermuteArrayMultiColumn(dst,src,dst_idx,src_idx,numCols) );
413 Kokkos::parallel_for(
414 n, PermuteArrayMultiColumn(dst,src,dst_idx,src_idx,numCols) );
418 template <
typename DS,
typename ... DP,
419 typename SS,
typename ... SP,
420 typename DstIdxView,
typename SrcIdxView,
421 typename DstColView,
typename SrcColView>
422 struct PermuteArrayMultiColumnVariableStride<
423 Kokkos::View<Sacado::MP::Vector<DS>**,DP...>,
424 Kokkos::View<const Sacado::MP::Vector<SS>**,SP...>,
425 DstIdxView, SrcIdxView,
426 DstColView, SrcColView >
428 typedef Kokkos::View<Sacado::MP::Vector<DS>**,DP...>
DstView;
429 typedef Kokkos::View<const Sacado::MP::Vector<SS>**,SP...>
SrcView;
443 const DstIdxView& dst_idx_,
444 const SrcIdxView& src_idx_,
445 const DstColView& dst_col_,
446 const SrcColView& src_col_,
448 dst(dst_), src(src_), dst_idx(dst_idx_), src_idx(src_idx_),
449 dst_col(dst_col_), src_col(src_col_),
452 KOKKOS_INLINE_FUNCTION
456 for (
size_t j = 0;
j < numCols; ++
j)
457 dst(toRow, dst_col(
j)) = src(fromRow, src_col(
j));
460 KOKKOS_INLINE_FUNCTION
464 for (
size_t j = 0;
j < numCols; ++
j)
465 dst(toRow, dst_col(
j)).fastAccessCoeff(tidx) =
466 src(fromRow, src_col(
j)).fastAccessCoeff(tidx);
471 const DstIdxView& dst_idx,
472 const SrcIdxView& src_idx,
473 const DstColView& dst_col,
474 const SrcColView& src_col,
478 Kokkos::parallel_for(
480 PermuteArrayMultiColumnVariableStride(
481 dst,src,dst_idx,src_idx,dst_col,src_col,numCols) );
483 Kokkos::parallel_for(
484 n, PermuteArrayMultiColumnVariableStride(
485 dst,src,dst_idx,src_idx,dst_col,src_col,numCols) );
493 #endif // TPETRA_KOKKOS_REFACTOR_DETAILS_MULTI_VECTOR_DIST_OBJECT_KERNELS_MP_VECTOR_HPP
execution_space::size_type size_type
execution_space::size_type size_type
Kokkos::View< Sacado::MP::Vector< DS > **, DP... > DstView
DstView::execution_space execution_space
Kokkos::View< const Sacado::MP::Vector< SS > **, SP... > SrcView
execution_space::size_type size_type
PackArrayMultiColumn(const DstView &dst_, const SrcView &src_, const IdxView &idx_, size_t numCols_)
KOKKOS_INLINE_FUNCTION void operator()(const size_type k) const
DstView::execution_space execution_space
Kokkos::View< const Sacado::MP::Vector< SS > **, SP... > SrcView
KOKKOS_INLINE_FUNCTION void operator()(const size_type k) const
Kokkos::DefaultExecutionSpace execution_space
static void unpack(const DstView &dst, const SrcView &src, const IdxView &idx, const ColView &col, const Op &op, size_t numCols)
DstView::execution_space execution_space
static void permute(const DstView &dst, const SrcView &src, const DstIdxView &dst_idx, const SrcIdxView &src_idx, size_t numCols)
execution_space::size_type size_type
execution_space::size_type size_type
execution_space::size_type size_type
KOKKOS_INLINE_FUNCTION void operator()(const size_type k, const size_type tidx) const
KOKKOS_INLINE_FUNCTION void operator()(const size_type k, const size_type tidx) const
Kokkos::View< const Sacado::MP::Vector< SS > **, SP... > SrcView
DstView::execution_space execution_space
PackArrayMultiColumnVariableStride(const DstView &dst_, const SrcView &src_, const IdxView &idx_, const ColView &col_, size_t numCols_)
KOKKOS_INLINE_FUNCTION PCE< Storage > min(const typename PCE< Storage >::value_type &a, const PCE< Storage > &b)
Kokkos::View< Sacado::MP::Vector< DS > *, DP... > DstView
KOKKOS_INLINE_FUNCTION void operator()(const size_type k, const size_type tidx) const
Kokkos::View< const Sacado::MP::Vector< SS > **, SP... > SrcView
KOKKOS_INLINE_FUNCTION void operator()(const size_type k, const size_type tidx) const
execution_space::size_type size_type
Kokkos::View< Sacado::MP::Vector< DS > *, DP... > DstView
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< View< T, P... > >::value, unsigned >::type dimension_scalar(const View< T, P... > &view)
static void unpack(const DstView &dst, const SrcView &src, const IdxView &idx, const Op &op, size_t numCols)
static void pack(const DstView &dst, const SrcView &src, const IdxView &idx, const ColView &col, size_t numCols)
DstView::execution_space execution_space
KOKKOS_INLINE_FUNCTION void operator()(const size_type k, const size_type tidx) const
Kokkos::View< const Sacado::MP::Vector< SS > *, SP... > SrcView
static void permute(const DstView &dst, const SrcView &src, const DstIdxView &dst_idx, const SrcIdxView &src_idx, const DstColView &dst_col, const SrcColView &src_col, size_t numCols)
Kokkos::View< const Sacado::MP::Vector< SS > *, SP... > SrcView
Team-based parallel work configuration for Sacado::MP::Vector.
UnpackArrayMultiColumnVariableStride(const DstView &dst_, const SrcView &src_, const IdxView &idx_, const ColView &col_, const Op &op_, size_t numCols_)
PermuteArrayMultiColumnVariableStride(const DstView &dst_, const SrcView &src_, const DstIdxView &dst_idx_, const SrcIdxView &src_idx_, const DstColView &dst_col_, const SrcColView &src_col_, size_t numCols_)
Kokkos::View< const Sacado::MP::Vector< SS > **, SP... > SrcView
KOKKOS_INLINE_FUNCTION void operator()(const size_type k) const
Kokkos::View< Sacado::MP::Vector< DS > **, DP... > DstView
static void pack(const DstView &dst, const SrcView &src, const IdxView &idx, size_t col)
DstView::execution_space execution_space
KOKKOS_INLINE_FUNCTION void operator()(const size_type k, const size_type tidx) const
PermuteArrayMultiColumn(const DstView &dst_, const SrcView &src_, const DstIdxView &dst_idx_, const SrcIdxView &src_idx_, size_t numCols_)
UnpackArrayMultiColumn(const DstView &dst_, const SrcView &src_, const IdxView &idx_, const Op &op_, size_t numCols_)
KOKKOS_INLINE_FUNCTION void operator()(const size_type k, const size_type tidx) const
KOKKOS_INLINE_FUNCTION void operator()(const size_type k) const
Kokkos::View< Sacado::MP::Vector< DS > **, DP... > DstView
KOKKOS_INLINE_FUNCTION void operator()(const size_type k) const
Kokkos::View< Sacado::MP::Vector< DS > **, DP... > DstView
PackArraySingleColumn(const DstView &dst_, const SrcView &src_, const IdxView &idx_, size_t col_)
KOKKOS_INLINE_FUNCTION void operator()(const size_type k) const
DstView::execution_space execution_space
Kokkos::View< Sacado::MP::Vector< DS > *, DP... > DstView
KOKKOS_INLINE_FUNCTION void operator()(const size_type k) const
static void pack(const DstView &dst, const SrcView &src, const IdxView &idx, size_t numCols)