Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
Tpetra_Details_castAwayConstDualView.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_CASTAWAYCONSTDUALVIEW_HPP
11#define TPETRA_DETAILS_CASTAWAYCONSTDUALVIEW_HPP
12
20
21#include "Kokkos_DualView.hpp"
22
23namespace Tpetra {
24namespace Details {
25
30template <class ValueType, class DeviceType>
31Kokkos::DualView<ValueType*, DeviceType>
32castAwayConstDualView(const Kokkos::DualView<const ValueType*, DeviceType>& input_dv) {
33 typedef Kokkos::DualView<const ValueType*, DeviceType> input_dual_view_type;
34 typedef typename input_dual_view_type::t_dev::non_const_type out_dev_view_type;
35 typedef typename input_dual_view_type::t_host::non_const_type out_host_view_type;
36
37 out_dev_view_type output_view_dev(const_cast<ValueType*>(input_dv.view_device().data()),
38 input_dv.view_device().extent(0));
39 out_host_view_type output_view_host(const_cast<ValueType*>(input_dv.view_host().data()),
40 input_dv.view_host().extent(0));
41
42 Kokkos::DualView<ValueType*, DeviceType> output_dv(output_view_dev, output_view_host);
43 if (input_dv.need_sync_host()) output_dv.modify_device();
44 if (input_dv.need_sync_device()) output_dv.modify_host();
45 return output_dv;
46}
47
48} // namespace Details
49} // namespace Tpetra
50
51#endif // TPETRA_DETAILS_CASTAWAYCONSTDUALVIEW_HPP
Struct that holds views of the contents of a CrsMatrix.
Implementation details of Tpetra.
Kokkos::DualView< ValueType *, DeviceType > castAwayConstDualView(const Kokkos::DualView< const ValueType *, DeviceType > &input_dv)
Cast away const-ness of a 1-D Kokkos::DualView.
Namespace Tpetra contains the class and methods constituting the Tpetra library.