Skip to content

Commit 92afd90

Browse files
author
Jaime Arteaga
authored
Fix ze_device_properties_t in samples (#62)
Correct initialize ze_device_properties_t to zero and set stype properly. This way samples show how to initialize these structs to avoid driver implementations to misread garbage values in pNext. Signed-off-by: Jaime Arteaga <[email protected]>
1 parent 7520fd2 commit 92afd90

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

scripts/core/PROG.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ The following pseudo-code demonstrates a basic initialization and device discove
7979
${x}DeviceGet(allDrivers[i], &deviceCount, allDevices);
8080
8181
for(d = 0; d < deviceCount; ++d) {
82-
${x}_device_properties_t device_properties;
82+
${x}_device_properties_t device_properties {};
83+
device_properties.stype = ${X}_STRUCTURE_TYPE_DEVICE_PROPERTIES;
8384
${x}DeviceGetProperties(allDevices[d], &device_properties);
8485
8586
if(${X}_DEVICE_TYPE_GPU == device_properties.type) {
@@ -1772,7 +1773,8 @@ or sub-device using ${x}DeviceGetProperties.
17721773
${x}_device_handle_t hSubdevice = allSubDevices[2];
17731774
17741775
// Query sub-device properties.
1775-
${x}_device_properties_t subdeviceProps;
1776+
${x}_device_properties_t subdeviceProps {};
1777+
subDeviceProps.stype = ${X}_STRUCTURE_TYPE_DEVICE_PROPERTIES;
17761778
${x}DeviceGetProperties(hSubdevice, &subdeviceProps);
17771779
17781780
assert(subdeviceProps.flags & ${X}_DEVICE_PROPERTY_FLAG_SUBDEVICE); // Ensure that we have a handle to a sub-device.

scripts/sysman/PROG.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ system and create Sysman handles for them:
123123
${x}DeviceGet(allDrivers[i], &deviceCount, allDevices)
124124
125125
for(devIndex = 0 .. deviceCount-1)
126-
${x}_device_properties_t device_properties
126+
${x}_device_properties_t device_properties {}
127+
device_properties.stype = ${X}_STRUCTURE_TYPE_DEVICE_PROPERTIES
127128
${x}DeviceGetProperties(allDevices[devIndex], &device_properties)
128129
if(${X}_DEVICE_TYPE_GPU != device_properties.type)
129130
next
@@ -516,7 +517,8 @@ device:
516517
.. parsed-literal::
517518
518519
function ShowDeviceInfo(${s}_device_handle_t hSysmanDevice)
519-
${s}_device_properties_t devProps
520+
${s}_device_properties_t devProps {}
521+
devProps.stype = ${X}_STRUCTURE_TYPE_DEVICE_PROPERTIES
520522
${s}_device_state_t devState
521523
if (${s}DeviceGetProperties(hSysmanDevice, &devProps) == ${X}_RESULT_SUCCESS)
522524
output(" UUID: %s", devProps.core.uuid.id)

scripts/tools/PROG.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,8 @@ The total number of threads on a device can be computed using device properties
760760

761761
.. parsed-literal::
762762
763-
${x}_device_properties_t properties;
763+
${x}_device_properties_t properties {};
764+
properties.stype = ${X}_STRUCTURE_TYPE_DEVICE_PROPERTIES;
764765
uint64_t num_threads;
765766
766767
${x}DeviceGetProperties(hDevice, &properties);

0 commit comments

Comments
 (0)