Skip to content

Commit

Permalink
rough impl for perf testing.
Browse files Browse the repository at this point in the history
Signed-off-by: JackAKirk <jack.kirk@codeplay.com>
  • Loading branch information
JackAKirk committed Oct 24, 2022
1 parent 20b1bea commit 3b36bc4
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sycl/include/sycl/detail/pi.def
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,7 @@ _PI_API(piPluginGetLastError)

_PI_API(piTearDown)

_PI_API(piextEnablePeer)


#undef _PI_API
2 changes: 2 additions & 0 deletions sycl/include/sycl/detail/pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,8 @@ __SYCL_EXPORT pi_result piDevicesGet(pi_platform platform,
pi_uint32 num_entries, pi_device *devices,
pi_uint32 *num_devices);

__SYCL_EXPORT pi_result piextEnablePeer(pi_queue command_queue, pi_queue peer_queue);

/// Returns requested info for provided native device
/// Return PI_DEVICE_INFO_EXTENSION_DEVICELIB_ASSERT for
/// PI_DEVICE_INFO_EXTENSIONS query when the device supports native asserts
Expand Down
12 changes: 12 additions & 0 deletions sycl/include/sycl/queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ class queue;
template <backend BackendName, class SyclObjectT>
auto get_native(const SyclObjectT &Obj)
-> backend_return_t<BackendName, SyclObjectT>;
namespace ext {
namespace oneapi {
namespace experimental {

bool __SYCL_EXPORT ext_oneapi_enable_peer_access(const queue &active, const queue &peer);

} // namespace experimental
} // namespace oneapi
} // namespace ext

namespace detail {
class queue_impl;
Expand All @@ -85,6 +94,9 @@ static event submitAssertCapture(queue &, event &, queue *,
/// \ingroup sycl_api
class __SYCL_EXPORT queue {
public:

friend bool ext::oneapi::experimental::ext_oneapi_enable_peer_access(const queue &active, const queue &peer);

/// Constructs a SYCL queue instance using the device returned by an instance
/// of default_selector.
///
Expand Down
14 changes: 14 additions & 0 deletions sycl/plugins/cuda/pi_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5258,6 +5258,19 @@ pi_result cuda_piextUSMEnqueueMemAdvise(pi_queue queue, const void *ptr,
return result;
}

pi_result cuda_piextEnablePeer(pi_queue command_queue, pi_queue peer_queue){

pi_result result = PI_SUCCESS;
try {
ScopedContext active(command_queue->get_context());
result = PI_CHECK_ERROR(cuCtxEnablePeerAccess(peer_queue->get_context()->get(), 0));

} catch (pi_result err) {
result = err;
}
return result;
}

/// API to query information about USM allocated pointers
/// Valid Queries:
/// PI_MEM_ALLOC_TYPE returns host/device/shared pi_host_usm value
Expand Down Expand Up @@ -5524,6 +5537,7 @@ pi_result piPluginInit(pi_plugin *PluginInit) {
_PI_CL(piextKernelSetArgSampler, cuda_piextKernelSetArgSampler)
_PI_CL(piPluginGetLastError, cuda_piPluginGetLastError)
_PI_CL(piTearDown, cuda_piTearDown)
_PI_CL(piextEnablePeer, cuda_piextEnablePeer)

#undef _PI_CL

Expand Down
7 changes: 7 additions & 0 deletions sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8489,6 +8489,13 @@ pi_result piextUSMEnqueueMemAdvise(pi_queue Queue, const void *Ptr,
return PI_SUCCESS;
}

pi_result piextEnablePeer(pi_queue command_queue, pi_queue peer_queue){

pi_result result = PI_SUCCESS;

return result;
}

/// API to query information about USM allocated pointers.
/// Valid Queries:
/// PI_MEM_ALLOC_TYPE returns host/device/shared pi_usm_type value
Expand Down
16 changes: 16 additions & 0 deletions sycl/source/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@
namespace sycl {
__SYCL_INLINE_VER_NAMESPACE(_V1) {

namespace ext {
namespace oneapi {
namespace experimental {

bool __SYCL_EXPORT ext_oneapi_enable_peer_access(const queue &active, const queue &peer) {
const RT::PiQueue Queue = active.impl->getHandleRef();
const detail::plugin &Plugin = active.impl->getPlugin();
const RT::PiQueue PeerPi = peer.impl->getHandleRef();
Plugin.call<detail::PiApiKind::piextEnablePeer>(Queue, PeerPi );
return true;
}

} // namespace experimental
} // namespace oneapi
} // namespace ext

queue::queue(const context &SyclContext, const device_selector &DeviceSelector,
const async_handler &AsyncHandler, const property_list &PropList) {

Expand Down

0 comments on commit 3b36bc4

Please sign in to comment.