Eigen  3.4.90 (git rev 5a9f66fb35d03a4da9ef8976e67a61b30aa16dcf)
 
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: <[email protected]>
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// IWYU pragma: private
25#include "../../InternalHeaderCheck.h"
26
27namespace Eigen {
28
29namespace internal {
30#ifdef SYCL_DEVICE_ONLY
31template <>
32struct type_casting_traits<float, int> {
33 enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 1 };
34};
35
36template <>
37EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE cl::sycl::cl_int4 pcast<cl::sycl::cl_float4, cl::sycl::cl_int4>(
38 const cl::sycl::cl_float4& a) {
39 return a.template convert<cl::sycl::cl_int, cl::sycl::rounding_mode::automatic>();
40}
41
42template <>
43struct type_casting_traits<int, float> {
44 enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 1 };
45};
46
47template <>
48EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE cl::sycl::cl_float4 pcast<cl::sycl::cl_int4, cl::sycl::cl_float4>(
49 const cl::sycl::cl_int4& a) {
50 return a.template convert<cl::sycl::cl_float, cl::sycl::rounding_mode::automatic>();
51}
52
53template <>
54struct type_casting_traits<double, float> {
55 enum { VectorizedCast = 1, SrcCoeffRatio = 2, TgtCoeffRatio = 1 };
56};
57
58template <>
59EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE cl::sycl::cl_float4 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, cl::sycl::rounding_mode::automatic>();
62 auto b1 = b.template convert<cl::sycl::cl_float, cl::sycl::rounding_mode::automatic>();
63 return cl::sycl::cl_float4(a1.x(), a1.y(), b1.x(), b1.y());
64}
65
66template <>
67struct type_casting_traits<float, double> {
68 enum { VectorizedCast = 1, SrcCoeffRatio = 1, TgtCoeffRatio = 2 };
69};
70
71template <>
72EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE cl::sycl::cl_double2 pcast<cl::sycl::cl_float4, cl::sycl::cl_double2>(
73 const cl::sycl::cl_float4& a) {
74 // Simply discard the second half of the input
75 return cl::sycl::cl_double2(a.x(), a.y());
76}
77
78#endif
79} // end namespace internal
80
81} // end namespace Eigen
82
83#endif // EIGEN_TYPE_CASTING_SYCL_H
Namespace containing all symbols from the Eigen library.
Definition Core:137