Debian Codegraph @

packages/kokkos-kernels/batched/dense/impl/KokkosBatched_Vector_SIMD_Logical.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 #ifndef KOKKOSBATCHED_VECTOR_SIMD_LOGICAL_HPP
17 #define KOKKOSBATCHED_VECTOR_SIMD_LOGICAL_HPP
18
19 /// \author Kyungjoo Kim ([email protected])
20
21 #include "Kokkos_Complex.hpp"
22
23 namespace KokkosBatched {
24
25 #define KOKKOSKERNELS_SIMD_LOGICAL_RETURN_BOOL_TYPE(T0, T1, l) \
26 typename std::enable_if<std::is_integral<T0>::value && std::is_integral<T1>::value, \
27 const Vector<SIMD<bool>, l> >::type
28
29 template <typename T, int l>
30 KOKKOS_INLINE_FUNCTION static typename std::enable_if<std::is_integral<T>::value, const Vector<SIMD<bool>, l> >::type
31 operator!(const Vector<SIMD<T>, l> &a) {
32 Vector<SIMD<bool>, l> r_val;
33 #if defined(KOKKOS_ENABLE_PRAGMA_IVDEP)
34 #pragma ivdep
35 #endif
36 #if defined(KOKKOS_ENABLE_PRAGMA_VECTOR)
37 #pragma vector always
38 #endif
39 for (int i = 0; i < l; ++i) r_val[i] = !a[i];
40 return r_val;
41 }
42
43 template <typename T0, typename T1, int l>
44 KOKKOS_INLINE_FUNCTION static KOKKOSKERNELS_SIMD_LOGICAL_RETURN_BOOL_TYPE(T0, T1, l) operator||(
45 const Vector<SIMD<T0>, l> &a, const Vector<SIMD<T1>, l> &b) {
46 Vector<SIMD<bool>, l> r_val;
47 #if defined(KOKKOS_ENABLE_PRAGMA_IVDEP)
48 #pragma ivdep
49 #endif
50 #if defined(KOKKOS_ENABLE_PRAGMA_VECTOR)
51 #pragma vector always
52 #endif
53 for (int i = 0; i < l; ++i) r_val[i] = a[i] || b[i];
54 return r_val;
55 }
56
57 template <typename T0, typename T1, int l>
58 KOKKOS_INLINE_FUNCTION static KOKKOSKERNELS_SIMD_LOGICAL_RETURN_BOOL_TYPE(T0, T1, l) operator&&(
59 const Vector<SIMD<T0>, l> &a, const Vector<SIMD<T1>, l> &b) {
60 Vector<SIMD<bool>, l> r_val;
61 #if defined(KOKKOS_ENABLE_PRAGMA_IVDEP)
62 #pragma ivdep
63 #endif
64 #if defined(KOKKOS_ENABLE_PRAGMA_VECTOR)
65 #pragma vector always
66 #endif
67 for (int i = 0; i < l; ++i) r_val[i] = a[i] && b[i];
68 return r_val;
69 }
70
71 template <typename T0, typename T1, int l>
72 KOKKOS_INLINE_FUNCTION static KOKKOSKERNELS_SIMD_LOGICAL_RETURN_BOOL_TYPE(T0, T1, l) operator||(
73 const Vector<SIMD<T0>, l> &a, const T1 &b) {
74 Vector<SIMD<bool>, l> r_val;
75 #if defined(KOKKOS_ENABLE_PRAGMA_IVDEP)
76 #pragma ivdep
77 #endif
78 #if defined(KOKKOS_ENABLE_PRAGMA_VECTOR)
79 #pragma vector always
80 #endif
81 for (int i = 0; i < l; ++i) r_val[i] = a[i] || b;
82 return r_val;
83 }
84
85 template <typename T0, typename T1, int l>
86 KOKKOS_INLINE_FUNCTION static KOKKOSKERNELS_SIMD_LOGICAL_RETURN_BOOL_TYPE(T0, T1, l) operator&&(
87 const Vector<SIMD<T0>, l> &a, const T1 &b) {
88 Vector<SIMD<bool>, l> r_val;
89 #if defined(KOKKOS_ENABLE_PRAGMA_IVDEP)
90 #pragma ivdep
91 #endif
92 #if defined(KOKKOS_ENABLE_PRAGMA_VECTOR)
93 #pragma vector always
94 #endif
95 for (int i = 0; i < l; ++i) r_val[i] = a[i] && b;
96 return r_val;
97 }
98
99 template <typename T0, typename T1, int l>
100 KOKKOS_INLINE_FUNCTION static KOKKOSKERNELS_SIMD_LOGICAL_RETURN_BOOL_TYPE(T0, T1, l) operator||(
101 const T0 &a, const Vector<SIMD<T1>, l> &b) {
102 Vector<SIMD<bool>, l> r_val;
103 #if defined(KOKKOS_ENABLE_PRAGMA_IVDEP)
104 #pragma ivdep
105 #endif
106 #if defined(KOKKOS_ENABLE_PRAGMA_VECTOR)
107 #pragma vector always
108 #endif
109 for (int i = 0; i < l; ++i) r_val[i] = a || b[i];
110 return r_val;
111 }
112
113 template <typename T0, typename T1, int l>
114 KOKKOS_INLINE_FUNCTION static KOKKOSKERNELS_SIMD_LOGICAL_RETURN_BOOL_TYPE(T0, T1, l) operator&&(
115 const T0 &a, const Vector<SIMD<T1>, l> &b) {
116 Vector<SIMD<bool>, l> r_val;
117 #if defined(KOKKOS_ENABLE_PRAGMA_IVDEP)
118 #pragma ivdep
119 #endif
120 #if defined(KOKKOS_ENABLE_PRAGMA_VECTOR)
121 #pragma vector always
122 #endif
123 for (int i = 0; i < l; ++i) r_val[i] = a && b[i];
124 return r_val;
125 }
126 #undef KOKKOSKERNELS_SIMD_LOGICAL_RETURN_BOOL_TYPE
127 } // namespace KokkosBatched
128
129 #endif