-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL][PI][CUDA] Implements get_native interoperability #1332
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
pvchupin
merged 4 commits into
intel:sycl
from
codeplaysoftware:steffen/generalized-get-native
Apr 14, 2020
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
25a76c5
[SYCL][PI][CUDA] Implements get_native interoperability
a884b13
[SYCL][PI][OpenCL] Generalizing interop handler getters
f67949a
[SYCL][PI] Splitting the converter function
9a67949
[SYCL][PI] PI objects created with native handles takes ownership
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//==---------------- backend.hpp - SYCL PI backends ------------------------==// | ||
// | ||
// 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/accessor.hpp> | ||
#include <CL/sycl/backend_types.hpp> | ||
|
||
__SYCL_INLINE_NAMESPACE(cl) { | ||
namespace sycl { | ||
|
||
template <backend BackendName, class SyclObjectT> | ||
auto get_native(const SyclObjectT &Obj) -> | ||
typename interop<BackendName, SyclObjectT>::type { | ||
return Obj.template get_native<BackendName>(); | ||
} | ||
|
||
// Native handle of an accessor should be accessed through interop_handler | ||
template <backend BackendName, typename DataT, int Dimensions, | ||
access::mode AccessMode, access::target AccessTarget, | ||
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; | ||
|
||
} // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
//==---------------- opencl.hpp - 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#pragma once | ||
|
||
#include <CL/cl.h> | ||
#include <CL/sycl/accessor.hpp> | ||
#include <CL/sycl/backend_types.hpp> | ||
|
||
__SYCL_INLINE_NAMESPACE(cl) { | ||
namespace sycl { | ||
|
||
template <> struct interop<backend::opencl, queue> { | ||
using type = cl_command_queue; | ||
steffenlarsen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
template <typename DataT, int Dimensions, access::mode AccessMode> | ||
struct interop<backend::opencl, accessor<DataT, Dimensions, AccessMode, | ||
access::target::global_buffer, | ||
access::placeholder::false_t>> { | ||
using type = cl_mem; | ||
}; | ||
|
||
} // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//==-------------- backend_types.hpp - SYCL backend types ------------------==// | ||
// | ||
// 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 | ||
|
||
namespace cl { | ||
namespace sycl { | ||
|
||
enum class backend { host, opencl, cuda }; | ||
romanovvlad marked this conversation as resolved.
Show resolved
Hide resolved
steffenlarsen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
template <backend name, typename SYCLObjectT> struct interop; | ||
|
||
} // namespace sycl | ||
} // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//==------------ cuda_definitions.hpp - SYCL CUDA 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 | ||
|
||
// CUDA backend specific options | ||
// TODO: Use values that won't overlap with others | ||
|
||
// Mem Object info: Retrieve the raw CUDA pointer from a cl_mem | ||
#define PI_CUDA_RAW_POINTER (0xFF01) | ||
// Context creation: Use a primary CUDA context instead of a custom one by | ||
// providing a property value of PI_TRUE for the following | ||
// property ID. | ||
#define PI_CONTEXT_PROPERTIES_CUDA_PRIMARY (0xFF02) | ||
|
||
// PI Command Queue using Default stream | ||
#define PI_CUDA_USE_DEFAULT_STREAM (0xFF03) | ||
// PI Command queue will sync with default stream | ||
#define PI_CUDA_SYNC_WITH_DEFAULT (0xFF04) |
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.