Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
Tpetra_Details_ScalarViewTraits.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Tpetra: Templated Linear Algebra Services Package
4//
5// Copyright 2008 NTESS and the Tpetra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef TPETRA_DETAILS_SCALARVIEWTRAITS_HPP
11#define TPETRA_DETAILS_SCALARVIEWTRAITS_HPP
12
18
20
21namespace Tpetra {
22namespace Details {
23
28template <class T, class D>
30 using value_type = T;
31 using device_type = D;
32
62 static Kokkos::View<value_type*, device_type>
64 const size_t numEnt,
65 const std::string& label = "") {
66 using view_type = Kokkos::View<value_type*, device_type>;
67
68 // When the traits::specialize type is non-void this exploits
69 // the fact that Kokkos::View's constructor ignores
70 // size arguments beyond what the View's type specifies. For
71 // value_type = Stokhos::UQ::PCE<S>, numValuesPerScalar returns
72 // something other than 1, and the constructor will actually use
73 // that value.
74 // Otherwise, the number of arguments must match the dynamic rank
75 // (i.e. number *'s with the value_type of the View)
77 if (std::is_same<typename view_type::traits::specialize, void>::value) {
78 return view_type(label, numEnt);
79 } else {
80 return view_type(label, numEnt, numVals);
81 }
82 }
83}; // struct ScalarViewTraits
84
85} // namespace Details
86} // namespace Tpetra
87
88#endif // TPETRA_DETAILS_SCALARVIEWTRAITS_HPP
Declaration and generic definition of traits class that tells Tpetra::CrsMatrix how to pack and unpac...
Struct that holds views of the contents of a CrsMatrix.
Implementation details of Tpetra.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
static KOKKOS_INLINE_FUNCTION size_t numValuesPerScalar(const value_type &)
Given an instance of value_type allocated with the right size, return the "number of values" that mak...
Traits class for allocating a Kokkos::View<T*, D>.
static Kokkos::View< value_type *, device_type > allocateArray(const value_type &x, const size_t numEnt, const std::string &label="")
Given an instance of value_type allocated with the right size, allocate and return a one-dimensional ...