60 typedef typename ViewFac::value_type value_type;
61 typedef typename View1::device_type device_type;
62 typedef typename View1::size_type size_type;
63 typedef Kokkos::View<value_type*,device_type> ViewTmp;
65 static_assert( unsigned(View1::rank) == 2,
"" );
66 static_assert( unsigned(View2::rank) == 1,
"" );
68 const size_type m = v1.extent(0);
69 const size_type n = v1.extent(1);
70 ViewTmp vtmp = ViewFac::template create_view<ViewTmp>(v1,v2,
"tmp",m);
72 Kokkos::parallel_for(m, KOKKOS_LAMBDA (
const size_type
i) {
74 for (size_type j=0; j<n; ++j)
116int main(
int argc,
char* argv[]) {
118#if !defined(__CUDACC__)
120 typedef Kokkos::DefaultExecutionSpace execution_space;
122 Kokkos::initialize(argc, argv);
126 const size_t deriv_dim = 1;
132 Kokkos::View<double**,execution_space> v1(
"v1",m,n);
133 Kokkos::View<double* ,execution_space> v2(
"v2",n);
135 Kokkos::deep_copy(v1, 2.0);
136 Kokkos::deep_copy(v2, 3.0);
140 std::cout <<
"v3 = " << std::endl;
141 for (
size_t i=0;
i<m; ++
i) {
142 std::cout <<
"\t" << v3(
i) << std::endl;
147 Kokkos::View<FadType*,execution_space> v2_fad(
"v2_fad",n,deriv_dim+1);
148 Kokkos::deep_copy(v2_fad,
FadType(deriv_dim, 0, 3.0));
150 auto v3_fad =
my_func(v1,v2_fad);
152 std::cout <<
"v3_fad = " << std::endl;
153 for (
size_t i=0;
i<m; ++
i) {
154 std::cout <<
"\t" << v3_fad(
i) << std::endl;
159#if defined(HAVE_SACADO_KOKKOSCONTAINERS)
164 Kokkos::DynRankView<double,execution_space> v1(
"v1",m,n);
165 Kokkos::DynRankView<double,execution_space> v2(
"v2",n);
167 Kokkos::deep_copy(v1, 2.0);
168 Kokkos::deep_copy(v2, 3.0);
170 auto v3 = my_func_dynamic(v1,v2);
172 std::cout <<
"v3 = " << std::endl;
173 for (
size_t i=0;
i<m; ++
i) {
174 std::cout <<
"\t" << v3(
i) << std::endl;
179 Kokkos::DynRankView<FadType,execution_space> v2_fad(
"v2_fad",n,deriv_dim+1);
180 Kokkos::deep_copy(v2_fad,
FadType(deriv_dim, 0, 3.0));
182 auto v3_fad = my_func_dynamic(v1,v2_fad);
184 std::cout <<
"v3_fad = " << std::endl;
185 for (
size_t i=0;
i<m; ++
i) {
186 std::cout <<
"\t" << v3_fad(
i) << std::endl;