Skip to content

Commit

Permalink
[SYCL][COMPLEX] Split complex header file and tests into multiple fil…
Browse files Browse the repository at this point in the history
…es (#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
```
  • Loading branch information
jle-quel authored Oct 30, 2023
1 parent 4399e4f commit 0b5757b
Show file tree
Hide file tree
Showing 8 changed files with 521 additions and 440 deletions.
16 changes: 16 additions & 0 deletions sycl/include/sycl/ext/oneapi/experimental/complex/complex.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//===- complex.hpp --------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#pragma once

#ifdef SYCL_EXT_ONEAPI_COMPLEX

#include "./detail/complex.hpp"
#include "./detail/complex_math.hpp"

#endif // SYCL_EXT_ONEAPI_COMPLEX
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//===- common.hpp ---------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#pragma once

#include <type_traits>

#include <sycl/half_type.hpp>

namespace sycl {
inline namespace _V1 {

namespace ext {
namespace oneapi {
namespace experimental {

////////////////////////////////////////////////////////////////////////////////
/// FORWARD DECLARATIONS
////////////////////////////////////////////////////////////////////////////////

template <class _Tp> struct is_genfloat;

template <class _Tp, class _Enable = void> class complex;

template <class _Tp>
class complex<_Tp, typename std::enable_if_t<is_genfloat<_Tp>::value>>;

////////////////////////////////////////////////////////////////////////////////
/// TRAITS
////////////////////////////////////////////////////////////////////////////////

template <class _Tp>
struct is_genfloat
: std::integral_constant<bool, std::is_same_v<_Tp, double> ||
std::is_same_v<_Tp, float> ||
std::is_same_v<_Tp, sycl::half>> {};

template <class _Tp>
struct is_gencomplex
: std::integral_constant<bool,
std::is_same_v<_Tp, complex<double>> ||
std::is_same_v<_Tp, complex<float>> ||
std::is_same_v<_Tp, complex<sycl::half>>> {};

////////////////////////////////////////////////////////////////////////////////
/// DEFINES
////////////////////////////////////////////////////////////////////////////////

#define _SYCL_EXT_CPLX_INLINE_VISIBILITY \
inline __attribute__((__visibility__("hidden"), __always_inline__))

} // namespace experimental
} // namespace oneapi
} // namespace ext

} // namespace _V1
} // namespace sycl
Loading

0 comments on commit 0b5757b

Please sign in to comment.