Tpetra parallel linear algebra
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
core
src
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
19
#include "
Tpetra_Details_PackTraits.hpp
"
20
21
namespace
Tpetra
{
22
namespace
Details
{
23
28
template
<
class
T,
class
D>
29
struct
ScalarViewTraits
{
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
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)
76
const
size_t
numVals =
PackTraits<value_type>::numValuesPerScalar
(x);
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
Tpetra_Details_PackTraits.hpp
Declaration and generic definition of traits class that tells Tpetra::CrsMatrix how to pack and unpac...
Tpetra::Details
Nonmember function that computes a residual Computes R = B - A * X.
Definition
Tpetra_KokkosRefactor_Details_MultiVectorLocalDeepCopy.hpp:17
Tpetra
Namespace Tpetra contains the class and methods constituting the Tpetra library.
Tpetra::Details::PackTraits::numValuesPerScalar
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...
Definition
Tpetra_Details_PackTraits.hpp:76
Tpetra::Details::ScalarViewTraits
Traits class for allocating a Kokkos::View<T*, D>.
Definition
Tpetra_Details_ScalarViewTraits.hpp:29
Tpetra::Details::ScalarViewTraits::allocateArray
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 ...
Definition
Tpetra_Details_ScalarViewTraits.hpp:63
Generated by
1.17.0