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{
34 typedef Kokkos::DualView<const ValueType*, DeviceType> input_dual_view_type;
35 typedef typename input_dual_view_type::t_dev::non_const_type out_dev_view_type;
36 typedef typename input_dual_view_type::t_host::non_const_type out_host_view_type;
37
38 out_dev_view_type output_view_dev
39 (const_cast<ValueType*> (input_dv.view_device().data ()),
40 input_dv.view_device().extent (0));
41 out_host_view_type output_view_host
42 (const_cast<ValueType*> (input_dv.view_host().data ()),
43 input_dv.view_host().extent (0));
44
45 Kokkos::DualView<ValueType*, DeviceType> output_dv(output_view_dev,output_view_host);
46 if(input_dv.need_sync_host()) output_dv.modify_device();
47 if(input_dv.need_sync_device()) output_dv.modify_host();
48 return output_dv;
49}
50
51} // namespace Details
52} // namespace Tpetra
53
54#endif // TPETRA_DETAILS_CASTAWAYCONSTDUALVIEW_HPP
Nonmember function that computes a residual Computes R = B - A * X.
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.