@@ -346,8 +346,7 @@ _pi_context::getFreeSlotInExistingOrNewPool(ze_event_pool_handle_t &ZePool,
346
346
std::lock_guard<std::mutex> NumEventsLiveInEventPoolGuard (
347
347
NumEventsLiveInEventPoolMutex, std::adopt_lock);
348
348
349
- ze_event_pool_desc_t ZeEventPoolDesc = {};
350
- ZeEventPoolDesc.stype = ZE_STRUCTURE_TYPE_EVENT_POOL_DESC;
349
+ ZeStruct<ze_event_pool_desc_t > ZeEventPoolDesc;
351
350
ZeEventPoolDesc.count = MaxNumEventsPerPool;
352
351
353
352
// Make all events visible on the host.
@@ -585,7 +584,7 @@ pi_result _pi_context::initialize() {
585
584
// TODO: get rid of using Devices[0] for the context with multiple
586
585
// root-devices. We should somehow make the data initialized on all devices.
587
586
pi_device Device = SingleRootDevice ? SingleRootDevice : Devices[0 ];
588
- ze_command_queue_desc_t ZeCommandQueueDesc = {} ;
587
+ ZeStruct< ze_command_queue_desc_t > ZeCommandQueueDesc;
589
588
ZeCommandQueueDesc.ordinal = Device->ZeComputeQueueGroupIndex ;
590
589
ZeCommandQueueDesc.index = 0 ;
591
590
ZeCommandQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS;
@@ -733,10 +732,8 @@ pi_result _pi_context::getAvailableCommandList(
733
732
// Each command list is paired with an associated fence to track when the
734
733
// command list is available for reuse.
735
734
_pi_result pi_result = PI_OUT_OF_RESOURCES;
736
- ze_command_list_desc_t ZeCommandListDesc = {};
737
- ZeCommandListDesc.stype = ZE_STRUCTURE_TYPE_COMMAND_LIST_DESC;
738
- ze_fence_desc_t ZeFenceDesc = {};
739
- ZeFenceDesc.stype = ZE_STRUCTURE_TYPE_FENCE_DESC;
735
+ ZeStruct<ze_command_list_desc_t > ZeCommandListDesc;
736
+ ZeStruct<ze_fence_desc_t > ZeFenceDesc;
740
737
741
738
ZeCommandListDesc.commandQueueGroupOrdinal =
742
739
(UseCopyEngine) ? Queue->Device ->ZeCopyQueueGroupIndex
@@ -2224,7 +2221,9 @@ pi_result piContextCreate(const pi_context_properties *Properties,
2224
2221
PI_ASSERT (RetContext, PI_INVALID_VALUE);
2225
2222
2226
2223
pi_platform Platform = (*Devices)->Platform ;
2227
- ze_context_desc_t ContextDesc = {ZE_STRUCTURE_TYPE_CONTEXT_DESC, nullptr , 0 };
2224
+ ZeStruct<ze_context_desc_t > ContextDesc;
2225
+ ContextDesc.flags = 0 ;
2226
+
2228
2227
ze_context_handle_t ZeContext;
2229
2228
ZE_CALL (zeContextCreate, (Platform->ZeDriver , &ContextDesc, &ZeContext));
2230
2229
try {
@@ -2389,7 +2388,7 @@ pi_result piQueueCreate(pi_context Context, pi_device Device,
2389
2388
PI_ASSERT (Device, PI_INVALID_DEVICE);
2390
2389
2391
2390
ZeDevice = Device->ZeDevice ;
2392
- ze_command_queue_desc_t ZeCommandQueueDesc = {} ;
2391
+ ZeStruct< ze_command_queue_desc_t > ZeCommandQueueDesc;
2393
2392
ZeCommandQueueDesc.ordinal = Device->ZeComputeQueueGroupIndex ;
2394
2393
ZeCommandQueueDesc.index = 0 ;
2395
2394
ZeCommandQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS;
@@ -2840,7 +2839,7 @@ pi_result piMemImageCreate(pi_context Context, pi_mem_flags Flags,
2840
2839
return PI_INVALID_VALUE;
2841
2840
}
2842
2841
2843
- ze_image_desc_t ZeImageDesc = {} ;
2842
+ ZeStruct< ze_image_desc_t > ZeImageDesc;
2844
2843
ZeImageDesc.arraylevels = ZeImageDesc.flags = 0 ;
2845
2844
ZeImageDesc.type = ZeImageType;
2846
2845
ZeImageDesc.format = ZeFormatDesc;
@@ -3340,7 +3339,7 @@ static pi_result compileOrBuild(pi_program Program, pi_uint32 NumDevices,
3340
3339
}
3341
3340
3342
3341
// Ask Level Zero to build and load the native code onto the device.
3343
- ze_module_desc_t ZeModuleDesc = {} ;
3342
+ ZeStruct< ze_module_desc_t > ZeModuleDesc;
3344
3343
ZeModuleDesc.format = (Program->State == _pi_program::IL)
3345
3344
? ZE_MODULE_FORMAT_IL_SPIRV
3346
3345
: ZE_MODULE_FORMAT_NATIVE;
@@ -3515,7 +3514,7 @@ static pi_result copyModule(ze_context_handle_t ZeContext,
3515
3514
std::unique_ptr<uint8_t []> Code (new uint8_t [Length]);
3516
3515
ZE_CALL (zeModuleGetNativeBinary, (SrcMod, &Length, Code.get ()));
3517
3516
3518
- ze_module_desc_t ZeModuleDesc = {} ;
3517
+ ZeStruct< ze_module_desc_t > ZeModuleDesc;
3519
3518
ZeModuleDesc.format = ZE_MODULE_FORMAT_NATIVE;
3520
3519
ZeModuleDesc.inputSize = Length;
3521
3520
ZeModuleDesc.pInputModule = Code.get ();
@@ -3602,7 +3601,7 @@ pi_result piKernelCreate(pi_program Program, const char *KernelName,
3602
3601
return PI_INVALID_PROGRAM_EXECUTABLE;
3603
3602
}
3604
3603
3605
- ze_kernel_desc_t ZeKernelDesc = {} ;
3604
+ ZeStruct< ze_kernel_desc_t > ZeKernelDesc;
3606
3605
ZeKernelDesc.flags = 0 ;
3607
3606
ZeKernelDesc.pKernelName = KernelName;
3608
3607
@@ -4067,7 +4066,7 @@ pi_result piEventCreate(pi_context Context, pi_event *RetEvent) {
4067
4066
return Res;
4068
4067
4069
4068
ze_event_handle_t ZeEvent;
4070
- ze_event_desc_t ZeEventDesc = {} ;
4069
+ ZeStruct< ze_event_desc_t > ZeEventDesc;
4071
4070
// We have to set the SIGNAL flag as HOST scope because the
4072
4071
// Level-Zero plugin implementation waits for the events to complete
4073
4072
// on the host.
@@ -4470,7 +4469,7 @@ pi_result piSamplerCreate(pi_context Context,
4470
4469
pi_device Device = Context->Devices [0 ];
4471
4470
4472
4471
ze_sampler_handle_t ZeSampler;
4473
- ze_sampler_desc_t ZeSamplerDesc = {} ;
4472
+ ZeStruct< ze_sampler_desc_t > ZeSamplerDesc;
4474
4473
4475
4474
// Set the default values for the ZeSamplerDesc.
4476
4475
ZeSamplerDesc.isNormalized = PI_TRUE;
@@ -5186,7 +5185,7 @@ pi_result piEnqueueMemBufferMap(pi_queue Queue, pi_mem Buffer,
5186
5185
// Use the version with reference counting
5187
5186
PI_CALL (piextUSMHostAlloc (RetMap, Queue->Context , nullptr , Size, 1 ));
5188
5187
} else {
5189
- ze_host_mem_alloc_desc_t ZeDesc = {} ;
5188
+ ZeStruct< ze_host_mem_alloc_desc_t > ZeDesc;
5190
5189
ZeDesc.flags = 0 ;
5191
5190
5192
5191
ZE_CALL (zeMemAllocHost,
@@ -5716,14 +5715,13 @@ static pi_result USMDeviceAllocImpl(void **ResultPtr, pi_context Context,
5716
5715
PI_INVALID_VALUE);
5717
5716
5718
5717
// TODO: translate PI properties to Level Zero flags
5719
- ze_device_mem_alloc_desc_t ZeDesc = {} ;
5718
+ ZeStruct< ze_device_mem_alloc_desc_t > ZeDesc;
5720
5719
ZeDesc.flags = 0 ;
5721
5720
ZeDesc.ordinal = 0 ;
5722
5721
5723
- ze_relaxed_allocation_limits_exp_desc_t RelaxedDesc = {} ;
5722
+ ZeStruct< ze_relaxed_allocation_limits_exp_desc_t > RelaxedDesc;
5724
5723
if (Size > Device->ZeDeviceProperties .maxMemAllocSize ) {
5725
5724
// Tell Level-Zero to accept Size > maxMemAllocSize
5726
- RelaxedDesc.stype = ZE_STRUCTURE_TYPE_RELAXED_ALLOCATION_LIMITS_EXP_DESC;
5727
5725
RelaxedDesc.flags = ZE_RELAXED_ALLOCATION_LIMITS_EXP_FLAG_MAX_SIZE;
5728
5726
ZeDesc.pNext = &RelaxedDesc;
5729
5727
}
@@ -5750,16 +5748,15 @@ static pi_result USMSharedAllocImpl(void **ResultPtr, pi_context Context,
5750
5748
PI_INVALID_VALUE);
5751
5749
5752
5750
// TODO: translate PI properties to Level Zero flags
5753
- ze_host_mem_alloc_desc_t ZeHostDesc = {} ;
5751
+ ZeStruct< ze_host_mem_alloc_desc_t > ZeHostDesc;
5754
5752
ZeHostDesc.flags = 0 ;
5755
- ze_device_mem_alloc_desc_t ZeDevDesc = {} ;
5753
+ ZeStruct< ze_device_mem_alloc_desc_t > ZeDevDesc;
5756
5754
ZeDevDesc.flags = 0 ;
5757
5755
ZeDevDesc.ordinal = 0 ;
5758
5756
5759
- ze_relaxed_allocation_limits_exp_desc_t RelaxedDesc = {} ;
5757
+ ZeStruct< ze_relaxed_allocation_limits_exp_desc_t > RelaxedDesc;
5760
5758
if (Size > Device->ZeDeviceProperties .maxMemAllocSize ) {
5761
5759
// Tell Level-Zero to accept Size > maxMemAllocSize
5762
- RelaxedDesc.stype = ZE_STRUCTURE_TYPE_RELAXED_ALLOCATION_LIMITS_EXP_DESC;
5763
5760
RelaxedDesc.flags = ZE_RELAXED_ALLOCATION_LIMITS_EXP_FLAG_MAX_SIZE;
5764
5761
ZeDevDesc.pNext = &RelaxedDesc;
5765
5762
}
@@ -5784,7 +5781,7 @@ static pi_result USMHostAllocImpl(void **ResultPtr, pi_context Context,
5784
5781
PI_INVALID_VALUE);
5785
5782
5786
5783
// TODO: translate PI properties to Level Zero flags
5787
- ze_host_mem_alloc_desc_t ZeHostDesc = {} ;
5784
+ ZeStruct< ze_host_mem_alloc_desc_t > ZeHostDesc;
5788
5785
ZeHostDesc.flags = 0 ;
5789
5786
ZE_CALL (zeMemAllocHost,
5790
5787
(Context->ZeContext , &ZeHostDesc, Size, Alignment, ResultPtr));
0 commit comments