Skip to content

[SYCL] Add SYCL-2020 interop_handle::get_backend() method #3664

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 1 commit into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 6 additions & 2 deletions sycl/include/CL/sycl/interop_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ class context;

class interop_handle {
public:
interop_handle() = delete;

/// Returns a backend associated with the queue associated with this
/// interop_handle.
__SYCL_EXPORT backend get_backend() const noexcept;

/// Receives a SYCL accessor that has been defined as a requirement for the
/// command group, and returns the underlying OpenCL memory object that is
/// used by the SYCL runtime. If the accessor passed as parameter is not part
Expand Down Expand Up @@ -131,15 +137,13 @@ class interop_handle {
friend class detail::DispatchHostTask;
using ReqToMem = std::pair<detail::Requirement *, pi_mem>;

// TODO set c-tor private
interop_handle(std::vector<ReqToMem> MemObjs,
const std::shared_ptr<detail::queue_impl> &Queue,
const std::shared_ptr<detail::device_impl> &Device,
const std::shared_ptr<detail::context_impl> &Context)
: MQueue(Queue), MDevice(Device), MContext(Context),
MMemObjs(std::move(MemObjs)) {}

private:
template <backend BackendName, typename DataT, int Dims, access::mode Mode,
access::target Target, access::placeholder IsPlh>
auto getMemImpl(detail::Requirement *Req) const ->
Expand Down
5 changes: 5 additions & 0 deletions sycl/source/interop_handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <CL/sycl/detail/accessor_impl.hpp>
#include <CL/sycl/exception.hpp>
#include <CL/sycl/interop_handle.hpp>
#include <detail/backend_impl.hpp>
#include <detail/context_impl.hpp>
#include <detail/device_impl.hpp>
#include <detail/queue_impl.hpp>
Expand All @@ -18,6 +19,10 @@
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {

backend interop_handle::get_backend() const noexcept {
return detail::getImplBackend(MQueue);
}

pi_native_handle interop_handle::getNativeMem(detail::Requirement *Req) const {
auto Iter = std::find_if(std::begin(MMemObjs), std::end(MMemObjs),
[=](ReqToMem Elem) { return (Elem.first == Req); });
Expand Down
1 change: 1 addition & 0 deletions sycl/test/abi/sycl_symbols_linux.dump
Original file line number Diff line number Diff line change
Expand Up @@ -3908,6 +3908,7 @@ _ZNK2cl4sycl13host_selectorclERKNS0_6deviceE
_ZNK2cl4sycl14exception_list3endEv
_ZNK2cl4sycl14exception_list4sizeEv
_ZNK2cl4sycl14exception_list5beginEv
_ZNK2cl4sycl14interop_handle11get_backendEv
_ZNK2cl4sycl14interop_handle12getNativeMemEPNS0_6detail16AccessorImplHostE
_ZNK2cl4sycl14interop_handle14getNativeQueueEv
_ZNK2cl4sycl14interop_handle15getNativeDeviceEv
Expand Down