Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Fad_KokkosTests_ViewCornerCases.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Sacado Package
4 //
5 // Copyright 2006 NTESS and the Sacado contributors.
6 // SPDX-License-Identifier: LGPL-2.1-or-later
7 // *****************************************************************************
8 // @HEADER
9 
13 
14 #include "Kokkos_Core.hpp"
15 #include "Sacado.hpp"
16 
17 // Tests special size alignment for SFad on Cuda is correct
18 TEUCHOS_UNIT_TEST(Kokkos_View_CornerCases, ViewOfUnmanagedView)
19 {
20  using fad_t = Sacado::Fad::SFad<double, 3>;
21  using inner_t = Kokkos::View<fad_t*, Kokkos::HostSpace, Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
22  using outer_t = Kokkos::View<inner_t*, Kokkos::HostSpace>;
23 
24  Kokkos::View<fad_t*, Kokkos::HostSpace> data("data", 9, 4);
25  TEUCHOS_TEST_EQUALITY(data.use_count(), 1, out, success);
26  {
27  outer_t A("A", 10);
28 
29  for(int i=0 ; i<10; i++) A(i) = data;
30  TEUCHOS_TEST_EQUALITY(data.use_count(), 1, out, success);
31  }
32  TEUCHOS_TEST_EQUALITY(data.use_count(), 1, out, success);
33  data = Kokkos::View<fad_t*, Kokkos::HostSpace>();
34  TEUCHOS_TEST_EQUALITY(data.use_count(), 0, out, success);
35 }
36 
37 int main( int argc, char* argv[] ) {
38  Teuchos::GlobalMPISession mpiSession(&argc, &argv);
39 
40  // Initialize serial
41  Kokkos::initialize(argc,argv);
42 
44 
45  Kokkos::finalize();
46 
47  return res;
48 }
TEUCHOS_UNIT_TEST(Conversion, IsConvertible)
static int runUnitTestsFromMain(int argc, char *argv[])
#define A
Definition: Sacado_rad.hpp:552
int main()
Definition: ad_example.cpp:171
#define TEUCHOS_TEST_EQUALITY(v1, v2, out, success)