-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL] Implements getNative() interoperability for Level Zero #1723
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
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e7fbf1a
Commit includes:
smaslov-intel 897bbac
Merge remote-tracking branch 'origin/sycl' into rebased_native
againull 11292a9
Minor fixes
againull dfe8030
Rename files
againull 28ba020
Address review comments
againull c7d3fd9
Define CUmodule type
againull d628ef2
Merge remote-tracking branch 'origin/sycl' into native_address
againull 9301a53
Fix piextProgramCreateWithNativeHandle after merge
againull a664a0e
Reuse pi::getPlugin
againull File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
//==--------- level_zero.hpp - SYCL Level-Zero backend ---------------------==// | ||
// | ||
// 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 <CL/sycl.hpp> | ||
#include <level_zero/ze_api.h> | ||
|
||
__SYCL_INLINE_NAMESPACE(cl) { | ||
namespace sycl { | ||
|
||
template <> struct interop<backend::level0, platform> { | ||
using type = ze_driver_handle_t; | ||
}; | ||
|
||
template <> struct interop<backend::level0, device> { | ||
using type = ze_device_handle_t; | ||
}; | ||
|
||
template <> struct interop<backend::level0, queue> { | ||
using type = ze_command_queue_handle_t; | ||
}; | ||
|
||
template <> struct interop<backend::level0, program> { | ||
using type = ze_module_handle_t; | ||
}; | ||
|
||
template <typename DataT, int Dimensions, access::mode AccessMode> | ||
struct interop<backend::level0, accessor<DataT, Dimensions, AccessMode, | ||
access::target::global_buffer, | ||
access::placeholder::false_t>> { | ||
using type = char *; | ||
}; | ||
|
||
namespace level0 { | ||
|
||
// Implementation of various "make" functions resides in libsycl.so | ||
platform make_platform(pi_native_handle NativeHandle); | ||
device make_device(const platform &Platform, pi_native_handle NativeHandle); | ||
program make_program(const context &Context, pi_native_handle NativeHandle); | ||
queue make_queue(const context &Context, pi_native_handle InteropHandle); | ||
|
||
// Construction of SYCL platform. | ||
template <typename T, typename std::enable_if< | ||
std::is_same<T, platform>::value>::type * = nullptr> | ||
T make(typename interop<backend::level0, T>::type Interop) { | ||
return make_platform(reinterpret_cast<pi_native_handle>(Interop)); | ||
} | ||
|
||
// Construction of SYCL device. | ||
template <typename T, typename std::enable_if< | ||
std::is_same<T, device>::value>::type * = nullptr> | ||
T make(const platform &Platform, | ||
typename interop<backend::level0, T>::type Interop) { | ||
return make_device(Platform, reinterpret_cast<pi_native_handle>(Interop)); | ||
} | ||
|
||
// Construction of SYCL program. | ||
template <typename T, typename std::enable_if< | ||
std::is_same<T, program>::value>::type * = nullptr> | ||
T make(const context &Context, | ||
typename interop<backend::level0, T>::type Interop) { | ||
return make_program(Context, reinterpret_cast<pi_native_handle>(Interop)); | ||
} | ||
|
||
// Construction of SYCL queue. | ||
template <typename T, typename std::enable_if< | ||
std::is_same<T, queue>::value>::type * = nullptr> | ||
T make(const context &Context, | ||
typename interop<backend::level0, T>::type Interop) { | ||
return make_queue(Context, reinterpret_cast<pi_native_handle>(Interop)); | ||
} | ||
|
||
} // namespace level0 | ||
} // namespace sycl | ||
} // __SYCL_INLINE_NAMESPACE(cl) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.