SYCL/TypeCasting.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Mehdi Goli Codeplay Software Ltd.
5 // Ralph Potter Codeplay Software Ltd.
6 // Luke Iwanski Codeplay Software Ltd.
7 // Contact: <eigen@codeplay.com>
8 //
9 // This Source Code Form is subject to the terms of the Mozilla
10 // Public License v. 2.0. If a copy of the MPL was not distributed
11 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 
13 /*****************************************************************
14  * TypeCasting.h
15  *
16  * \brief:
17  * TypeCasting
18  *
19  *****************************************************************/
20 
21 #ifndef EIGEN_TYPE_CASTING_SYCL_H
22 #define EIGEN_TYPE_CASTING_SYCL_H
23 
24 namespace Eigen {
25 
26 namespace internal {
27 #ifdef SYCL_DEVICE_ONLY
28 template <>
29 struct type_casting_traits<float, int> {
30  enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 1 };
31 };
32 
33 template <>
34 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE cl::sycl::cl_int4
35 pcast<cl::sycl::cl_float4, cl::sycl::cl_int4>(const cl::sycl::cl_float4& a) {
36  return a
37  .template convert<cl::sycl::cl_int, cl::sycl::rounding_mode::automatic>();
38 }
39 
40 template <>
41 struct type_casting_traits<int, float> {
42  enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 1 };
43 };
44 
45 template <>
46 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE cl::sycl::cl_float4
47 pcast<cl::sycl::cl_int4, cl::sycl::cl_float4>(const cl::sycl::cl_int4& a) {
48  return a.template convert<cl::sycl::cl_float,
49  cl::sycl::rounding_mode::automatic>();
50 }
51 
52 template <>
53 struct type_casting_traits<double, float> {
54  enum { VectorizedCast = 1, SrcCoeffRatio = 2, TgtCoeffRatio = 1 };
55 };
56 
57 template <>
58 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE cl::sycl::cl_float4
59 pcast<cl::sycl::cl_double2, cl::sycl::cl_float4>(
60  const cl::sycl::cl_double2& a, const cl::sycl::cl_double2& b) {
61  auto a1 = a.template convert<cl::sycl::cl_float,
62  cl::sycl::rounding_mode::automatic>();
63  auto b1 = b.template convert<cl::sycl::cl_float,
64  cl::sycl::rounding_mode::automatic>();
65  return cl::sycl::float4(a1.x(), a1.y(), b1.x(), b1.y());
66 }
67 
68 template <>
69 struct type_casting_traits<float, double> {
70  enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 2 };
71 };
72 
73 template <>
74 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE cl::sycl::cl_double2
75 pcast<cl::sycl::cl_float4, cl::sycl::cl_double2>(const cl::sycl::cl_float4& a) {
76  // Simply discard the second half of the input
77  return cl::sycl::cl_double2(a.x(), a.y());
78 }
79 
80 #endif
81 } // end namespace internal
82 
83 } // end namespace Eigen
84 
85 #endif // EIGEN_TYPE_CASTING_SYCL_H
Point2 a1
Definition: testPose2.cpp:769
#define EIGEN_ALWAYS_INLINE
Definition: Macros.h:932
Scalar * b
Definition: benchVecAdd.cpp:17
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:976
static BinaryMeasurement< Rot3 > convert(const BetweenFactor< Pose3 >::shared_ptr &f)
Vector2 b1(2, -1)


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:40:39