Skip to content
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

[SYCL][Graph] Support for read and write for 1d and 2d buffers #238

Merged
merged 1 commit into from
Jun 27, 2023
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
4 changes: 4 additions & 0 deletions sycl/include/sycl/detail/pi.def
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ _PI_API(piextCommandBufferNDRangeKernel)
_PI_API(piextCommandBufferMemcpyUSM)
_PI_API(piextCommandBufferMemBufferCopy)
_PI_API(piextCommandBufferMemBufferCopyRect)
_PI_API(piextCommandBufferMemBufferWrite)
_PI_API(piextCommandBufferMemBufferWriteRect)
_PI_API(piextCommandBufferMemBufferRead)
_PI_API(piextCommandBufferMemBufferReadRect)
EwanC marked this conversation as resolved.
Show resolved Hide resolved
_PI_API(piextEnqueueCommandBuffer)
_PI_API(piPluginGetLastError)

Expand Down
84 changes: 84 additions & 0 deletions sycl/include/sycl/detail/pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -2225,6 +2225,90 @@ __SYCL_EXPORT pi_result piextCommandBufferMemBufferCopyRect(
const pi_ext_sync_point *sync_point_wait_list,
pi_ext_sync_point *sync_point);

/// API to append a mem buffer read command to the command-buffer.
/// \param command_buffer The command-buffer to append onto.
/// \param buffer is the data to be read
/// \param offset offset into \p buffer
/// \param size is number of bytes to read
/// \param dst is the pointer to the destination
/// \param num_sync_points_in_wait_list The number of sync points in the
/// provided wait list.
/// \param sync_point_wait_list A list of sync points that this command must
/// wait on.
/// \param sync_point The sync_point associated with this memory operation.
__SYCL_EXPORT pi_result piextCommandBufferMemBufferRead(
pi_ext_command_buffer command_buffer, pi_mem buffer, size_t offset,
size_t size, void *dst, pi_uint32 num_sync_points_in_wait_list,
const pi_ext_sync_point *sync_point_wait_list,
pi_ext_sync_point *sync_point);

/// API to append a rectangular mem buffer read command to the command-buffer.
/// \param command_buffer The command-buffer to append onto.
/// \param buffer is the data to be read
/// \param buffer_offset offset for the start of the region to read in buffer
/// \param host_offset offset for the start of the region to be written from ptr
/// \param region The size of the region to read
/// \param buffer_row_pitch Row pitch for the source buffer data
/// \param buffer_slice_pitch Slice pitch for the source buffer data
/// \param host_row_pitch Row pitch for the destination data ptr
/// \param host_slice_pitch Slice pitch for the destination data ptr
/// \param ptr is the location the data will be written
/// \param num_sync_points_in_wait_list The number of sync points in the
/// provided wait list.
/// \param sync_point_wait_list A list of sync points that this command must
/// wait on.
/// \param sync_point The sync_point associated with this memory operation.
__SYCL_EXPORT pi_result piextCommandBufferMemBufferReadRect(
pi_ext_command_buffer command_buffer, pi_mem buffer,
pi_buff_rect_offset buffer_offset, pi_buff_rect_offset host_offset,
pi_buff_rect_region region, size_t buffer_row_pitch,
size_t buffer_slice_pitch, size_t host_row_pitch, size_t host_slice_pitch,
void *ptr, pi_uint32 num_events_in_wait_list,
const pi_ext_sync_point *sync_point_wait_list,
pi_ext_sync_point *sync_point);

/// API to append a mem buffer write command to the command-buffer.
/// \param command_buffer The command-buffer to append onto.
/// \param buffer is the location to write the data
/// \param offset offset into \p buffer
/// \param size is number of bytes to write
/// \param ptr is the pointer to the source
/// \param num_sync_points_in_wait_list The number of sync points in the
/// provided wait list.
/// \param sync_point_wait_list A list of sync points that this command must
/// wait on.
/// \param sync_point The sync_point associated with this memory operation.
__SYCL_EXPORT pi_result piextCommandBufferMemBufferWrite(
pi_ext_command_buffer command_buffer, pi_mem buffer, size_t offset,
size_t size, const void *ptr, pi_uint32 num_events_in_wait_list,
const pi_ext_sync_point *sync_point_wait_list,
pi_ext_sync_point *sync_point);

/// API to append a rectangular mem buffer write command to the command-buffer.
/// \param command_buffer The command-buffer to append onto.
/// \param buffer is the location to write the data
/// \param buffer_offset offset for the start of the region to write in buffer
/// \param host_offset offset for the start of the region to be read from ptr
/// \param region The size of the region to write
/// \param buffer_row_pitch Row pitch for the buffer data
/// \param buffer_slice_pitch Slice pitch for the buffer data
/// \param host_row_pitch Row pitch for the source data ptr
/// \param host_slice_pitch Slice pitch for the source data ptr
/// \param ptr is the pointer to the source
/// \param num_sync_points_in_wait_list The number of sync points in the
/// provided wait list.
/// \param sync_point_wait_list A list of sync points that this command must
/// wait on.
/// \param sync_point The sync_point associated with this memory operation.
__SYCL_EXPORT pi_result piextCommandBufferMemBufferWriteRect(
pi_ext_command_buffer command_buffer, pi_mem buffer,
pi_buff_rect_offset buffer_offset, pi_buff_rect_offset host_offset,
pi_buff_rect_region region, size_t buffer_row_pitch,
size_t buffer_slice_pitch, size_t host_row_pitch, size_t host_slice_pitch,
const void *ptr, pi_uint32 num_events_in_wait_list,
const pi_ext_sync_point *sync_point_wait_list,
pi_ext_sync_point *sync_point);

/// API to submit the command-buffer to queue for execution, returns an error if
/// command-buffer not finalized or another instance of same command-buffer
/// currently executing.
Expand Down
34 changes: 34 additions & 0 deletions sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2154,6 +2154,40 @@ pi_result piextCommandBufferMemBufferCopyRect(
DIE_NO_IMPLEMENTATION;
}

pi_result piextCommandBufferMemBufferRead(
pi_ext_command_buffer command_buffer, pi_mem buffer, size_t offset,
size_t size, void *dst, pi_uint32 num_sync_points_in_wait_list,
const pi_ext_sync_point *sync_point_wait_list, pi_ext_sync_point *sync_point) {
DIE_NO_IMPLEMENTATION;
}

pi_result piextCommandBufferMemBufferReadRect(
pi_ext_command_buffer command_buffer, pi_mem buffer,
pi_buff_rect_offset buffer_offset, pi_buff_rect_offset host_offset,
pi_buff_rect_region region, size_t buffer_row_pitch, size_t buffer_slice_pitch,
size_t host_row_pitch, size_t host_slice_pitch, void *ptr,
pi_uint32 num_sync_points_in_wait_list, const pi_ext_sync_point *sync_point_wait_list,
pi_ext_sync_point *sync_point) {
DIE_NO_IMPLEMENTATION;
}

pi_result piextCommandBufferMemBufferWrite(
pi_ext_command_buffer command_buffer, pi_mem buffer, size_t offset,
size_t size, const void *ptr, pi_uint32 num_sync_points_in_wait_list,
const pi_ext_sync_point *sync_point_wait_list, pi_ext_sync_point *sync_point) {
DIE_NO_IMPLEMENTATION;
}

pi_result piextCommandBufferMemBufferWriteRect(
pi_ext_command_buffer command_buffer, pi_mem buffer,
pi_buff_rect_offset buffer_offset, pi_buff_rect_offset host_offset,
pi_buff_rect_region region, size_t buffer_row_pitch, size_t buffer_slice_pitch,
size_t host_row_pitch, size_t host_slice_pitch, const void *ptr,
pi_uint32 num_sync_points_in_wait_list, const pi_ext_sync_point *sync_point_wait_list,
pi_ext_sync_point *sync_point) {
DIE_NO_IMPLEMENTATION;
}

pi_result piextEnqueueCommandBuffer(pi_ext_command_buffer command_buffer,
pi_queue queue,
pi_uint32 num_events_in_wait_list,
Expand Down
44 changes: 44 additions & 0 deletions sycl/plugins/hip/pi_hip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5640,6 +5640,44 @@ pi_result hip_piextCommandBufferMemBufferCopyRect(
return {};
}

pi_result hip_piextCommandBufferMemBufferRead(
pi_ext_command_buffer command_buffer, pi_mem buffer, size_t offset,
size_t size, void *dst, pi_uint32 num_sync_points_in_wait_list,
const pi_ext_sync_point *sync_point_wait_list, pi_ext_sync_point *sync_point) {
sycl::detail::pi::die("command-buffer API not implemented in HIP backend");
return {};
}

pi_result hip_piextCommandBufferMemBufferReadRect(
pi_ext_command_buffer command_buffer, pi_mem buffer,
pi_buff_rect_offset buffer_offset, pi_buff_rect_offset host_offset,
pi_buff_rect_region region, size_t buffer_row_pitch, size_t buffer_slice_pitch,
size_t host_row_pitch, size_t host_slice_pitch, void *ptr,
pi_uint32 num_sync_points_in_wait_list, const pi_ext_sync_point *sync_point_wait_list,
pi_ext_sync_point *sync_point) {
sycl::detail::pi::die("command-buffer API not implemented in HIP backend");
return {};
}

pi_result hip_piextCommandBufferMemBufferWrite(
pi_ext_command_buffer command_buffer, pi_mem buffer, size_t offset,
size_t size, const void *ptr, pi_uint32 num_sync_points_in_wait_list,
const pi_ext_sync_point *sync_point_wait_list, pi_ext_sync_point *sync_point) {
sycl::detail::pi::die("command-buffer API not implemented in HIP backend");
return {};
}

pi_result hip_piextCommandBufferMemBufferWriteRect(
pi_ext_command_buffer command_buffer, pi_mem buffer,
pi_buff_rect_offset buffer_offset, pi_buff_rect_offset host_offset,
pi_buff_rect_region region, size_t buffer_row_pitch, size_t buffer_slice_pitch,
size_t host_row_pitch, size_t host_slice_pitch, const void *ptr,
pi_uint32 num_sync_points_in_wait_list, const pi_ext_sync_point *sync_point_wait_list,
pi_ext_sync_point *sync_point) {
sycl::detail::pi::die("command-buffer API not implemented in HIP backend");
return {};
}

pi_result hip_piextEnqueueCommandBuffer(pi_ext_command_buffer command_buffer,
pi_queue queue,
pi_uint32 num_events_in_wait_list,
Expand Down Expand Up @@ -5848,6 +5886,12 @@ pi_result piPluginInit(pi_plugin *PluginInit) {
_PI_CL(piextCommandBufferMemBufferCopy, hip_piextCommandBufferMemBufferCopy)
_PI_CL(piextCommandBufferMemBufferCopyRect,
hip_piextCommandBufferMemBufferCopyRect)
_PI_CL(piextCommandBufferMemBufferRead, hip_piextCommandBufferMemBufferRead)
_PI_CL(piextCommandBufferMemBufferReadRect,
hip_piextCommandBufferMemBufferReadRect)
_PI_CL(piextCommandBufferMemBufferWrite, hip_piextCommandBufferMemBufferWrite)
_PI_CL(piextCommandBufferMemBufferWriteRect,
hip_piextCommandBufferMemBufferWriteRect)
_PI_CL(piextEnqueueCommandBuffer, hip_piextEnqueueCommandBuffer)

_PI_CL(piextKernelSetArgMemObj, hip_piextKernelSetArgMemObj)
Expand Down
44 changes: 44 additions & 0 deletions sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,50 @@ pi_result piextCommandBufferMemBufferCopyRect(
SyncPointWaitList, SyncPoint);
}

pi_result piextCommandBufferMemBufferRead(
pi_ext_command_buffer CommandBuffer, pi_mem Buffer, size_t Offset,
size_t Size, void *Dst, pi_uint32 NumSyncPointsInWaitList,
const pi_ext_sync_point *SyncPointWaitList, pi_ext_sync_point *SyncPoint) {
return pi2ur::piextCommandBufferMemBufferRead(CommandBuffer, Buffer, Offset,
Size, Dst, NumSyncPointsInWaitList,
SyncPointWaitList, SyncPoint);
}

pi_result piextCommandBufferMemBufferReadRect(
pi_ext_command_buffer CommandBuffer, pi_mem Buffer,
pi_buff_rect_offset BufferOffset, pi_buff_rect_offset HostOffset,
pi_buff_rect_region Region, size_t BufferRowPitch, size_t BufferSlicePitch,
size_t HostRowPitch, size_t HostSlicePitch, void *Ptr,
pi_uint32 NumSyncPointsInWaitList, const pi_ext_sync_point *SyncPointWaitList,
pi_ext_sync_point *SyncPoint) {
return pi2ur::piextCommandBufferMemBufferReadRect(
CommandBuffer, Buffer, BufferOffset, HostOffset, Region, BufferRowPitch,
BufferSlicePitch, HostRowPitch, HostSlicePitch, Ptr, NumSyncPointsInWaitList,
SyncPointWaitList, SyncPoint);
}

pi_result piextCommandBufferMemBufferWrite(
pi_ext_command_buffer CommandBuffer, pi_mem Buffer, size_t Offset,
size_t Size, const void *Ptr, pi_uint32 NumSyncPointsInWaitList,
const pi_ext_sync_point *SyncPointWaitList, pi_ext_sync_point *SyncPoint) {
return pi2ur::piextCommandBufferMemBufferWrite(CommandBuffer, Buffer, Offset,
Size, Ptr, NumSyncPointsInWaitList,
SyncPointWaitList, SyncPoint);
}

pi_result piextCommandBufferMemBufferWriteRect(
pi_ext_command_buffer CommandBuffer, pi_mem Buffer,
pi_buff_rect_offset BufferOffset, pi_buff_rect_offset HostOffset,
pi_buff_rect_region Region, size_t BufferRowPitch, size_t BufferSlicePitch,
size_t HostRowPitch, size_t HostSlicePitch, const void *Ptr,
pi_uint32 NumSyncPointsInWaitList, const pi_ext_sync_point *SyncPointWaitList,
pi_ext_sync_point *SyncPoint) {
return pi2ur::piextCommandBufferMemBufferWriteRect(
CommandBuffer, Buffer, BufferOffset, HostOffset, Region, BufferRowPitch,
BufferSlicePitch, HostRowPitch, HostSlicePitch, Ptr, NumSyncPointsInWaitList,
SyncPointWaitList, SyncPoint);
}

pi_result piextEnqueueCommandBuffer(pi_ext_command_buffer CommandBuffer,
pi_queue Queue,
pi_uint32 NumEventsInWaitList,
Expand Down
44 changes: 44 additions & 0 deletions sycl/plugins/opencl/pi_opencl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2343,6 +2343,44 @@ pi_result piextCommandBufferMemBufferCopyRect(
return {};
}

pi_result piextCommandBufferMemBufferRead(
pi_ext_command_buffer command_buffer, pi_mem buffer, size_t offset,
size_t size, void *dst, pi_uint32 num_sync_points_in_wait_list,
const pi_ext_sync_point *sync_point_wait_list, pi_ext_sync_point *sync_point) {
// Not implemented
return {};
}

pi_result piextCommandBufferMemBufferReadRect(
pi_ext_command_buffer command_buffer, pi_mem buffer,
pi_buff_rect_offset buffer_offset, pi_buff_rect_offset host_offset,
pi_buff_rect_region region, size_t buffer_row_pitch, size_t buffer_slice_pitch,
size_t host_row_pitch, size_t host_slice_pitch, void *ptr,
pi_uint32 num_sync_points_in_wait_list, const pi_ext_sync_point *sync_point_wait_list,
pi_ext_sync_point *sync_point) {
// Not implemented
return {};
}

pi_result piextCommandBufferMemBufferWrite(
pi_ext_command_buffer command_buffer, pi_mem buffer, size_t offset,
size_t size, const void *ptr, pi_uint32 num_sync_points_in_wait_list,
const pi_ext_sync_point *sync_point_wait_list, pi_ext_sync_point *sync_point) {
// Not implemented
return {};
}

pi_result piextCommandBufferMemBufferWriteRect(
pi_ext_command_buffer command_buffer, pi_mem buffer,
pi_buff_rect_offset buffer_offset, pi_buff_rect_offset host_offset,
pi_buff_rect_region region, size_t buffer_row_pitch, size_t buffer_slice_pitch,
size_t host_row_pitch, size_t host_slice_pitch, const void *ptr,
pi_uint32 num_sync_points_in_wait_list, const pi_ext_sync_point *sync_point_wait_list,
pi_ext_sync_point *sync_point) {
// Not implemented
return {};
}

pi_result piextEnqueueCommandBuffer(pi_ext_command_buffer command_buffer,
pi_queue queue,
pi_uint32 num_events_in_wait_list,
Expand Down Expand Up @@ -2556,6 +2594,12 @@ pi_result piPluginInit(pi_plugin *PluginInit) {
_PI_CL(piextCommandBufferMemBufferCopy, piextCommandBufferMemBufferCopy)
_PI_CL(piextCommandBufferMemBufferCopyRect,
piextCommandBufferMemBufferCopyRect)
_PI_CL(piextCommandBufferMemBufferRead, piextCommandBufferMemBufferRead)
_PI_CL(piextCommandBufferMemBufferReadRect,
piextCommandBufferMemBufferReadRect)
_PI_CL(piextCommandBufferMemBufferWrite, piextCommandBufferMemBufferWrite)
_PI_CL(piextCommandBufferMemBufferWriteRect,
piextCommandBufferMemBufferWriteRect)
_PI_CL(piextEnqueueCommandBuffer, piextEnqueueCommandBuffer)

_PI_CL(piextKernelSetArgMemObj, piextKernelSetArgMemObj)
Expand Down
2 changes: 1 addition & 1 deletion sycl/plugins/unified_runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if (NOT DEFINED UNIFIED_RUNTIME_LIBRARY OR NOT DEFINED UNIFIED_RUNTIME_INCLUDE_D
include(FetchContent)

set(UNIFIED_RUNTIME_REPO "https://github.com/bensuo/unified-runtime.git")
set(UNIFIED_RUNTIME_TAG f055b00e70eeaabb5532c1c48dc3c769df6bef57)
set(UNIFIED_RUNTIME_TAG 933d9cad4be0c339a8e583fc54debe6f5a0472e8)

message(STATUS "Will fetch Unified Runtime from ${UNIFIED_RUNTIME_REPO}")
FetchContent_Declare(unified-runtime
Expand Down
Loading