Debian Codegraph @

packages/kokkos-kernels/batched/dense/unit_test/Test_Batched_TeamVectorEigendecomposition.hpp

raw
1 //@HEADER
2 // ************************************************************************
3 //
4 // Kokkos v. 4.0
5 // Copyright (2022) National Technology & Engineering
6 // Solutions of Sandia, LLC (NTESS).
7 //
8 // Under the terms of Contract DE-NA0003525 with NTESS,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
12 // See https://kokkos.org/LICENSE for license information.
13 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
14 //
15 //@HEADER
16 /// \author Kyungjoo Kim ([email protected])
17
18 /*
19 #include "gtest/gtest.h"
20 #include "Kokkos_Core.hpp"
21 #include "Kokkos_Random.hpp"
22
23 #include "KokkosBatched_Eigendecomposition_Decl.hpp"
24 #include "KokkosBatched_Eigendecomposition_TeamVector_Impl.hpp"
25
26 #include "KokkosKernels_TestUtils.hpp"
27
28 using namespace KokkosBatched;
29
30 namespace Test {
31
32 template<typename DeviceType,
33 typename ViewRank3Type,
34 typename ViewRank2Type>
35 struct Functor_TestBatchedTeamVectorEigendecomposition {
36 ViewRank3Type _A;
37 ViewRank2Type _Er, _Ei;
38 ViewRank3Type _UL, _UR;
39 ViewRank2Type _W;
40
41 KOKKOS_INLINE_FUNCTION
42 Functor_TestBatchedTeamVectorEigendecomposition(const ViewRank3Type A,
43 const ViewRank2Type Er,
44 const ViewRank2Type Ei,
45 const ViewRank3Type UL,
46 const ViewRank3Type UR,
47 const ViewRank2Type W)
48 : _A(A), _Er(Er), _Ei(Ei), _UL(UL), _UR(UR), _W(W)
49 {}
50
51 template<typename MemberType>
52 KOKKOS_INLINE_FUNCTION
53 void operator()(const MemberType &member) const {
54 const int k = member.league_rank();
55 auto A = Kokkos::subview(_A, k, Kokkos::ALL(), Kokkos::ALL());
56 auto er = Kokkos::subview(_Er, k, Kokkos::ALL());
57 auto ei = Kokkos::subview(_Ei, k, Kokkos::ALL());
58 auto UL = Kokkos::subview(_UL, k, Kokkos::ALL(), Kokkos::ALL());
59 auto UR = Kokkos::subview(_UR, k, Kokkos::ALL(), Kokkos::ALL());
60 auto W = Kokkos::subview(_W, k, Kokkos::ALL());
61
62 TeamVectorEigendecomposition<MemberType>::invoke(member, A, er, ei, UL,
63 UR, W);
64 }
65
66 inline
67 void run() {
68 typedef typename ViewRank3Type::value_type value_type;
69 std::string
70 name_region("KokkosBatched::Test::TeamVectorEigendecomposition"); std::string
71 name_value_type = ( std::is_same<value_type,float>::value ? "::Float" :
72 std::is_same<value_type,double>::value ?
73 "::Double" : std::is_same<value_type,Kokkos::complex<float> >::value ?
74 "::ComplexFloat" : std::is_same<value_type,Kokkos::complex<double> >::value ?
75 "::ComplexDouble" : "::UnknownValueType" ); std::string name = name_region +
76 name_value_type; Kokkos::Profiling::pushRegion( name.c_str() );
77 Kokkos::TeamPolicy<execution_space> policy(_A.extent(0), Kokkos::AUTO);
78 Kokkos::parallel_for(name.c_str(), policy, *this);
79 Kokkos::Profiling::popRegion();
80 }
81 };
82
83 template<typename DeviceType,
84 typename ValueType,
85 typename LayoutType>
86 void impl_test_batched_teamvector_eigendecomposition(const int N, const int m)
87 { typedef ValueType value_type; typedef
88 Kokkos::View<value_type***,LayoutType,DeviceType> ViewRank3Type; typedef
89 Kokkos::View<value_type**,LayoutType,DeviceType> ViewRank2Type;
90
91 /// input
92 ViewRank3Type A("A", N, m, m);
93 ViewRank2Type W("W", N, 2*m*m+m*5);
94
95 /// output
96 ViewRank2Type Er("Er", N, m);
97 ViewRank2Type Ei("Ei", N, m);
98 ViewRank3Type UL("UL", N, m, m);
99 ViewRank3Type UR("UR", N, m, m);
100
101
102 Kokkos::Random_XorShift64_Pool<typename DeviceType::execution_space>
103 random(13718); Kokkos::fill_random(A, random, value_type(1.0)); Kokkos::fence();
104
105 /// test body
106 Functor_TestBatchedTeamVectorEigendecomposition
107 <DeviceType,ViewRank3Type,ViewRank2Type>(A, Er, Ei, UL, UR, W).run();
108 Kokkos::fence();
109 }
110 }
111
112 template<typename DeviceType,
113 typename ValueType>
114 int test_batched_teamvector_eigendecomposition() {
115 // #if defined(KOKKOSKERNELS_INST_LAYOUTLEFT)
116 // {
117 //
118 Test::impl_test_batched_teamvector_eigendecomposition<DeviceType,ValueType,Kokkos::LayoutLeft>(10,
119 10);
120 // for (int i=0;i<10;++i) {
121 //
122 Test::impl_test_batched_teamvector_eigendecomposition<DeviceType,ValueType,Kokkos::LayoutLeft>(10,
123 1);
124 // }
125 // }
126 // #endif
127 #if defined(KOKKOSKERNELS_INST_LAYOUTRIGHT)
128 {
129 Test::impl_test_batched_teamvector_eigendecomposition<DeviceType,ValueType,Kokkos::LayoutRight>(10,
130 10); for (int i=0;i<10;++i) {
131 Test::impl_test_batched_teamvector_eigendecomposition<DeviceType,ValueType,Kokkos::LayoutRight>(10,
132 1);
133 }
134 }
135 #endif
136
137 return 0;
138 }
139 */