Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9
Eigen  3.4.0
 
Loading...
Searching...
No Matches
SYCL/TypeCasting.h
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
24namespace Eigen {
25
26namespace internal {
27#ifdef SYCL_DEVICE_ONLY
28template <>
29struct type_casting_traits<float, int> {
30 enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 1 };
31};
32
33template <>
34EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE cl::sycl::cl_int4
35pcast<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
40template <>
41struct type_casting_traits<int, float> {
42 enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 1 };
43};
44
45template <>
46EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE cl::sycl::cl_float4
47pcast<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
52template <>
53struct type_casting_traits<double, float> {
54 enum { VectorizedCast = 1, SrcCoeffRatio = 2, TgtCoeffRatio = 1 };
55};
56
57template <>
58EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE cl::sycl::cl_float4
59pcast<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
68template <>
69struct type_casting_traits<float, double> {
70 enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 2 };
71};
72
73template <>
74EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE cl::sycl::cl_double2
75pcast<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
Namespace containing all symbols from the Eigen library.
Definition: Core:141