Skip to content

Commit 08add9c

Browse files
committed
Add buffer mem calls to command buffer v2
1 parent 7e8d04e commit 08add9c

File tree

6 files changed

+485
-250
lines changed

6 files changed

+485
-250
lines changed

source/adapters/level_zero/v2/api.cpp

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -251,83 +251,6 @@ ur_result_t urCommandBufferAppendUSMFillExp(
251251
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
252252
}
253253

254-
ur_result_t urCommandBufferAppendMemBufferCopyExp(
255-
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hSrcMem,
256-
ur_mem_handle_t hDstMem, size_t srcOffset, size_t dstOffset, size_t size,
257-
uint32_t numSyncPointsInWaitList,
258-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
259-
uint32_t NumEventsInWaitList, const ur_event_handle_t *phEventWaitList,
260-
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
261-
ur_exp_command_buffer_command_handle_t *phCommand) {
262-
logger::error("{} function not implemented!", __FUNCTION__);
263-
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
264-
}
265-
266-
ur_result_t urCommandBufferAppendMemBufferWriteExp(
267-
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hBuffer,
268-
size_t offset, size_t size, const void *pSrc,
269-
uint32_t numSyncPointsInWaitList,
270-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
271-
uint32_t NumEventsInWaitList, const ur_event_handle_t *phEventWaitList,
272-
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
273-
ur_exp_command_buffer_command_handle_t *phCommand) {
274-
logger::error("{} function not implemented!", __FUNCTION__);
275-
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
276-
}
277-
278-
ur_result_t urCommandBufferAppendMemBufferReadExp(
279-
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hBuffer,
280-
size_t offset, size_t size, void *pDst, uint32_t numSyncPointsInWaitList,
281-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
282-
uint32_t NumEventsInWaitList, const ur_event_handle_t *phEventWaitList,
283-
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
284-
ur_exp_command_buffer_command_handle_t *phCommand) {
285-
logger::error("{} function not implemented!", __FUNCTION__);
286-
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
287-
}
288-
289-
ur_result_t urCommandBufferAppendMemBufferCopyRectExp(
290-
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hSrcMem,
291-
ur_mem_handle_t hDstMem, ur_rect_offset_t srcOrigin,
292-
ur_rect_offset_t dstOrigin, ur_rect_region_t region, size_t srcRowPitch,
293-
size_t srcSlicePitch, size_t dstRowPitch, size_t dstSlicePitch,
294-
uint32_t numSyncPointsInWaitList,
295-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
296-
uint32_t NumEventsInWaitList, const ur_event_handle_t *phEventWaitList,
297-
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
298-
ur_exp_command_buffer_command_handle_t *phCommand) {
299-
logger::error("{} function not implemented!", __FUNCTION__);
300-
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
301-
}
302-
303-
ur_result_t urCommandBufferAppendMemBufferWriteRectExp(
304-
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hBuffer,
305-
ur_rect_offset_t bufferOffset, ur_rect_offset_t hostOffset,
306-
ur_rect_region_t region, size_t bufferRowPitch, size_t bufferSlicePitch,
307-
size_t hostRowPitch, size_t hostSlicePitch, void *pSrc,
308-
uint32_t numSyncPointsInWaitList,
309-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
310-
uint32_t NumEventsInWaitList, const ur_event_handle_t *phEventWaitList,
311-
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
312-
ur_exp_command_buffer_command_handle_t *phCommand) {
313-
logger::error("{} function not implemented!", __FUNCTION__);
314-
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
315-
}
316-
317-
ur_result_t urCommandBufferAppendMemBufferReadRectExp(
318-
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hBuffer,
319-
ur_rect_offset_t bufferOffset, ur_rect_offset_t hostOffset,
320-
ur_rect_region_t region, size_t bufferRowPitch, size_t bufferSlicePitch,
321-
size_t hostRowPitch, size_t hostSlicePitch, void *pDst,
322-
uint32_t numSyncPointsInWaitList,
323-
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
324-
uint32_t NumEventsInWaitList, const ur_event_handle_t *phEventWaitList,
325-
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
326-
ur_exp_command_buffer_command_handle_t *phCommand) {
327-
logger::error("{} function not implemented!", __FUNCTION__);
328-
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
329-
}
330-
331254
ur_result_t urCommandBufferAppendMemBufferFillExp(
332255
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hBuffer,
333256
const void *pPattern, size_t patternSize, size_t offset, size_t size,

source/adapters/level_zero/v2/command_buffer.cpp

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,187 @@ ur_result_t urCommandBufferAppendUSMMemcpyExp(
165165
return exceptionToResult(std::current_exception());
166166
}
167167

168+
ur_result_t urCommandBufferAppendMemBufferCopyExp(
169+
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hSrcMem,
170+
ur_mem_handle_t hDstMem, size_t srcOffset, size_t dstOffset, size_t size,
171+
uint32_t numSyncPointsInWaitList,
172+
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
173+
uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList,
174+
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
175+
ur_exp_command_buffer_command_handle_t *phCommand) try {
176+
177+
// the same issue as in urCommandBufferAppendKernelLaunchExp
178+
std::ignore = numEventsInWaitList;
179+
std::ignore = phEventWaitList;
180+
std::ignore = phEvent;
181+
// sync mechanic can be ignored, because all lists are in-order
182+
std::ignore = numSyncPointsInWaitList;
183+
std::ignore = pSyncPointWaitList;
184+
std::ignore = pSyncPoint;
185+
186+
std::ignore = phCommand;
187+
// Responsibility of UMD to offload to copy engine
188+
UR_CALL(hCommandBuffer->commandListManager.appendMemBufferCopy(
189+
hSrcMem, hDstMem, srcOffset, dstOffset, size, 0, nullptr, nullptr));
190+
191+
return UR_RESULT_SUCCESS;
192+
} catch (...) {
193+
return exceptionToResult(std::current_exception());
194+
}
195+
196+
ur_result_t urCommandBufferAppendMemBufferWriteExp(
197+
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hBuffer,
198+
size_t offset, size_t size, const void *pSrc,
199+
uint32_t numSyncPointsInWaitList,
200+
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
201+
uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList,
202+
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
203+
ur_exp_command_buffer_command_handle_t *phCommand) try {
204+
205+
// the same issue as in urCommandBufferAppendKernelLaunchExp
206+
std::ignore = numEventsInWaitList;
207+
std::ignore = phEventWaitList;
208+
std::ignore = phEvent;
209+
// sync mechanic can be ignored, because all lists are in-order
210+
std::ignore = numSyncPointsInWaitList;
211+
std::ignore = pSyncPointWaitList;
212+
std::ignore = pSyncPoint;
213+
214+
std::ignore = phCommand;
215+
// Responsibility of UMD to offload to copy engine
216+
UR_CALL(hCommandBuffer->commandListManager.appendMemBufferWrite(
217+
hBuffer, false, offset, size, pSrc, 0, nullptr, nullptr));
218+
219+
return UR_RESULT_SUCCESS;
220+
} catch (...) {
221+
return exceptionToResult(std::current_exception());
222+
}
223+
224+
ur_result_t urCommandBufferAppendMemBufferReadExp(
225+
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hBuffer,
226+
size_t offset, size_t size, void *pDst, uint32_t numSyncPointsInWaitList,
227+
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
228+
uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList,
229+
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
230+
ur_exp_command_buffer_command_handle_t *phCommand) try {
231+
232+
// the same issue as in urCommandBufferAppendKernelLaunchExp
233+
std::ignore = numEventsInWaitList;
234+
std::ignore = phEventWaitList;
235+
std::ignore = phEvent;
236+
// sync mechanic can be ignored, because all lists are in-order
237+
std::ignore = numSyncPointsInWaitList;
238+
std::ignore = pSyncPointWaitList;
239+
std::ignore = pSyncPoint;
240+
241+
std::ignore = phCommand;
242+
243+
// Responsibility of UMD to offload to copy engine
244+
UR_CALL(hCommandBuffer->commandListManager.appendMemBufferRead(
245+
hBuffer, false, offset, size, pDst, 0, nullptr, nullptr));
246+
247+
return UR_RESULT_SUCCESS;
248+
} catch (...) {
249+
return exceptionToResult(std::current_exception());
250+
}
251+
252+
ur_result_t urCommandBufferAppendMemBufferCopyRectExp(
253+
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hSrcMem,
254+
ur_mem_handle_t hDstMem, ur_rect_offset_t srcOrigin,
255+
ur_rect_offset_t dstOrigin, ur_rect_region_t region, size_t srcRowPitch,
256+
size_t srcSlicePitch, size_t dstRowPitch, size_t dstSlicePitch,
257+
uint32_t numSyncPointsInWaitList,
258+
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
259+
uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList,
260+
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
261+
ur_exp_command_buffer_command_handle_t *phCommand) try {
262+
263+
// the same issue as in urCommandBufferAppendKernelLaunchExp
264+
std::ignore = numEventsInWaitList;
265+
std::ignore = phEventWaitList;
266+
std::ignore = phEvent;
267+
// sync mechanic can be ignored, because all lists are in-order
268+
std::ignore = numSyncPointsInWaitList;
269+
std::ignore = pSyncPointWaitList;
270+
std::ignore = pSyncPoint;
271+
272+
std::ignore = phCommand;
273+
// Responsibility of UMD to offload to copy engine
274+
UR_CALL(hCommandBuffer->commandListManager.appendMemBufferCopyRect(
275+
hSrcMem, hDstMem, srcOrigin, dstOrigin, region, srcRowPitch,
276+
srcSlicePitch, dstRowPitch, dstSlicePitch, 0, nullptr, nullptr));
277+
278+
return UR_RESULT_SUCCESS;
279+
} catch (...) {
280+
return exceptionToResult(std::current_exception());
281+
}
282+
283+
ur_result_t urCommandBufferAppendMemBufferWriteRectExp(
284+
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hBuffer,
285+
ur_rect_offset_t bufferOffset, ur_rect_offset_t hostOffset,
286+
ur_rect_region_t region, size_t bufferRowPitch, size_t bufferSlicePitch,
287+
size_t hostRowPitch, size_t hostSlicePitch, void *pSrc,
288+
uint32_t numSyncPointsInWaitList,
289+
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
290+
uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList,
291+
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
292+
ur_exp_command_buffer_command_handle_t *phCommand) try {
293+
294+
// the same issue as in urCommandBufferAppendKernelLaunchExp
295+
std::ignore = numEventsInWaitList;
296+
std::ignore = phEventWaitList;
297+
std::ignore = phEvent;
298+
// sync mechanic can be ignored, because all lists are in-order
299+
std::ignore = numSyncPointsInWaitList;
300+
std::ignore = pSyncPointWaitList;
301+
std::ignore = pSyncPoint;
302+
303+
std::ignore = phCommand;
304+
305+
// Responsibility of UMD to offload to copy engine
306+
UR_CALL(hCommandBuffer->commandListManager.appendMemBufferWriteRect(
307+
hBuffer, false, bufferOffset, hostOffset, region, bufferRowPitch,
308+
bufferSlicePitch, hostRowPitch, hostSlicePitch, pSrc, 0, nullptr,
309+
nullptr));
310+
311+
return UR_RESULT_SUCCESS;
312+
} catch (...) {
313+
return exceptionToResult(std::current_exception());
314+
}
315+
316+
ur_result_t urCommandBufferAppendMemBufferReadRectExp(
317+
ur_exp_command_buffer_handle_t hCommandBuffer, ur_mem_handle_t hBuffer,
318+
ur_rect_offset_t bufferOffset, ur_rect_offset_t hostOffset,
319+
ur_rect_region_t region, size_t bufferRowPitch, size_t bufferSlicePitch,
320+
size_t hostRowPitch, size_t hostSlicePitch, void *pDst,
321+
uint32_t numSyncPointsInWaitList,
322+
const ur_exp_command_buffer_sync_point_t *pSyncPointWaitList,
323+
uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList,
324+
ur_exp_command_buffer_sync_point_t *pSyncPoint, ur_event_handle_t *phEvent,
325+
ur_exp_command_buffer_command_handle_t *phCommand) try {
326+
327+
// the same issue as in urCommandBufferAppendKernelLaunchExp
328+
std::ignore = numEventsInWaitList;
329+
std::ignore = phEventWaitList;
330+
std::ignore = phEvent;
331+
// sync mechanic can be ignored, because all lists are in-order
332+
std::ignore = numSyncPointsInWaitList;
333+
std::ignore = pSyncPointWaitList;
334+
std::ignore = pSyncPoint;
335+
336+
std::ignore = phCommand;
337+
338+
// Responsibility of UMD to offload to copy engine
339+
UR_CALL(hCommandBuffer->commandListManager.appendMemBufferReadRect(
340+
hBuffer, false, bufferOffset, hostOffset, region, bufferRowPitch,
341+
bufferSlicePitch, hostRowPitch, hostSlicePitch, pDst, 0, nullptr,
342+
nullptr));
343+
344+
return UR_RESULT_SUCCESS;
345+
} catch (...) {
346+
return exceptionToResult(std::current_exception());
347+
}
348+
168349
ur_result_t
169350
urCommandBufferGetInfoExp(ur_exp_command_buffer_handle_t hCommandBuffer,
170351
ur_exp_command_buffer_info_t propName,

0 commit comments

Comments
 (0)