Skip to content

Commit

Permalink
Merge pull request #2684 from Xewar313/add-mem-buffer-operations
Browse files Browse the repository at this point in the history
Add mem buffer operations to command buffer v2
  • Loading branch information
pbalcer authored Feb 12, 2025
2 parents d2ad898 + 3d71b0f commit 3ce6fcc
Show file tree
Hide file tree
Showing 6 changed files with 485 additions and 250 deletions.
77 changes: 0 additions & 77 deletions source/adapters/level_zero/v2/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,83 +251,6 @@ ur_result_t urCommandBufferAppendUSMFillExp(
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

ur_result_t urCommandBufferAppendMemBufferCopyExp(
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hSrcMem,
ur_mem_handle_t hDstMem, size_t srcOffset, size_t dstOffset, size_t size,
uint32_t numSyncPointsInWaitList,
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
uint32_t NumEventsInWaitList, const ur_event_handle_t *phEventWaitList,
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
ur_exp_command_buffer_command_handle_t *phCommand) {
logger::error("{} function not implemented!", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

ur_result_t urCommandBufferAppendMemBufferWriteExp(
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hBuffer,
size_t offset, size_t size, const void *pSrc,
uint32_t numSyncPointsInWaitList,
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
uint32_t NumEventsInWaitList, const ur_event_handle_t *phEventWaitList,
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
ur_exp_command_buffer_command_handle_t *phCommand) {
logger::error("{} function not implemented!", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

ur_result_t urCommandBufferAppendMemBufferReadExp(
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hBuffer,
size_t offset, size_t size, void *pDst, uint32_t numSyncPointsInWaitList,
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
uint32_t NumEventsInWaitList, const ur_event_handle_t *phEventWaitList,
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
ur_exp_command_buffer_command_handle_t *phCommand) {
logger::error("{} function not implemented!", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

ur_result_t urCommandBufferAppendMemBufferCopyRectExp(
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hSrcMem,
ur_mem_handle_t hDstMem, ur_rect_offset_t srcOrigin,
ur_rect_offset_t dstOrigin, ur_rect_region_t region, size_t srcRowPitch,
size_t srcSlicePitch, size_t dstRowPitch, size_t dstSlicePitch,
uint32_t numSyncPointsInWaitList,
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
uint32_t NumEventsInWaitList, const ur_event_handle_t *phEventWaitList,
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
ur_exp_command_buffer_command_handle_t *phCommand) {
logger::error("{} function not implemented!", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

ur_result_t urCommandBufferAppendMemBufferWriteRectExp(
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hBuffer,
ur_rect_offset_t bufferOffset, ur_rect_offset_t hostOffset,
ur_rect_region_t region, size_t bufferRowPitch, size_t bufferSlicePitch,
size_t hostRowPitch, size_t hostSlicePitch, void *pSrc,
uint32_t numSyncPointsInWaitList,
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
uint32_t NumEventsInWaitList, const ur_event_handle_t *phEventWaitList,
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
ur_exp_command_buffer_command_handle_t *phCommand) {
logger::error("{} function not implemented!", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

ur_result_t urCommandBufferAppendMemBufferReadRectExp(
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hBuffer,
ur_rect_offset_t bufferOffset, ur_rect_offset_t hostOffset,
ur_rect_region_t region, size_t bufferRowPitch, size_t bufferSlicePitch,
size_t hostRowPitch, size_t hostSlicePitch, void *pDst,
uint32_t numSyncPointsInWaitList,
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
uint32_t NumEventsInWaitList, const ur_event_handle_t *phEventWaitList,
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
ur_exp_command_buffer_command_handle_t *phCommand) {
logger::error("{} function not implemented!", __FUNCTION__);
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

ur_result_t urCommandBufferAppendMemBufferFillExp(
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hBuffer,
const void *pPattern, size_t patternSize, size_t offset, size_t size,
Expand Down
181 changes: 181 additions & 0 deletions source/adapters/level_zero/v2/command_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,187 @@ ur_result_t urCommandBufferAppendUSMMemcpyExp(
return exceptionToResult(std::current_exception());
}

ur_result_t urCommandBufferAppendMemBufferCopyExp(
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hSrcMem,
ur_mem_handle_t hDstMem, size_t srcOffset, size_t dstOffset, size_t size,
uint32_t numSyncPointsInWaitList,
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList,
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
ur_exp_command_buffer_command_handle_t *phCommand) try {

// the same issue as in urCommandBufferAppendKernelLaunchExp
std::ignore = numEventsInWaitList;
std::ignore = phEventWaitList;
std::ignore = phEvent;
// sync mechanic can be ignored, because all lists are in-order
std::ignore = numSyncPointsInWaitList;
std::ignore = pSyncPointWaitList;
std::ignore = pSyncPoint;

std::ignore = phCommand;
// Responsibility of UMD to offload to copy engine
UR_CALL(hCommandBuffer->commandListManager.appendMemBufferCopy(
hSrcMem, hDstMem, srcOffset, dstOffset, size, 0, nullptr, nullptr));

return UR_RESULT_SUCCESS;
} catch (...) {
return exceptionToResult(std::current_exception());
}

ur_result_t urCommandBufferAppendMemBufferWriteExp(
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hBuffer,
size_t offset, size_t size, const void *pSrc,
uint32_t numSyncPointsInWaitList,
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList,
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
ur_exp_command_buffer_command_handle_t *phCommand) try {

// the same issue as in urCommandBufferAppendKernelLaunchExp
std::ignore = numEventsInWaitList;
std::ignore = phEventWaitList;
std::ignore = phEvent;
// sync mechanic can be ignored, because all lists are in-order
std::ignore = numSyncPointsInWaitList;
std::ignore = pSyncPointWaitList;
std::ignore = pSyncPoint;

std::ignore = phCommand;
// Responsibility of UMD to offload to copy engine
UR_CALL(hCommandBuffer->commandListManager.appendMemBufferWrite(
hBuffer, false, offset, size, pSrc, 0, nullptr, nullptr));

return UR_RESULT_SUCCESS;
} catch (...) {
return exceptionToResult(std::current_exception());
}

ur_result_t urCommandBufferAppendMemBufferReadExp(
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hBuffer,
size_t offset, size_t size, void *pDst, uint32_t numSyncPointsInWaitList,
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList,
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
ur_exp_command_buffer_command_handle_t *phCommand) try {

// the same issue as in urCommandBufferAppendKernelLaunchExp
std::ignore = numEventsInWaitList;
std::ignore = phEventWaitList;
std::ignore = phEvent;
// sync mechanic can be ignored, because all lists are in-order
std::ignore = numSyncPointsInWaitList;
std::ignore = pSyncPointWaitList;
std::ignore = pSyncPoint;

std::ignore = phCommand;

// Responsibility of UMD to offload to copy engine
UR_CALL(hCommandBuffer->commandListManager.appendMemBufferRead(
hBuffer, false, offset, size, pDst, 0, nullptr, nullptr));

return UR_RESULT_SUCCESS;
} catch (...) {
return exceptionToResult(std::current_exception());
}

ur_result_t urCommandBufferAppendMemBufferCopyRectExp(
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hSrcMem,
ur_mem_handle_t hDstMem, ur_rect_offset_t srcOrigin,
ur_rect_offset_t dstOrigin, ur_rect_region_t region, size_t srcRowPitch,
size_t srcSlicePitch, size_t dstRowPitch, size_t dstSlicePitch,
uint32_t numSyncPointsInWaitList,
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList,
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
ur_exp_command_buffer_command_handle_t *phCommand) try {

// the same issue as in urCommandBufferAppendKernelLaunchExp
std::ignore = numEventsInWaitList;
std::ignore = phEventWaitList;
std::ignore = phEvent;
// sync mechanic can be ignored, because all lists are in-order
std::ignore = numSyncPointsInWaitList;
std::ignore = pSyncPointWaitList;
std::ignore = pSyncPoint;

std::ignore = phCommand;
// Responsibility of UMD to offload to copy engine
UR_CALL(hCommandBuffer->commandListManager.appendMemBufferCopyRect(
hSrcMem, hDstMem, srcOrigin, dstOrigin, region, srcRowPitch,
srcSlicePitch, dstRowPitch, dstSlicePitch, 0, nullptr, nullptr));

return UR_RESULT_SUCCESS;
} catch (...) {
return exceptionToResult(std::current_exception());
}

ur_result_t urCommandBufferAppendMemBufferWriteRectExp(
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hBuffer,
ur_rect_offset_t bufferOffset, ur_rect_offset_t hostOffset,
ur_rect_region_t region, size_t bufferRowPitch, size_t bufferSlicePitch,
size_t hostRowPitch, size_t hostSlicePitch, void *pSrc,
uint32_t numSyncPointsInWaitList,
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList,
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
ur_exp_command_buffer_command_handle_t *phCommand) try {

// the same issue as in urCommandBufferAppendKernelLaunchExp
std::ignore = numEventsInWaitList;
std::ignore = phEventWaitList;
std::ignore = phEvent;
// sync mechanic can be ignored, because all lists are in-order
std::ignore = numSyncPointsInWaitList;
std::ignore = pSyncPointWaitList;
std::ignore = pSyncPoint;

std::ignore = phCommand;

// Responsibility of UMD to offload to copy engine
UR_CALL(hCommandBuffer->commandListManager.appendMemBufferWriteRect(
hBuffer, false, bufferOffset, hostOffset, region, bufferRowPitch,
bufferSlicePitch, hostRowPitch, hostSlicePitch, pSrc, 0, nullptr,
nullptr));

return UR_RESULT_SUCCESS;
} catch (...) {
return exceptionToResult(std::current_exception());
}

ur_result_t urCommandBufferAppendMemBufferReadRectExp(
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hBuffer,
ur_rect_offset_t bufferOffset, ur_rect_offset_t hostOffset,
ur_rect_region_t region, size_t bufferRowPitch, size_t bufferSlicePitch,
size_t hostRowPitch, size_t hostSlicePitch, void *pDst,
uint32_t numSyncPointsInWaitList,
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList,
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
ur_exp_command_buffer_command_handle_t *phCommand) try {

// the same issue as in urCommandBufferAppendKernelLaunchExp
std::ignore = numEventsInWaitList;
std::ignore = phEventWaitList;
std::ignore = phEvent;
// sync mechanic can be ignored, because all lists are in-order
std::ignore = numSyncPointsInWaitList;
std::ignore = pSyncPointWaitList;
std::ignore = pSyncPoint;

std::ignore = phCommand;

// Responsibility of UMD to offload to copy engine
UR_CALL(hCommandBuffer->commandListManager.appendMemBufferReadRect(
hBuffer, false, bufferOffset, hostOffset, region, bufferRowPitch,
bufferSlicePitch, hostRowPitch, hostSlicePitch, pDst, 0, nullptr,
nullptr));

return UR_RESULT_SUCCESS;
} catch (...) {
return exceptionToResult(std::current_exception());
}

ur_result_t
urCommandBufferGetInfoExp(ur_exp_command_buffer_handle_t hCommandBuffer,
ur_exp_command_buffer_info_t propName,
Expand Down
Loading

0 comments on commit 3ce6fcc

Please sign in to comment.