Skip to content

[SYCL][CUDA] Allow building Host task with CUDA #2010

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
Jun 30, 2020
Merged
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
30 changes: 24 additions & 6 deletions sycl/include/CL/sycl/interop_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class interop_handle {
#else
(void)Acc;
// we believe this won't be ever called on device side
return nullptr;
return 0;
#endif
}

Expand Down Expand Up @@ -89,7 +89,7 @@ class interop_handle {
getNativeQueue());
#else
// we believe this won't be ever called on device side
return nullptr;
return 0;
#endif
}

Expand All @@ -104,7 +104,7 @@ class interop_handle {
getNativeDevice());
#else
// we believe this won't be ever called on device side
return nullptr;
return 0;
#endif
}

Expand All @@ -119,7 +119,7 @@ class interop_handle {
getNativeContext());
#else
// we believe this won't be ever called on device side
return nullptr;
return 0;
#endif
}

Expand All @@ -142,8 +142,26 @@ class interop_handle {
auto getMemImpl(detail::Requirement *Req) const ->
typename interop<BackendName,
accessor<DataT, Dims, Mode, Target, IsPlh>>::type {
return reinterpret_cast<typename interop<
BackendName, accessor<DataT, Dims, Mode, Target, IsPlh>>::type>(
/*
Do not update this cast: a C-style cast is required here.

This function tries to cast pi_native_handle to the native handle type.
pi_native_handle is a typedef of uintptr_t. It is used to store opaque
pointers, such as cl_device, and integer handles, such as CUdevice. To
convert a uintptr_t to a pointer type, such as cl_device, reinterpret_cast
must be used. However, reinterpret_cast cannot be used to convert
uintptr_t to a different integer type, such as CUdevice. For this,
static_cast must be used. This function must employ a cast that is capable
of reinterpret_cast and static_cast depending on the arguments passed to
it. A C-style cast will achieve this. The compiler will attempt to
interpret it as a static_cast, and will fall back to reinterpret_cast
where appropriate.

https://en.cppreference.com/w/cpp/language/reinterpret_cast
https://en.cppreference.com/w/cpp/language/explicit_cast
*/
return (typename interop<BackendName,
accessor<DataT, Dims, Mode, Target, IsPlh>>::type)(
getNativeMem(Req));
}

Expand Down