Skip to content

[SYCL] Rename cuda, hip and fix renaming for level_zero backends #4785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
518ebf8
[SYCL] Rename cuda, hip and fix renaming for level_zero backends
Oct 19, 2021
f56d58b
[SYCL] Fix formatting issues
Oct 19, 2021
1c42174
[SYCL] Fix formatting issues
Oct 19, 2021
922d4ce
[SYCL] Move CL/sycl/backend/cuda.hpp file into sycl/ext/oneapi/backen…
Oct 19, 2021
be32b16
[SYCL] Move cuda-related properties to the "sycl::ext::oneapi::cuda" …
Oct 20, 2021
2dd534b
[SYCL] Add new symbols in the sycl_symbols_windows.dump test
Oct 21, 2021
ef19d6f
[SYCL] Fix formatting issues
Oct 21, 2021
071cdb8
[SYCL] Add new symbols in the sycl_symbols_linux.dump test
Oct 21, 2021
78f58ea
[SYCL] Add a new symbol in the sycl_symbols_linux.dump test
Oct 22, 2021
5dd275b
[SYCL] Include moved cuda backend header in feature_test.hpp.in
Oct 22, 2021
02de3e8
[SYCL] Mark a set of make functions for opencl as deprecated
Oct 22, 2021
b03fc38
[SYCL] Move sycl::interop template into the sycl::detail namespace
Oct 25, 2021
815d4bc
[SYCL] Typo fixed in opencl.hpp
Oct 25, 2021
2806d9d
[SYCL] Restore header independence in sycl.hpp
Oct 26, 2021
be53b40
[SYCL][NFC] Copy TODO comments from opencl backend trait to the others
Oct 26, 2021
b73560f
[SYCL] Optimize includes for the Level Zero backend
Oct 26, 2021
a514b1b
[SYCL][NFC] Fix formatting issues
Oct 26, 2021
93c9e15
[SYCL][NFC] Fix formatting issues
Oct 26, 2021
577059c
[SYCL][NFC] Fix formatting issues
Oct 26, 2021
60afe43
[SYCL][NFC] Fix formatting issues
Oct 26, 2021
8c89502
[SYCL] Make the assert_happened.hpp header independent
Oct 26, 2021
9fca827
[SYCL] Actualize the warning in the CL/sycl/backend/cuda.hpp header
Oct 26, 2021
5630a2d
[SYCL] Move includes of backends from feature_test.hpp.in
Oct 26, 2021
849e964
[SYCL] Remove includes of sycl/ext/oneapi/backend/cuda.hpp from tests
Oct 26, 2021
acfe248
[SYCL] Add test for level_zero backend interops with __SYCL_INTERNAL_API
Oct 27, 2021
4889ad0
[SYCL] Make the known_identity.hpp header independent
Oct 27, 2021
070194b
[SYCL] Fix sycl/ext/oneapi/backend/level_zero.hpp compilation issues
Oct 27, 2021
eebadaf
[SYCL] Fix sycl/ext/oneapi/backend/level_zero.hpp compilation issues 2
Oct 27, 2021
437f952
[SYCL] Fix sycl/ext/oneapi/backend/level_zero.hpp compilation issues 3
Oct 27, 2021
0a4ee29
[SYCL] Move the SYCL/Basic/interop/traits.cpp test from llvm-test-suite
Oct 28, 2021
79ccff6
[SYCL] Trigger precommit tests
Oct 28, 2021
7030286
Merge branch 'sycl' into cuda-hip-backends-in-sycl-2020
Nov 8, 2021
f18ad74
[SYCL] Fix property_traits and context tests
Nov 8, 2021
ae5780b
Update sycl/include/CL/sycl/backend_types.hpp
againull Nov 11, 2021
e136ddc
[SYCL][NFC] Fix formatting issues
Nov 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions sycl/include/CL/sycl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#include <CL/sycl/atomic.hpp>
#include <CL/sycl/atomic_fence.hpp>
#include <CL/sycl/backend.hpp>
#if SYCL_BACKEND_OPENCL
#include <CL/sycl/backend/opencl.hpp>
#endif
#include <CL/sycl/buffer.hpp>
#include <CL/sycl/builtins.hpp>
#include <CL/sycl/context.hpp>
Expand Down Expand Up @@ -53,6 +56,9 @@
#include <CL/sycl/usm.hpp>
#include <CL/sycl/version.hpp>
#include <sycl/ext/oneapi/atomic.hpp>
#if SYCL_EXT_ONEAPI_BACKEND_LEVEL_ZERO
#include <sycl/ext/oneapi/backend/level_zero.hpp>
#endif
#include <sycl/ext/oneapi/experimental/builtins.hpp>
#include <sycl/ext/oneapi/filter_selector.hpp>
#include <sycl/ext/oneapi/group_algorithm.hpp>
Expand Down
31 changes: 16 additions & 15 deletions sycl/include/CL/sycl/backend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,20 @@
#pragma once

#include <CL/sycl/accessor.hpp>
#include <CL/sycl/backend.hpp>
#include <CL/sycl/backend_types.hpp>
#include <CL/sycl/buffer.hpp>
#include <CL/sycl/context.hpp>
#include <CL/sycl/detail/backend_traits.hpp>
#include <CL/sycl/feature_test.hpp>
#if SYCL_BACKEND_OPENCL
#include <CL/sycl/detail/backend_traits_opencl.hpp>
#endif
#if SYCL_EXT_ONEAPI_BACKEND_CUDA
#include <CL/sycl/detail/backend_traits_cuda.hpp>
#endif
#if SYCL_EXT_ONEAPI_BACKEND_LEVEL_ZERO
#include <CL/sycl/detail/backend_traits_level_zero.hpp>
#endif
#include <CL/sycl/detail/common.hpp>
#include <CL/sycl/detail/export.hpp>
#include <CL/sycl/detail/pi.h>
Expand All @@ -31,16 +40,6 @@ __SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {

namespace detail {
template <backend Backend, typename T> struct BackendInput {
// TODO replace usage of interop with specializations.
using type = typename interop<Backend, T>::type;
};

template <backend Backend, typename T> struct BackendReturn {
// TODO replace usage of interop with specializations.
using type = typename interop<Backend, T>::type;
};

// TODO each backend can have its own custom errc enumeration
// but the details for this are not fully specified yet
enum class backend_errc : unsigned int {};
Expand Down Expand Up @@ -69,8 +68,10 @@ template <backend BackendName, class SyclObjectT>
auto get_native(const SyclObjectT &Obj)
-> backend_return_t<BackendName, SyclObjectT> {
// TODO use SYCL 2020 exception when implemented
if (Obj.get_backend() != BackendName)
if (Obj.get_backend() != BackendName) {
throw runtime_error("Backends mismatch", PI_INVALID_OPERATION);
}

return Obj.template get_native<BackendName>();
}

Expand All @@ -80,9 +81,9 @@ template <backend BackendName, typename DataT, int Dimensions,
access::placeholder IsPlaceholder>
auto get_native(const accessor<DataT, Dimensions, AccessMode, AccessTarget,
IsPlaceholder> &Obj) ->
typename interop<BackendName, accessor<DataT, Dimensions, AccessMode,
AccessTarget, IsPlaceholder>>::type =
delete;
typename detail::interop<
BackendName, accessor<DataT, Dimensions, AccessMode, AccessTarget,
IsPlaceholder>>::type = delete;

namespace detail {
// Forward declaration
Expand Down
58 changes: 2 additions & 56 deletions sycl/include/CL/sycl/backend/cuda.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,60 +9,6 @@

#pragma once

#include <CL/sycl/accessor.hpp>
#include <CL/sycl/backend_types.hpp>
#include <CL/sycl/context.hpp>
#include <CL/sycl/detail/defines.hpp>
#include <CL/sycl/device.hpp>
#include <CL/sycl/event.hpp>
#include <CL/sycl/queue.hpp>
#include <CL/sycl/detail/defines_elementary.hpp>

typedef int CUdevice;
typedef struct CUctx_st *CUcontext;
typedef struct CUstream_st *CUstream;
typedef struct CUevent_st *CUevent;
typedef struct CUmod_st *CUmodule;

// As defined in the CUDA 10.1 header file. This requires CUDA version > 3.2
#if defined(_WIN64) || defined(__LP64__)
typedef unsigned long long CUdeviceptr;
#else
typedef unsigned int CUdeviceptr;
#endif

__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {

template <> struct interop<backend::cuda, device> { using type = CUdevice; };

template <> struct interop<backend::cuda, context> { using type = CUcontext; };

template <> struct interop<backend::cuda, queue> { using type = CUstream; };

template <> struct interop<backend::cuda, event> { using type = CUevent; };

#ifdef __SYCL_INTERNAL_API
template <> struct interop<backend::cuda, program> { using type = CUmodule; };
#endif

template <typename DataT, int Dimensions, access::mode AccessMode>
struct interop<backend::cuda,
accessor<DataT, Dimensions, AccessMode, access::target::device,
access::placeholder::false_t>> {
using type = CUdeviceptr;
};

template <typename DataT, int Dimensions, access::mode AccessMode>
struct interop<backend::cuda, accessor<DataT, Dimensions, AccessMode,
access::target::constant_buffer,
access::placeholder::false_t>> {
using type = CUdeviceptr;
};

template <typename DataT, int Dimensions, typename AllocatorT>
struct interop<backend::cuda, buffer<DataT, Dimensions, AllocatorT>> {
using type = CUdeviceptr;
};

} // namespace sycl
} // namespace cl
__SYCL_WARNING("CL/sycl/backend/cuda.hpp is deprecated and no required anymore")
108 changes: 11 additions & 97 deletions sycl/include/CL/sycl/backend/opencl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,103 +9,13 @@

#pragma once

#include <CL/sycl/accessor.hpp>
#include <CL/sycl/backend.hpp>
#include <CL/sycl/backend_types.hpp>
#include <CL/sycl/detail/backend_traits.hpp>
#include <CL/sycl/detail/cl.h>
#include <CL/sycl/kernel_bundle.hpp>

#include <vector>

__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {

template <> struct interop<backend::opencl, platform> {
using type = cl_platform_id;
};

template <> struct interop<backend::opencl, device> {
using type = cl_device_id;
};

template <> struct interop<backend::opencl, context> {
using type = cl_context;
};

template <> struct interop<backend::opencl, queue> {
using type = cl_command_queue;
};

#ifdef __SYCL_INTERNAL_API
template <> struct interop<backend::opencl, program> {
using type = cl_program;
};
#endif

template <> struct interop<backend::opencl, event> { using type = cl_event; };

template <typename DataT, int Dimensions, access::mode AccessMode>
struct interop<backend::opencl,
accessor<DataT, Dimensions, AccessMode, access::target::device,
access::placeholder::false_t>> {
using type = cl_mem;
};

template <typename DataT, int Dimensions, access::mode AccessMode>
struct interop<backend::opencl, accessor<DataT, Dimensions, AccessMode,
access::target::constant_buffer,
access::placeholder::false_t>> {
using type = cl_mem;
};

template <typename DataT, int Dimensions, access::mode AccessMode>
struct interop<backend::opencl,
accessor<DataT, Dimensions, AccessMode, access::target::image,
access::placeholder::false_t>> {
using type = cl_mem;
};

template <typename DataT, int Dimensions, typename AllocatorT>
struct interop<backend::opencl, buffer<DataT, Dimensions, AllocatorT>> {
using type = cl_mem;
};

namespace detail {
template <bundle_state State>
struct BackendInput<backend::opencl, kernel_bundle<State>> {
using type = cl_program;
};

template <bundle_state State>
struct BackendReturn<backend::opencl, kernel_bundle<State>> {
using type = std::vector<cl_program>;
};

template <> struct BackendInput<backend::opencl, kernel> {
using type = cl_kernel;
};

template <> struct BackendReturn<backend::opencl, kernel> {
using type = cl_kernel;
};

template <> struct InteropFeatureSupportMap<backend::opencl> {
static constexpr bool MakePlatform = true;
static constexpr bool MakeDevice = true;
static constexpr bool MakeContext = true;
static constexpr bool MakeQueue = true;
static constexpr bool MakeEvent = true;
static constexpr bool MakeBuffer = true;
static constexpr bool MakeKernel = true;
static constexpr bool MakeKernelBundle = true;
};
} // namespace detail

namespace opencl {

// Implementation of various "make" functions resides in SYCL RT because
// creating SYCL objects requires knowing details not acessible here.
// creating SYCL objects requires knowing details not accessible here.
// Note that they take opaque pi_native_handle that real OpenCL handles
// are casted to.
//
Expand All @@ -122,42 +32,46 @@ __SYCL_EXPORT queue make_queue(const context &Context,
// Construction of SYCL platform.
template <typename T, typename detail::enable_if_t<
std::is_same<T, platform>::value> * = nullptr>
T make(typename interop<backend::opencl, T>::type Interop) {
__SYCL_DEPRECATED("Use SYCL 2020 sycl::make_platform free function")
T make(typename detail::interop<backend::opencl, T>::type Interop) {
return make_platform(detail::pi::cast<pi_native_handle>(Interop));
}

// Construction of SYCL device.
template <typename T, typename detail::enable_if_t<
std::is_same<T, device>::value> * = nullptr>
T make(typename interop<backend::opencl, T>::type Interop) {
__SYCL_DEPRECATED("Use SYCL 2020 sycl::make_device free function")
T make(typename detail::interop<backend::opencl, T>::type Interop) {
return make_device(detail::pi::cast<pi_native_handle>(Interop));
}

// Construction of SYCL context.
template <typename T, typename detail::enable_if_t<
std::is_same<T, context>::value> * = nullptr>
T make(typename interop<backend::opencl, T>::type Interop) {
__SYCL_DEPRECATED("Use SYCL 2020 sycl::make_context free function")
T make(typename detail::interop<backend::opencl, T>::type Interop) {
return make_context(detail::pi::cast<pi_native_handle>(Interop));
}

// Construction of SYCL program.
#ifdef __SYCL_INTERNAL_API
template <typename T, typename detail::enable_if_t<
std::is_same<T, program>::value> * = nullptr>
__SYCL_DEPRECATED("Use SYCL 2020 sycl::make_program free function")
T make(const context &Context,
typename interop<backend::opencl, T>::type Interop) {
typename detail::interop<backend::opencl, T>::type Interop) {
return make_program(Context, detail::pi::cast<pi_native_handle>(Interop));
}
#endif

// Construction of SYCL queue.
template <typename T, typename detail::enable_if_t<
std::is_same<T, queue>::value> * = nullptr>
__SYCL_DEPRECATED("Use SYCL 2020 sycl::make_queue free function")
T make(const context &Context,
typename interop<backend::opencl, T>::type Interop) {
typename detail::interop<backend::opencl, T>::type Interop) {
return make_queue(Context, detail::pi::cast<pi_native_handle>(Interop));
}

} // namespace opencl
} // namespace sycl
} // __SYCL_INLINE_NAMESPACE(cl)
20 changes: 10 additions & 10 deletions sycl/include/CL/sycl/backend_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ enum class backend : char {
ext_oneapi_level_zero = 2,
level_zero __SYCL2020_DEPRECATED("use 'ext_oneapi_level_zero' instead") =
ext_oneapi_level_zero,
cuda = 3,
ext_oneapi_cuda = 3,
cuda __SYCL2020_DEPRECATED("use 'ext_oneapi_cuda' instead") = ext_oneapi_cuda,
all = 4,
ext_intel_esimd_emulator = 5,
esimd_cpu __SYCL2020_DEPRECATED("use 'ext_oneapi_esimd_emulator' instead") =
ext_intel_esimd_emulator,
hip = 6,
ext_oneapi_hip = 6,
hip __SYCL2020_DEPRECATED("use 'ext_oneapi_hip' instead") = ext_oneapi_hip,
};

template <backend Backend, typename SYCLObjectT> struct interop;

template <backend Backend> class backend_traits;

template <backend Backend, typename SYCLObjectT>
Expand All @@ -51,17 +51,17 @@ inline std::ostream &operator<<(std::ostream &Out, backend be) {
case backend::opencl:
Out << "opencl";
break;
case backend::level_zero:
Out << "level_zero";
case backend::ext_oneapi_level_zero:
Out << "ext_oneapi_level_zero";
break;
case backend::cuda:
Out << "cuda";
case backend::ext_oneapi_cuda:
Out << "ext_oneapi_cuda";
break;
case backend::ext_intel_esimd_emulator:
Out << "ext_intel_esimd_emulator";
break;
case backend::hip:
Out << "hip";
case backend::ext_oneapi_hip:
Out << "ext_oneapi_hip";
break;
case backend::all:
Out << "all";
Expand Down
9 changes: 5 additions & 4 deletions sycl/include/CL/sycl/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#pragma once

#include <CL/sycl/backend_types.hpp>
#include <CL/sycl/detail/backend_traits.hpp>
#include <CL/sycl/detail/common.hpp>
#include <CL/sycl/detail/export.hpp>
#include <CL/sycl/detail/stl_type_traits.hpp>
Expand Down Expand Up @@ -219,9 +219,10 @@ class __SYCL_EXPORT context {
/// \return a native handle, the type of which defined by the backend.
template <backend BackendName>
__SYCL_DEPRECATED("Use SYCL 2020 sycl::get_native free function")
auto get_native() const -> typename interop<BackendName, context>::type {
return reinterpret_cast<typename interop<BackendName, context>::type>(
getNative());
auto get_native() const ->
typename detail::interop<BackendName, context>::type {
return reinterpret_cast<
typename detail::interop<BackendName, context>::type>(getNative());
}

private:
Expand Down
2 changes: 2 additions & 0 deletions sycl/include/CL/sycl/detail/assert_happened.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include <CL/sycl/detail/defines_elementary.hpp>

#include <cstdint>

#ifdef __SYCL_DEVICE_ONLY__
// Reads Flag of AssertHappened on device
SYCL_EXTERNAL __attribute__((weak)) extern "C" void
Expand Down
7 changes: 7 additions & 0 deletions sycl/include/CL/sycl/detail/backend_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
namespace detail {

template <backend Backend, typename SYCLObjectT> struct interop;

template <backend Backend, typename T> struct BackendInput;

template <backend Backend, typename T> struct BackendReturn;

template <backend Backend> struct InteropFeatureSupportMap {
static constexpr bool MakePlatform = false;
static constexpr bool MakeDevice = false;
Expand Down
Loading