Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Kokkos_View_Utils_Def.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef KOKKOS_VIEW_UTILS_DEF_HPP
11 #define KOKKOS_VIEW_UTILS_DEF_HPP
12 
13 #include "Kokkos_View_Utils.hpp"
14 //#include "Kokkos_ExecPolicy.hpp"
15 //#include "Kokkos_Parallel.hpp"
16 
17 namespace Kokkos {
18 
19 namespace Impl {
20 
21 // Specialization for deep_copy( view, view::value_type ) for Cuda
22 
23 template <class OutputView, typename Enabled>
24 struct StokhosViewFill
25 {
26  typedef typename OutputView::const_value_type const_value_type ;
28 
29  const OutputView output ;
31 
32  KOKKOS_INLINE_FUNCTION
33  void operator()( const size_t i0 ) const
34  {
35  const size_t n1 = output.extent(1);
36  const size_t n2 = output.extent(2);
37  const size_t n3 = output.extent(3);
38  const size_t n4 = output.extent(4);
39  const size_t n5 = output.extent(5);
40  const size_t n6 = output.extent(6);
41  const size_t n7 = output.extent(7);
42 
43  for ( size_t i1 = 0 ; i1 < n1 ; ++i1 ) {
44  for ( size_t i2 = 0 ; i2 < n2 ; ++i2 ) {
45  for ( size_t i3 = 0 ; i3 < n3 ; ++i3 ) {
46  for ( size_t i4 = 0 ; i4 < n4 ; ++i4 ) {
47  for ( size_t i5 = 0 ; i5 < n5 ; ++i5 ) {
48  for ( size_t i6 = 0 ; i6 < n6 ; ++i6 ) {
49  for ( size_t i7 = 0 ; i7 < n7 ; ++i7 ) {
50  output.access(i0,i1,i2,i3,i4,i5,i6,i7) = input ;
51  }}}}}}}
52  }
53 
54  StokhosViewFill( const OutputView & arg_out , const_value_type & arg_in )
55  : output( arg_out ), input( arg_in )
56  {
57  const size_t n0 = output.extent(0);
58  Kokkos::RangePolicy<execution_space> policy( 0, n0 );
59  Kokkos::parallel_for( policy, *this );
60  execution_space().fence();
61  }
62 };
63 } // namespace Impl
64 
65 } // namespace Kokkos
66 
67 #endif // KOKKOS_VIEW_UTILS_DEF_HPP
Kokkos::DefaultExecutionSpace execution_space
KOKKOS_INLINE_FUNCTION void operator()(const size_t i0) const
OutputView::const_value_type const_value_type
OutputView::execution_space execution_space
StokhosViewFill(const OutputView &arg_out, const_value_type &arg_in)