Skip to content

Commit ebe7537

Browse files
authored
Ability to query free memory without using SYSMAN (#395)
* Add extension ze_device_memory_ext_usablemem_limit_t to memory properties structure to track usable memory. * Correct documentation in sysman to indicate tracking physical memory instead of allocatable memory and deprecate the use of size field in the zes_mem_state_t structure to gather usable memory information. * Correct documentation for physicalSize field in zes_mem_properties_t * add usable memory extension to the extension memory properties documentation.
1 parent 98ff4b0 commit ebe7537

4 files changed

Lines changed: 100 additions & 5 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<%
2+
import re
3+
from templates import helper as th
4+
%><%
5+
OneApi=tags['$OneApi']
6+
x=tags['$x']
7+
X=x.upper()
8+
%>
9+
:orphan:
10+
11+
.. _ZE_extension_device_usablemem_size_properties:
12+
13+
======================================
14+
Device Usable Memory Size Properties Extension
15+
======================================
16+
17+
API
18+
----
19+
20+
* Enumerations
21+
22+
23+
* ${x}_device_usablemem_size_properties_ext_version_t
24+
25+
26+
* Structures
27+
28+
* ${x}_device_usablemem_size_ext_properties_t
29+
30+
31+
Extended Device Properties
32+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33+
34+
Users may wish get the status of the available allocatable/usable memory. Since this is a transient information based on the overall state of the device usage, user would need to invoke the extension to obtain the information at each point of interest. This extension provides extended information about the usable memory size available as part of the device. The extension introduces the ${x}_device_usablemem_size_ext_properties_t struct which can be passed to $xDeviceGetProperties via the `pNext` member of $x_device_properties_t.
35+
36+
The following psuedo-code demonstrates a sequence for obtaining extended information about the usable memory size
37+
38+
.. parsed-literal::
39+
40+
...
41+
// Discover properties on device
42+
//Driver handle ze_driver_handle_t Driverh obtained through previous call to zeInitDrivers
43+
//Obtain Device handle ze_device_handle_t Deviceh
44+
//zeDeviceGet(Driverh, 1, Deviceh);
45+
46+
ze_device_properties_t deviceProperties {};
47+
${x}_device_usablemem_size_ext_properties_t* pUsablememProps = allocate(sizeof(${x}_device_usablemem_size_ext_properties_t));
48+
49+
pUsablememProps.stype = ZE_STRUCTURE_TYPE_DEVICE_USABLEMEM_SIZE_EXT_PROPERTIES;
50+
deviceProperties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;
51+
deviceProperties.pNext = pUsablememProps;
52+
53+
//obtain device and extended memory properties
54+
zeDeviceGetProperties(Deviceh, &deviceProperties);
55+
56+
57+

scripts/core/common.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,10 @@ etors:
685685
desc: $x_physical_mem_properties_t
686686
version: "1.15"
687687
value: "0x00020040"
688+
- name: DEVICE_USABLEMEM_SIZE_EXT_PROPERTIES
689+
desc: $x_device_usablemem_size_ext_properties_t
690+
version: "1.15"
691+
value: "0x00020041"
688692
--- #--------------------------------------------------------------------------
689693
type: enum
690694
desc: "External memory type flags"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--- #--------------------------------------------------------------------------
2+
type: header
3+
desc: "Intel $OneApi Level-Zero Extension APIs for Device UsableMem Size Properties Extension"
4+
version: "1.15"
5+
--- #--------------------------------------------------------------------------
6+
type: macro
7+
desc: "Device Usable Memory Size Properties Extension Name"
8+
version: "1.15"
9+
name: $X_DEVICE_USABLEMEM_SIZE_PROPERTIES_EXT_NAME
10+
value: '"$X_extension_device_usablemem_size_properties"'
11+
--- #--------------------------------------------------------------------------
12+
type: enum
13+
desc: "Device Usable Mem Size Extension Version(s)"
14+
version: "1.15"
15+
name: $x_device_usablemem_size_properties_ext_version_t
16+
etors:
17+
- name: "1_0"
18+
value: "$X_MAKE_VERSION( 1, 0 )"
19+
desc: "version 1.0"
20+
--- #--------------------------------------------------------------------------
21+
type: struct
22+
desc: "Memory access property to discover current status of usable memory"
23+
version: "1.15"
24+
class: $xDevice
25+
name: $x_device_usablemem_size_ext_properties_t
26+
base: $x_base_properties_t
27+
members:
28+
- type: uint64_t
29+
name: currUsableMemSize
30+
desc: "[out] Returns the available usable memory at the device level. This is typically less than or equal to the available physical memory on the device. It important to note that usable memory size reported is transient in nature and cannot be used to reliably guarentee success of future allocations. The usable memory includes all the memory that the clients can allocate for their use and by L0 Core for its internal allocations."
31+
details:
32+
- "This structure may be returned from $xDeviceGetProperties via the `pNext` member of $x_device_properties_t"

scripts/sysman/memory.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ members:
104104
desc: "[out] Location of this memory (system, device)"
105105
- type: uint64_t
106106
name: physicalSize
107-
desc: "[out] Physical memory size in bytes. A value of 0 indicates that this property is not known. However, a call to $sMemoryGetState() will correctly return the total size of usable memory."
107+
desc: "[out] Physical memory capacity in bytes. A value of 0 indicates that this property is not known. However, a call to zesMemoryGetState() will return the available free physical memory."
108108
- type: int32_t
109109
name: busWidth
110110
desc: "[out] Width of the memory bus. A value of -1 means that this property is unknown."
@@ -118,18 +118,20 @@ class: $sMemory
118118
name: $s_mem_state_t
119119
base: $s_base_state_t
120120
details:
121-
- "Percent allocation is given by 100 * (size - free / size."
122-
- "Percent free is given by 100 * free / size."
121+
- "Percent free is given by 100 * free / pysical mem size."
123122
members:
124123
- type: $s_mem_health_t
125124
name: health
126125
desc: "[out] Indicates the health of the memory"
127126
- type: uint64_t
128127
name: free
129-
desc: "[out] The free memory in bytes"
128+
desc: "[out] The free physical memory in bytes"
130129
- type: uint64_t
131130
name: size
132-
desc: "[out] The total allocatable memory in bytes (can be less than the `physicalSize` member of $s_mem_properties_t)"
131+
desc: |
132+
[out] The total allocatable memory in bytes (can be less than the `physicalSize` member of $s_mem_properties_t). *DEPRECATED*
133+
This member can no longer track the allocatable memory reliably. Clients depending on this information can use the
134+
zeDeviceGetMemoryProperties with ze_device_usablemem_size_ext_properties_t extention to get information of the available usable memory.
133135
--- #--------------------------------------------------------------------------
134136
type: struct
135137
desc: "Memory bandwidth"

0 commit comments

Comments
 (0)