10
10
11
11
#include " command_buffer.hpp"
12
12
#include " ../helpers/kernel_helpers.hpp"
13
- #include " logger/ur_logger.hpp"
14
13
#include " ../ur_interface_loader.hpp"
14
+ #include " logger/ur_logger.hpp"
15
15
16
16
namespace {
17
17
@@ -27,10 +27,9 @@ void checkImmediateAppendSupport(ur_context_handle_t context) {
27
27
" zeCommandListImmediateAppendCommandListsExp entrypoint." );
28
28
std::abort ();
29
29
}
30
-
31
30
}
32
31
33
- }
32
+ } // namespace
34
33
35
34
std::pair<ze_event_handle_t *, uint32_t >
36
35
ur_exp_command_buffer_handle_t_::getWaitListView (
@@ -46,8 +45,8 @@ ur_exp_command_buffer_handle_t_::getWaitListView(
46
45
47
46
ur_exp_command_buffer_handle_t_::ur_exp_command_buffer_handle_t_ (
48
47
ur_context_handle_t context, ur_device_handle_t device,
49
- ze_command_list_handle_t commandList,
50
- const ur_exp_command_buffer_desc_t *desc)
48
+ ze_command_list_handle_t commandList,
49
+ const ur_exp_command_buffer_desc_t *desc)
51
50
: context(context), device(device), zeCommandList(commandList),
52
51
isUpdatable(desc ? desc->isUpdatable : false ) {
53
52
UR_CALL_THROWS (ur::level_zero::urContextRetain (context));
@@ -77,15 +76,14 @@ namespace ur::level_zero {
77
76
* @return UR_RESULT_SUCCESS or an error code on failure
78
77
*/
79
78
ur_result_t createMainCommandList (ur_context_handle_t context,
80
- ur_device_handle_t device,
81
- bool isUpdatable,
79
+ ur_device_handle_t device, bool isUpdatable,
82
80
ze_command_list_handle_t &commandList) {
83
81
84
-
85
82
using queue_group_type = ur_device_handle_t_::queue_group_info_t ::type;
86
- // that should be call to queue getZeOrdinal,
83
+ // that should be call to queue getZeOrdinal,
87
84
// but queue is not available while constructing buffer
88
- uint32_t queueGroupOrdinal = device->QueueGroup [queue_group_type::Compute].ZeOrdinal ;
85
+ uint32_t queueGroupOrdinal =
86
+ device->QueueGroup [queue_group_type::Compute].ZeOrdinal ;
89
87
90
88
ZeStruct<ze_command_list_desc_t > zeCommandListDesc;
91
89
zeCommandListDesc.commandQueueGroupOrdinal = queueGroupOrdinal;
@@ -116,7 +114,7 @@ urCommandBufferCreateExp(ur_context_handle_t context, ur_device_handle_t device,
116
114
UR_ASSERT (context->getPlatform ()->ZeMutableCmdListExt .Supported ,
117
115
UR_RESULT_ERROR_UNSUPPORTED_FEATURE);
118
116
}
119
-
117
+
120
118
ze_command_list_handle_t zeCommandList = nullptr ;
121
119
UR_CALL (createMainCommandList (context, device, isUpdatable, zeCommandList));
122
120
*commandBuffer = new ur_exp_command_buffer_handle_t_ (
@@ -152,7 +150,7 @@ urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t hCommandBuffer) {
152
150
}
153
151
154
152
ur_result_t
155
- urCommandBufferFinalizeExp (ur_exp_command_buffer_handle_t hCommandBuffer) {
153
+ urCommandBufferFinalizeExp (ur_exp_command_buffer_handle_t hCommandBuffer) {
156
154
try {
157
155
UR_ASSERT (hCommandBuffer, UR_RESULT_ERROR_INVALID_NULL_POINTER);
158
156
UR_ASSERT (!hCommandBuffer->isFinalized , UR_RESULT_ERROR_INVALID_OPERATION);
@@ -180,33 +178,34 @@ ur_result_t urCommandBufferAppendKernelLaunchExp(
180
178
uint32_t numEventsInWaitList, const ur_event_handle_t *eventWaitList,
181
179
ur_exp_command_buffer_sync_point_t *retSyncPoint, ur_event_handle_t *event,
182
180
ur_exp_command_buffer_command_handle_t *command) {
183
- // Need to know semantics
184
- // - should they be checked before kernel execution or before kernel appending to list
185
- // if latter then it is easy fix, if former then TODO
181
+ // Need to know semantics
182
+ // - should they be checked before kernel execution or before kernel
183
+ // appending to list if latter then it is easy fix, if former then TODO
186
184
std::ignore = numEventsInWaitList;
187
185
std::ignore = eventWaitList;
188
186
std::ignore = event;
189
187
190
- // sync mechanic can be ignored, because all lists are in-order
188
+ // sync mechanic can be ignored, because all lists are in-order
191
189
std::ignore = numSyncPointsInWaitList;
192
190
std::ignore = syncPointWaitList;
193
191
std::ignore = retSyncPoint;
194
192
195
- // TODO
193
+ // TODO
196
194
std::ignore = numKernelAlternatives;
197
195
std::ignore = kernelAlternatives;
198
196
std::ignore = command;
199
197
try {
200
198
UR_ASSERT (hKernel, UR_RESULT_ERROR_INVALID_NULL_HANDLE);
201
- UR_ASSERT (hKernel->getProgramHandle (), UR_RESULT_ERROR_INVALID_NULL_POINTER);
199
+ UR_ASSERT (hKernel->getProgramHandle (),
200
+ UR_RESULT_ERROR_INVALID_NULL_POINTER);
202
201
203
202
UR_ASSERT (workDim > 0 , UR_RESULT_ERROR_INVALID_WORK_DIMENSION);
204
203
UR_ASSERT (workDim < 4 , UR_RESULT_ERROR_INVALID_WORK_DIMENSION);
205
204
206
205
ze_kernel_handle_t hZeKernel = hKernel->getZeHandle (commandBuffer->device );
207
206
208
- std::scoped_lock<ur_shared_mutex, ur_shared_mutex> lock (commandBuffer-> Mutex ,
209
- hKernel->Mutex );
207
+ std::scoped_lock<ur_shared_mutex, ur_shared_mutex> lock (
208
+ commandBuffer-> Mutex , hKernel->Mutex );
210
209
211
210
ze_group_count_t zeThreadGroupDimensions{1 , 1 , 1 };
212
211
uint32_t wg[3 ]{};
@@ -219,18 +218,19 @@ ur_result_t urCommandBufferAppendKernelLaunchExp(
219
218
bool memoryMigrated = false ;
220
219
auto memoryMigrate = [&](void *src, void *dst, size_t size) {
221
220
ZE2UR_CALL_THROWS (zeCommandListAppendMemoryCopy,
222
- (commandBuffer->zeCommandList .get (), dst, src, size, nullptr ,
223
- waitList.second , waitList.first ));
221
+ (commandBuffer->zeCommandList .get (), dst, src, size,
222
+ nullptr , waitList.second , waitList.first ));
224
223
memoryMigrated = true ;
225
224
};
226
225
227
- UR_CALL (hKernel->prepareForSubmission (commandBuffer-> context , commandBuffer-> device , pGlobalWorkOffset,
228
- workDim, wg[ 0 ], wg[ 1 ], wg[ 2 ] ,
229
- memoryMigrate));
226
+ UR_CALL (hKernel->prepareForSubmission (
227
+ commandBuffer-> context , commandBuffer-> device , pGlobalWorkOffset ,
228
+ workDim, wg[ 0 ], wg[ 1 ], wg[ 2 ], memoryMigrate));
230
229
231
230
ZE2UR_CALL (zeCommandListAppendLaunchKernel,
232
- (commandBuffer->zeCommandList .get (), hZeKernel, &zeThreadGroupDimensions,
233
- nullptr , waitList.second , waitList.first ));
231
+ (commandBuffer->zeCommandList .get (), hZeKernel,
232
+ &zeThreadGroupDimensions, nullptr , waitList.second ,
233
+ waitList.first ));
234
234
} catch (...) {
235
235
return exceptionToResult (std::current_exception ());
236
236
}
@@ -243,8 +243,9 @@ ur_result_t urCommandBufferEnqueueExp(
243
243
uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList,
244
244
ur_event_handle_t *phEvent) {
245
245
try {
246
- return hQueue->enqueueCommandBuffer (
247
- hCommandBuffer->zeCommandList .get (), phEvent, numEventsInWaitList, phEventWaitList);
246
+ return hQueue->enqueueCommandBuffer (hCommandBuffer->zeCommandList .get (),
247
+ phEvent, numEventsInWaitList,
248
+ phEventWaitList);
248
249
} catch (...) {
249
250
return exceptionToResult (std::current_exception ());
250
251
}
0 commit comments