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>
63 allocateArray (const value_type& x,
64 const size_t numEnt,
65 const std::string& label = "")
66 {
67 using view_type = Kokkos::View<value_type*, device_type>;
68
69 // When the traits::specialize type is non-void this exploits
70 // the fact that Kokkos::View's constructor ignores
71 // size arguments beyond what the View's type specifies. For
72 // value_type = Stokhos::UQ::PCE<S>, numValuesPerScalar returns
73 // something other than 1, and the constructor will actually use
74 // that value.
75 // Otherwise, the number of arguments must match the dynamic rank
76 // (i.e. number *'s with the value_type of the View)
77 const size_t numVals = PackTraits<value_type>::numValuesPerScalar (x);
78 if (std::is_same<typename view_type::traits::specialize, void>::value ) {
79 return view_type (label, numEnt);
80 }
81 else {
82 return view_type (label, numEnt, numVals);
83 }
84 }
85}; // struct ScalarViewTraits
86
87} // namespace Details
88} // namespace Tpetra
89
90#endif // TPETRA_DETAILS_SCALARVIEWTRAITS_HPP
Declaration and generic definition of traits class that tells Tpetra::CrsMatrix how to pack and unpac...
Nonmember function that computes a residual Computes R = B - A * X.
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 ...