42#ifndef TPETRA_DETAILS_FILL_HPP
43#define TPETRA_DETAILS_FILL_HPP
67memsetWrapper (
void* dest,
int ch, std::size_t count);
70template<
class ViewType,
74 const int rank = ViewType::Rank>
84 static_assert (std::is_integral<IndexType>::value,
85 "IndexType must be a built-in integer type.");
101 static_assert (ViewType::Rank == 1,
102 "ViewType must be a rank-1 Kokkos::View.");
103 static_assert (std::is_integral<IndexType>::value,
104 "IndexType must be a built-in integer type.");
120 typedef Kokkos::RangePolicy<ExecutionSpace, IndexType> range_type;
121 Kokkos::parallel_for (
"fill", range_type (0,
numRows),
140 X_ (
X), alpha_ (
alpha), numCols_ (numCols)
142 static_assert (ViewType::Rank == 2,
143 "ViewType must be a rank-2 Kokkos::View.");
144 static_assert (std::is_integral<IndexType>::value,
145 "IndexType must be a built-in integer type.");
163 typedef Kokkos::RangePolicy<ExecutionSpace, IndexType> range_type;
164 Kokkos::parallel_for (
"fill", range_type (0,
numRows),
174#if defined(KOKKOS_ENABLE_SERIAL)
187 fill (
const Kokkos::Serial& ,
193 static_assert (ViewType::Rank == 1,
194 "ViewType must be a rank-1 Kokkos::View.");
195 static_assert (std::is_integral<IndexType>::value,
196 "IndexType must be a built-in integer type.");
197 using ::Tpetra::Details::Blas::BlasSupportsScalar;
216#if defined(KOKKOS_ENABLE_SERIAL)
219template<
class ViewType,
229 fill (
const Kokkos::Serial& ,
231 const ValueType& alpha,
233 const IndexType numCols)
235 static_assert (ViewType::Rank == 2,
236 "ViewType must be a rank-2 Kokkos::View.");
237 static_assert (std::is_integral<IndexType>::value,
238 "IndexType must be a built-in integer type.");
239 using ::Tpetra::Details::Blas::BlasSupportsScalar;
240 typedef typename ViewType::non_const_value_type view_value_type;
241 typedef typename ViewType::array_layout array_layout;
245 constexpr bool podType = BlasSupportsScalar<view_value_type>::value;
247 if (podType && alpha == ValueType (0.0)) {
248 if (X.span_is_contiguous ()) {
249 memsetWrapper (X.data (), 0, X.span () * sizeof (view_value_type));
251 else if (std::is_same<array_layout, Kokkos::LayoutLeft>::value) {
253 for (IndexType j = 0; j < numCols; ++j) {
254 auto X_j = Kokkos::subview (X, Kokkos::ALL (), j);
255 memsetWrapper (X_j.data (), 0,
256 X_j.extent (0) * sizeof (view_value_type));
261 Kokkos::deep_copy (X, view_value_type (0.0));
266 using execution_space =
typename ViewType::execution_space;
267 Kokkos::deep_copy (execution_space(), X, alpha);
286template<
class ViewType,
289 class ExecutionSpace>
297 static_assert (std::is_integral<IndexType>::value,
298 "IndexType must be a built-in integer type.");
316 static_assert (ViewType::Rank == 2,
"ViewType must be a rank-2 "
317 "Kokkos::View in order to call the \"whichVectors\" "
318 "specialization of fill.");
319 static_assert (std::is_integral<IndexType>::value,
320 "IndexType must be a built-in integer type.");
323 auto X_j = Kokkos::subview (
X, Kokkos::ALL (),
j);
Type traits for Tpetra's BLAS wrappers; an implementation detail of Tpetra::MultiVector.
void fill(const ExecutionSpace &execSpace, const ViewType &X, const ValueType &alpha, const IndexType numRows, const IndexType numCols)
Fill the entries of the given 1-D or 2-D Kokkos::View with the given scalar value alpha.
Struct that holds views of the contents of a CrsMatrix.
Implementation of Tpetra::Details::Blas::fill.
Implementation details of Tpetra.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
Do BLAS libraries (all that are compliant with the BLAS Standard) support the given "scalar" (matrix ...