-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL] Add OpenCL interop API following SYCL-2020 backend generalization #1846
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
3 commits
Select commit
Hold shift + click to select a range
bbc2a9c
[SYCL] Add OpenCL interop API following SYCL-2020 backend generalization
smaslov-intel 6604372
[SYCL] use C-cast to allow various possible native handles type (poin…
smaslov-intel 1bb57b2
[SYCL] do not include backend/opencl.hpp from CL/sycl.hpp
smaslov-intel 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
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
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,88 @@ | ||
//==------- opencl.cpp - SYCL OpenCL 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include <CL/sycl.hpp> | ||
#include <detail/platform_impl.hpp> | ||
#include <detail/plugin.hpp> | ||
#include <detail/program_impl.hpp> | ||
#include <detail/queue_impl.hpp> | ||
|
||
__SYCL_INLINE_NAMESPACE(cl) { | ||
namespace sycl { | ||
namespace opencl { | ||
using namespace detail; | ||
|
||
//---------------------------------------------------------------------------- | ||
// Implementation of opencl::make<platform> | ||
__SYCL_EXPORT platform make_platform(pi_native_handle NativeHandle) { | ||
smaslov-intel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const auto &Plugin = pi::getPlugin<backend::opencl>(); | ||
// Create PI platform first. | ||
pi::PiPlatform PiPlatform; | ||
Plugin.call<PiApiKind::piextPlatformCreateWithNativeHandle>(NativeHandle, | ||
&PiPlatform); | ||
|
||
// Construct the SYCL platform from PI platfrom. | ||
return detail::createSyclObjFromImpl<platform>( | ||
std::make_shared<platform_impl>(PiPlatform, Plugin)); | ||
} | ||
|
||
//---------------------------------------------------------------------------- | ||
// Implementation of opencl::make<device> | ||
__SYCL_EXPORT device make_device(pi_native_handle NativeHandle) { | ||
const auto &Plugin = pi::getPlugin<backend::opencl>(); | ||
// Create PI device first. | ||
pi::PiDevice PiDevice; | ||
Plugin.call<PiApiKind::piextDeviceCreateWithNativeHandle>(NativeHandle, | ||
&PiDevice); | ||
// Construct the SYCL device from PI device. | ||
return detail::createSyclObjFromImpl<device>( | ||
std::make_shared<device_impl>(PiDevice, Plugin)); | ||
} | ||
|
||
//---------------------------------------------------------------------------- | ||
// Implementation of opencl::make<context> | ||
__SYCL_EXPORT context make_context(pi_native_handle NativeHandle) { | ||
const auto &Plugin = pi::getPlugin<backend::opencl>(); | ||
// Create PI context first. | ||
pi::PiContext PiContext; | ||
Plugin.call<PiApiKind::piextContextCreateWithNativeHandle>(NativeHandle, | ||
&PiContext); | ||
// Construct the SYCL context from PI context. | ||
return detail::createSyclObjFromImpl<context>( | ||
std::make_shared<context_impl>(PiContext, async_handler{}, Plugin)); | ||
} | ||
|
||
//---------------------------------------------------------------------------- | ||
// Implementation of opencl::make<program> | ||
__SYCL_EXPORT program make_program(const context &Context, | ||
pi_native_handle NativeHandle) { | ||
// Construct the SYCL program from native program. | ||
// TODO: move here the code that creates PI program, and remove the | ||
// native interop constructor. | ||
return detail::createSyclObjFromImpl<program>( | ||
std::make_shared<program_impl>(getSyclObjImpl(Context), NativeHandle)); | ||
} | ||
|
||
//---------------------------------------------------------------------------- | ||
// Implementation of opencl::make<queue> | ||
__SYCL_EXPORT queue make_queue(const context &Context, | ||
pi_native_handle NativeHandle) { | ||
const auto &Plugin = pi::getPlugin<backend::opencl>(); | ||
const auto &ContextImpl = getSyclObjImpl(Context); | ||
// Create PI queue first. | ||
pi::PiQueue PiQueue; | ||
Plugin.call<PiApiKind::piextQueueCreateWithNativeHandle>(NativeHandle, | ||
&PiQueue); | ||
// Construct the SYCL queue from PI queue. | ||
return detail::createSyclObjFromImpl<queue>(std::make_shared<queue_impl>( | ||
PiQueue, ContextImpl, ContextImpl->get_async_handler())); | ||
} | ||
|
||
} // namespace opencl | ||
} // 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
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.