Skip to content

Commit 0b5757b

Browse files
authored
[SYCL][COMPLEX] Split complex header file and tests into multiple files (#11600)
This PR is the first step toward restructuring the `complex` API. As discussed in #8647 and #10854, the goal here is to clean the future-to-be `complex` API. To simplify the review of these changes, a new PR (this PR) is created to not overload #8647. IF/WHEN this will be approved, the second step which does the same for the `marray`'s complex specialization will be pushed onto #8647 Here's an overview of what has changed: For the users, the only change is the include. Instead of including `<sycl/ext/oneapi/experimental/sycl_complex.hpp>`, it will now be `<sycl/ext/oneapi/experimental/complex/complex.hpp>` The `complex.hpp` header files include all the `complex/detail` header file (the `complex` API), in order to abstract the headers needed for the users. However, the users can include (if necessary) the specific component of the API located in `complex/detail`. Here's the overview of what the complex directory will contain when the whole API is merged. ``` - complex - complex.hpp - detail - complex.hpp - complex_math.hpp - complex_group_algorithm.hpp - marray.hpp - marray_math.hpp - marray_group_algorithm.hpp - common.hpp ``` Finally, here's the overview of the `sycl/test/extension` ``` - complex - complex.cpp - marray.cpp ```
1 parent 4399e4f commit 0b5757b

File tree

8 files changed

+521
-440
lines changed

8 files changed

+521
-440
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//===- complex.hpp --------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#pragma once
10+
11+
#ifdef SYCL_EXT_ONEAPI_COMPLEX
12+
13+
#include "./detail/complex.hpp"
14+
#include "./detail/complex_math.hpp"
15+
16+
#endif // SYCL_EXT_ONEAPI_COMPLEX
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//===- common.hpp ---------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#pragma once
10+
11+
#include <type_traits>
12+
13+
#include <sycl/half_type.hpp>
14+
15+
namespace sycl {
16+
inline namespace _V1 {
17+
18+
namespace ext {
19+
namespace oneapi {
20+
namespace experimental {
21+
22+
////////////////////////////////////////////////////////////////////////////////
23+
/// FORWARD DECLARATIONS
24+
////////////////////////////////////////////////////////////////////////////////
25+
26+
template <class _Tp> struct is_genfloat;
27+
28+
template <class _Tp, class _Enable = void> class complex;
29+
30+
template <class _Tp>
31+
class complex<_Tp, typename std::enable_if_t<is_genfloat<_Tp>::value>>;
32+
33+
////////////////////////////////////////////////////////////////////////////////
34+
/// TRAITS
35+
////////////////////////////////////////////////////////////////////////////////
36+
37+
template <class _Tp>
38+
struct is_genfloat
39+
: std::integral_constant<bool, std::is_same_v<_Tp, double> ||
40+
std::is_same_v<_Tp, float> ||
41+
std::is_same_v<_Tp, sycl::half>> {};
42+
43+
template <class _Tp>
44+
struct is_gencomplex
45+
: std::integral_constant<bool,
46+
std::is_same_v<_Tp, complex<double>> ||
47+
std::is_same_v<_Tp, complex<float>> ||
48+
std::is_same_v<_Tp, complex<sycl::half>>> {};
49+
50+
////////////////////////////////////////////////////////////////////////////////
51+
/// DEFINES
52+
////////////////////////////////////////////////////////////////////////////////
53+
54+
#define _SYCL_EXT_CPLX_INLINE_VISIBILITY \
55+
inline __attribute__((__visibility__("hidden"), __always_inline__))
56+
57+
} // namespace experimental
58+
} // namespace oneapi
59+
} // namespace ext
60+
61+
} // namespace _V1
62+
} // namespace sycl

0 commit comments

Comments
 (0)