From 16aa9602bd7eb710eba48b9965456281bba2aad7 Mon Sep 17 00:00:00 2001 From: James Brodman Date: Wed, 31 Mar 2021 16:26:37 -0400 Subject: [PATCH 1/4] Initial Draft of Extension for querying free device memory on Level Zero Signed-off-by: James Brodman --- .../extensions/FreeMemQuery/FreeMemQuery.adoc | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 sycl/doc/extensions/FreeMemQuery/FreeMemQuery.adoc diff --git a/sycl/doc/extensions/FreeMemQuery/FreeMemQuery.adoc b/sycl/doc/extensions/FreeMemQuery/FreeMemQuery.adoc new file mode 100644 index 0000000000000..524f098530228 --- /dev/null +++ b/sycl/doc/extensions/FreeMemQuery/FreeMemQuery.adoc @@ -0,0 +1,43 @@ += SYCL Proposals: Level Zero Backend: Free Memory Device Query +James Brodman +v0.1 +:source-highlighter: pygments +:icons: font +== Introduction +This document presents an addition for the Level Zero Backend Specification. The goal of this proposal is to give users the ability to query the amount of currently free memory on a device that uses a Level Zero Backend in SYCL 2020. + +== Free Memory query +Level Zero contains a library for system resource management called Sysman. Sysman allows programmers to query the amount of free, or unallocated, memory in a device. This extension provides a new device information descriptor specific to Level Zero Backends that allows DPC++ programs to query the amount of free memory for a given device. The new descriptor is as follows: + +.Proposed Backend Device Information Descriptor +[source,c++] +---- +namespace sycl{ +namespace ext { +namespace oneapi{ +namespace level_zero { +namespace info { +namespace device { + +struct free_memory { + using return_type = uint64_t; +}; + +} // namespace device; +} // namespace info +} // namespace level_zero +} // namespace oneapi +} // namespace ext +} // namespace sycl +---- + +The new struct `free_memory` is used in conjuction with the `get_backend_info()` method of the `device` class in SYCL 2020. The query will return the number of bytes of free memory for that device. + +.Example Usage +[source,c++] +---- +sycl::queue Queue; +auto Device = Queue.get_device(); + +uint64_t freeMemory = Device.get_backend_info(); +---- From fb322877188e8b1e5d6a7d715885ee7520c4af97 Mon Sep 17 00:00:00 2001 From: James Brodman Date: Tue, 13 Apr 2021 14:10:50 -0400 Subject: [PATCH 2/4] Move Free Memory extension to L0 BE spec Signed-off-by: James Brodman --- .../extensions/FreeMemQuery/FreeMemQuery.adoc | 43 ------------------- .../LevelZeroBackend/LevelZeroBackend.md | 39 +++++++++++++++++ 2 files changed, 39 insertions(+), 43 deletions(-) delete mode 100644 sycl/doc/extensions/FreeMemQuery/FreeMemQuery.adoc diff --git a/sycl/doc/extensions/FreeMemQuery/FreeMemQuery.adoc b/sycl/doc/extensions/FreeMemQuery/FreeMemQuery.adoc deleted file mode 100644 index 524f098530228..0000000000000 --- a/sycl/doc/extensions/FreeMemQuery/FreeMemQuery.adoc +++ /dev/null @@ -1,43 +0,0 @@ -= SYCL Proposals: Level Zero Backend: Free Memory Device Query -James Brodman -v0.1 -:source-highlighter: pygments -:icons: font -== Introduction -This document presents an addition for the Level Zero Backend Specification. The goal of this proposal is to give users the ability to query the amount of currently free memory on a device that uses a Level Zero Backend in SYCL 2020. - -== Free Memory query -Level Zero contains a library for system resource management called Sysman. Sysman allows programmers to query the amount of free, or unallocated, memory in a device. This extension provides a new device information descriptor specific to Level Zero Backends that allows DPC++ programs to query the amount of free memory for a given device. The new descriptor is as follows: - -.Proposed Backend Device Information Descriptor -[source,c++] ----- -namespace sycl{ -namespace ext { -namespace oneapi{ -namespace level_zero { -namespace info { -namespace device { - -struct free_memory { - using return_type = uint64_t; -}; - -} // namespace device; -} // namespace info -} // namespace level_zero -} // namespace oneapi -} // namespace ext -} // namespace sycl ----- - -The new struct `free_memory` is used in conjuction with the `get_backend_info()` method of the `device` class in SYCL 2020. The query will return the number of bytes of free memory for that device. - -.Example Usage -[source,c++] ----- -sycl::queue Queue; -auto Device = Queue.get_device(); - -uint64_t freeMemory = Device.get_backend_info(); ----- diff --git a/sycl/doc/extensions/LevelZeroBackend/LevelZeroBackend.md b/sycl/doc/extensions/LevelZeroBackend/LevelZeroBackend.md index 60cc4fbe9890c..544872fd5e39f 100755 --- a/sycl/doc/extensions/LevelZeroBackend/LevelZeroBackend.md +++ b/sycl/doc/extensions/LevelZeroBackend/LevelZeroBackend.md @@ -139,9 +139,48 @@ Applications must make sure that the Level-Zero handles themselves aren't used s Practically speaking, and taking into account that SYCL runtime takes ownership of the Level-Zero handles, the application should not attempt further direct use of those handles. +## 5 Level-Zero additional functionality + +### 5.1 Free Memory query +Level Zero contains a library for system resource management called Sysman. +Sysman allows programmers to query the amount of free, or unallocated, +memory in a device. This extension provides a new device information +descriptor specific to Level-Zero Backends that allows DPC++ programs to query +the amount of free memory for a given device. The new descriptor is as follows: + +``` C++ +namespace sycl{ +namespace ext { +namespace oneapi{ +namespace level_zero { +namespace info { +namespace device { + +struct free_memory { + using return_type = size_t; +}; + +} // namespace device; +} // namespace info +} // namespace level_zero +} // namespace oneapi +} // namespace ext +} // namespace sycl +``` + +The new struct ```free_memory``` is used in conjuction with the ```get_backend_info()``` method of the ```device``` class in SYCL 2020. The query will return the number of bytes of free memory for that device. + +``` C++ +sycl::queue Queue; +auto Device = Queue.get_device(); + +uint64_t freeMemory = Device.get_backend_info(); +``` + ## Revision History |Rev|Date|Author|Changes| |-------------|:------------|:------------|:------------| |1|2021-01-26|Sergey Maslov|Initial public working draft |2|2021-02-22|Sergey Maslov|Introduced explicit ownership for context +|3|2021-04-13|James Brodman|Free Memory Query From d94e8a7df59e74e6dba3e4ce9392e9f384e6975d Mon Sep 17 00:00:00 2001 From: James Brodman Date: Tue, 20 Apr 2021 15:23:52 -0400 Subject: [PATCH 3/4] Change formatting based on suggestions Signed-off-by: James Brodman --- .../LevelZeroBackend/LevelZeroBackend.md | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/sycl/doc/extensions/LevelZeroBackend/LevelZeroBackend.md b/sycl/doc/extensions/LevelZeroBackend/LevelZeroBackend.md index 544872fd5e39f..7cb8f48fe73ea 100755 --- a/sycl/doc/extensions/LevelZeroBackend/LevelZeroBackend.md +++ b/sycl/doc/extensions/LevelZeroBackend/LevelZeroBackend.md @@ -141,12 +141,29 @@ the application should not attempt further direct use of those handles. ## 5 Level-Zero additional functionality -### 5.1 Free Memory query -Level Zero contains a library for system resource management called Sysman. -Sysman allows programmers to query the amount of free, or unallocated, -memory in a device. This extension provides a new device information -descriptor specific to Level-Zero Backends that allows DPC++ programs to query -the amount of free memory for a given device. The new descriptor is as follows: +### 5.1 Device Information Descriptors +The Level Zero backend provides the following device information descriptors +that an application can use to query information about a Level Zero device. +Applications use these queries via the `device::get_backend_info<>()` member +function as shown in the example below (which illustrates the `free_memory` +query): + +``` C++ +sycl::queue Queue; +auto Device = Queue.get_device(); + +size_t freeMemory = + Device.get_backend_info(); +``` + +New descriptors added as part of this specification are found in the table below: + +| Descriptor | Description | +| ---------- | ----------- | +| `sycl::ext::oneapi::level_zero::info::device::free_memory` | Returns the number of bytes of free memory for the device. | + + +#### 5.1.1 Free Memory Query Details ``` C++ namespace sycl{ @@ -168,15 +185,6 @@ struct free_memory { } // namespace sycl ``` -The new struct ```free_memory``` is used in conjuction with the ```get_backend_info()``` method of the ```device``` class in SYCL 2020. The query will return the number of bytes of free memory for that device. - -``` C++ -sycl::queue Queue; -auto Device = Queue.get_device(); - -uint64_t freeMemory = Device.get_backend_info(); -``` - ## Revision History |Rev|Date|Author|Changes| |-------------|:------------|:------------|:------------| From 8be88be30d8ccbfc437a6406ac876d3ac8d613ab Mon Sep 17 00:00:00 2001 From: James Brodman Date: Fri, 23 Apr 2021 13:24:25 -0400 Subject: [PATCH 4/4] Suggested edits Signed-off-by: James Brodman --- sycl/doc/extensions/LevelZeroBackend/LevelZeroBackend.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sycl/doc/extensions/LevelZeroBackend/LevelZeroBackend.md b/sycl/doc/extensions/LevelZeroBackend/LevelZeroBackend.md index 7cb8f48fe73ea..4370f7d422f46 100755 --- a/sycl/doc/extensions/LevelZeroBackend/LevelZeroBackend.md +++ b/sycl/doc/extensions/LevelZeroBackend/LevelZeroBackend.md @@ -156,15 +156,13 @@ size_t freeMemory = Device.get_backend_info(); ``` -New descriptors added as part of this specification are found in the table below: +New descriptors added as part of this specification are described in the table below and in the subsequent synopsis. | Descriptor | Description | | ---------- | ----------- | | `sycl::ext::oneapi::level_zero::info::device::free_memory` | Returns the number of bytes of free memory for the device. | -#### 5.1.1 Free Memory Query Details - ``` C++ namespace sycl{ namespace ext {