@@ -346,8 +346,7 @@ _pi_context::getFreeSlotInExistingOrNewPool(ze_event_pool_handle_t &ZePool,
346346 std::lock_guard<std::mutex> NumEventsLiveInEventPoolGuard (
347347 NumEventsLiveInEventPoolMutex, std::adopt_lock);
348348
349- ze_event_pool_desc_t ZeEventPoolDesc = {};
350- ZeEventPoolDesc.stype = ZE_STRUCTURE_TYPE_EVENT_POOL_DESC;
349+ ZeStruct<ze_event_pool_desc_t > ZeEventPoolDesc;
351350 ZeEventPoolDesc.count = MaxNumEventsPerPool;
352351
353352 // Make all events visible on the host.
@@ -585,7 +584,7 @@ pi_result _pi_context::initialize() {
585584 // TODO: get rid of using Devices[0] for the context with multiple
586585 // root-devices. We should somehow make the data initialized on all devices.
587586 pi_device Device = SingleRootDevice ? SingleRootDevice : Devices[0 ];
588- ze_command_queue_desc_t ZeCommandQueueDesc = {} ;
587+ ZeStruct< ze_command_queue_desc_t > ZeCommandQueueDesc;
589588 ZeCommandQueueDesc.ordinal = Device->ZeComputeQueueGroupIndex ;
590589 ZeCommandQueueDesc.index = 0 ;
591590 ZeCommandQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS;
@@ -733,10 +732,8 @@ pi_result _pi_context::getAvailableCommandList(
733732 // Each command list is paired with an associated fence to track when the
734733 // command list is available for reuse.
735734 _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;
740737
741738 ZeCommandListDesc.commandQueueGroupOrdinal =
742739 (UseCopyEngine) ? Queue->Device ->ZeCopyQueueGroupIndex
@@ -2224,7 +2221,9 @@ pi_result piContextCreate(const pi_context_properties *Properties,
22242221 PI_ASSERT (RetContext, PI_INVALID_VALUE);
22252222
22262223 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+
22282227 ze_context_handle_t ZeContext;
22292228 ZE_CALL (zeContextCreate, (Platform->ZeDriver , &ContextDesc, &ZeContext));
22302229 try {
@@ -2389,7 +2388,7 @@ pi_result piQueueCreate(pi_context Context, pi_device Device,
23892388 PI_ASSERT (Device, PI_INVALID_DEVICE);
23902389
23912390 ZeDevice = Device->ZeDevice ;
2392- ze_command_queue_desc_t ZeCommandQueueDesc = {} ;
2391+ ZeStruct< ze_command_queue_desc_t > ZeCommandQueueDesc;
23932392 ZeCommandQueueDesc.ordinal = Device->ZeComputeQueueGroupIndex ;
23942393 ZeCommandQueueDesc.index = 0 ;
23952394 ZeCommandQueueDesc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS;
@@ -2840,7 +2839,7 @@ pi_result piMemImageCreate(pi_context Context, pi_mem_flags Flags,
28402839 return PI_INVALID_VALUE;
28412840 }
28422841
2843- ze_image_desc_t ZeImageDesc = {} ;
2842+ ZeStruct< ze_image_desc_t > ZeImageDesc;
28442843 ZeImageDesc.arraylevels = ZeImageDesc.flags = 0 ;
28452844 ZeImageDesc.type = ZeImageType;
28462845 ZeImageDesc.format = ZeFormatDesc;
@@ -3340,7 +3339,7 @@ static pi_result compileOrBuild(pi_program Program, pi_uint32 NumDevices,
33403339 }
33413340
33423341 // 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;
33443343 ZeModuleDesc.format = (Program->State == _pi_program::IL)
33453344 ? ZE_MODULE_FORMAT_IL_SPIRV
33463345 : ZE_MODULE_FORMAT_NATIVE;
@@ -3515,7 +3514,7 @@ static pi_result copyModule(ze_context_handle_t ZeContext,
35153514 std::unique_ptr<uint8_t []> Code (new uint8_t [Length]);
35163515 ZE_CALL (zeModuleGetNativeBinary, (SrcMod, &Length, Code.get ()));
35173516
3518- ze_module_desc_t ZeModuleDesc = {} ;
3517+ ZeStruct< ze_module_desc_t > ZeModuleDesc;
35193518 ZeModuleDesc.format = ZE_MODULE_FORMAT_NATIVE;
35203519 ZeModuleDesc.inputSize = Length;
35213520 ZeModuleDesc.pInputModule = Code.get ();
@@ -3602,7 +3601,7 @@ pi_result piKernelCreate(pi_program Program, const char *KernelName,
36023601 return PI_INVALID_PROGRAM_EXECUTABLE;
36033602 }
36043603
3605- ze_kernel_desc_t ZeKernelDesc = {} ;
3604+ ZeStruct< ze_kernel_desc_t > ZeKernelDesc;
36063605 ZeKernelDesc.flags = 0 ;
36073606 ZeKernelDesc.pKernelName = KernelName;
36083607
@@ -4067,7 +4066,7 @@ pi_result piEventCreate(pi_context Context, pi_event *RetEvent) {
40674066 return Res;
40684067
40694068 ze_event_handle_t ZeEvent;
4070- ze_event_desc_t ZeEventDesc = {} ;
4069+ ZeStruct< ze_event_desc_t > ZeEventDesc;
40714070 // We have to set the SIGNAL flag as HOST scope because the
40724071 // Level-Zero plugin implementation waits for the events to complete
40734072 // on the host.
@@ -4470,7 +4469,7 @@ pi_result piSamplerCreate(pi_context Context,
44704469 pi_device Device = Context->Devices [0 ];
44714470
44724471 ze_sampler_handle_t ZeSampler;
4473- ze_sampler_desc_t ZeSamplerDesc = {} ;
4472+ ZeStruct< ze_sampler_desc_t > ZeSamplerDesc;
44744473
44754474 // Set the default values for the ZeSamplerDesc.
44764475 ZeSamplerDesc.isNormalized = PI_TRUE;
@@ -5186,7 +5185,7 @@ pi_result piEnqueueMemBufferMap(pi_queue Queue, pi_mem Buffer,
51865185 // Use the version with reference counting
51875186 PI_CALL (piextUSMHostAlloc (RetMap, Queue->Context , nullptr , Size, 1 ));
51885187 } else {
5189- ze_host_mem_alloc_desc_t ZeDesc = {} ;
5188+ ZeStruct< ze_host_mem_alloc_desc_t > ZeDesc;
51905189 ZeDesc.flags = 0 ;
51915190
51925191 ZE_CALL (zeMemAllocHost,
@@ -5716,14 +5715,13 @@ static pi_result USMDeviceAllocImpl(void **ResultPtr, pi_context Context,
57165715 PI_INVALID_VALUE);
57175716
57185717 // 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;
57205719 ZeDesc.flags = 0 ;
57215720 ZeDesc.ordinal = 0 ;
57225721
5723- ze_relaxed_allocation_limits_exp_desc_t RelaxedDesc = {} ;
5722+ ZeStruct< ze_relaxed_allocation_limits_exp_desc_t > RelaxedDesc;
57245723 if (Size > Device->ZeDeviceProperties .maxMemAllocSize ) {
57255724 // Tell Level-Zero to accept Size > maxMemAllocSize
5726- RelaxedDesc.stype = ZE_STRUCTURE_TYPE_RELAXED_ALLOCATION_LIMITS_EXP_DESC;
57275725 RelaxedDesc.flags = ZE_RELAXED_ALLOCATION_LIMITS_EXP_FLAG_MAX_SIZE;
57285726 ZeDesc.pNext = &RelaxedDesc;
57295727 }
@@ -5750,16 +5748,15 @@ static pi_result USMSharedAllocImpl(void **ResultPtr, pi_context Context,
57505748 PI_INVALID_VALUE);
57515749
57525750 // 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;
57545752 ZeHostDesc.flags = 0 ;
5755- ze_device_mem_alloc_desc_t ZeDevDesc = {} ;
5753+ ZeStruct< ze_device_mem_alloc_desc_t > ZeDevDesc;
57565754 ZeDevDesc.flags = 0 ;
57575755 ZeDevDesc.ordinal = 0 ;
57585756
5759- ze_relaxed_allocation_limits_exp_desc_t RelaxedDesc = {} ;
5757+ ZeStruct< ze_relaxed_allocation_limits_exp_desc_t > RelaxedDesc;
57605758 if (Size > Device->ZeDeviceProperties .maxMemAllocSize ) {
57615759 // Tell Level-Zero to accept Size > maxMemAllocSize
5762- RelaxedDesc.stype = ZE_STRUCTURE_TYPE_RELAXED_ALLOCATION_LIMITS_EXP_DESC;
57635760 RelaxedDesc.flags = ZE_RELAXED_ALLOCATION_LIMITS_EXP_FLAG_MAX_SIZE;
57645761 ZeDevDesc.pNext = &RelaxedDesc;
57655762 }
@@ -5784,7 +5781,7 @@ static pi_result USMHostAllocImpl(void **ResultPtr, pi_context Context,
57845781 PI_INVALID_VALUE);
57855782
57865783 // 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;
57885785 ZeHostDesc.flags = 0 ;
57895786 ZE_CALL (zeMemAllocHost,
57905787 (Context->ZeContext , &ZeHostDesc, Size, Alignment, ResultPtr));
0 commit comments