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
gtsam.examples.DogLegOptimizerExample.int
int
Definition: DogLegOptimizerExample.py:111
EIGEN_DEVICE_FUNC
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:976
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
simple_graph::b1
Vector2 b1(2, -1)
b
Scalar * b
Definition: benchVecAdd.cpp:17
Vector2::y
float y
Definition: test_operator_overloading.cpp:94
align_3::a1
Point2 a1
Definition: testPose2.cpp:769
EIGEN_ALWAYS_INLINE
#define EIGEN_ALWAYS_INLINE
Definition: Macros.h:932
Eigen::internal::type_casting_traits::SrcCoeffRatio
@ SrcCoeffRatio
Definition: GenericPacketMath.h:151
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
Eigen::internal::type_casting_traits::TgtCoeffRatio
@ TgtCoeffRatio
Definition: GenericPacketMath.h:152
gtsam.examples.DogLegOptimizerExample.float
float
Definition: DogLegOptimizerExample.py:113
internal
Definition: BandTriangularSolver.h:13
Vector2::x
float x
Definition: test_operator_overloading.cpp:94
Eigen::internal::type_casting_traits::VectorizedCast
@ VectorizedCast
Definition: GenericPacketMath.h:150
gtsam::convert
static BinaryMeasurement< Rot3 > convert(const BetweenFactor< Pose3 >::shared_ptr &f)
Definition: ShonanAveraging.cpp:993


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:09:37