Skip to content

Commit 0eeef2b

Browse files
[SYCL] Support query of free device memory extension (#6604)
Support new extension to query free device memory with info::device::ext_intel_device_info_free_memory.
1 parent 2ffd50a commit 0eeef2b

File tree

11 files changed

+331
-143
lines changed

11 files changed

+331
-143
lines changed

sycl/doc/extensions/supported/sycl_ext_intel_device_info.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ The Feature Test Macro SYCL\_EXT\_INTEL\_DEVICE\_INFO will be defined as one of
1616
| 1 | Initial extension version\. Base features are supported |
1717
| 2 | Device UUID is supported |
1818
| 3 | HW threads per EU device query is supported |
19+
| 4 | Free device memory query is supported |
1920

2021

2122
# Device UUID #
@@ -347,3 +348,41 @@ Then the maximum memory bandwidth can be obtained using the standard get\_info()
347348
if (dev.has(aspect::ext_intel_max_mem_bandwidth)) {
348349
auto maxBW = dev.get_info<info::device::ext_intel_max_mem_bandwidth>();
349350
}
351+
352+
# Free Global Memory #
353+
354+
A new device descriptor will be added which will provide the number of bytes of free global memory for the device.
355+
356+
This new device descriptor is only available for devices in the Level Zero platform, and the matching aspect is only true for those devices. The DPC++ default behavior is to expose GPU devices through the Level Zero platform. NOTE: one may need to set
357+
ZES_ENABLE_SYSMAN=1 to fully enable this extension.
358+
359+
360+
## Version ##
361+
362+
The extension supports this query in version 4 and later.
363+
364+
365+
## Device Information Descriptors ##
366+
367+
| Device Descriptors | Return Type | Description |
368+
| ------------------ | ----------- | ----------- |
369+
| info\:\:device\:\:ext\_intel\_free\_memory | uint64\_t| Returns the memory avialble on the device in units of bytes.|
370+
371+
372+
## Aspects ##
373+
374+
A new aspect, ext\_intel\_free\_memory, will be added.
375+
376+
377+
## Error Condition ##
378+
379+
An invalid object runtime error will be thrown if the device does not support aspect\:\:ext\_intel\_free\_memory.
380+
381+
382+
## Example Usage ##
383+
384+
Then the free device memory can be obtained using the standard get\_info() interface.
385+
386+
if (dev.has(aspect::ext_intel_free_memory)) {
387+
auto FreeMemory = dev.get_info<info::device::ext_intel_free_memory>();
388+
}

sycl/doc/extensions/supported/sycl_ext_oneapi_backend_level_zero.md

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -452,50 +452,6 @@ The behavior of the SYCL buffer destructor depends on the Ownership flag. As wit
452452
* If the ownership is keep (i.e. the application retains ownership of the Level Zero memory allocation), then the SYCL buffer destructor blocks until all work in queues on the buffer have completed. The buffer's contents is not copied back to the Level Zero memory allocation.
453453
* If the ownership is transfer (i.e. the SYCL runtime has ownership of the Level Zero memory allocation), then the SYCL buffer destructor does not need to block even if work on the buffer has not completed. The SYCL runtime frees the Level Zero memory allocation asynchronously when it is no longer in use in queues.
454454
455-
## 5 Level-Zero additional functionality
456-
457-
### 5.1 Device Information Descriptors
458-
The Level Zero backend provides the following device information descriptors
459-
that an application can use to query information about a Level Zero device.
460-
Applications use these queries via the `device::get_backend_info<>()` member
461-
function as shown in the example below (which illustrates the `free_memory`
462-
query):
463-
464-
``` C++
465-
sycl::queue Queue;
466-
auto Device = Queue.get_device();
467-
468-
size_t freeMemory =
469-
Device.get_backend_info<sycl::ext::oneapi::level_zero::info::device::free_memory>();
470-
```
471-
472-
New descriptors added as part of this specification are described in the table below and in the subsequent synopsis.
473-
474-
| Descriptor | Description |
475-
| ---------- | ----------- |
476-
| `sycl::ext::oneapi::level_zero::info::device::free_memory` | Returns the number of bytes of free memory for the device. |
477-
478-
479-
``` C++
480-
namespace sycl{
481-
namespace ext {
482-
namespace oneapi {
483-
namespace level_zero {
484-
namespace info {
485-
namespace device {
486-
487-
struct free_memory {
488-
using return_type = size_t;
489-
};
490-
491-
} // namespace device;
492-
} // namespace info
493-
} // namespace level_zero
494-
} // namespace oneapi
495-
} // namespace ext
496-
} // namespace sycl
497-
```
498-
499455
## Revision History
500456
|Rev|Date|Author|Changes|
501457
|-------------|:------------|:------------|:------------|
@@ -508,3 +464,4 @@ struct free_memory {
508464
|7|2021-09-13|Sergey Maslov|Updated according to SYCL 2020 standard
509465
|8|2022-01-06|Artur Gainullin|Introduced make_buffer() API
510466
|9|2022-05-12|Steffen Larsen|Added device member to queue input type
467+
|10|2022-08-18|Sergey Maslov|Moved free_memory device info query to be sycl_ext_intel_device_info extension

sycl/include/sycl/aspects.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ enum class aspect {
5151
ext_intel_gpu_hw_threads_per_eu = 33,
5252
ext_oneapi_cuda_async_barrier = 34,
5353
ext_oneapi_bfloat16 = 35,
54+
ext_intel_free_memory = 36,
5455
};
5556

5657
} // __SYCL_INLINE_VER_NAMESPACE(_V1)

sycl/include/sycl/detail/pi.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@
5050
// 10.12 Change enum value PI_MEM_ADVICE_UNKNOWN from 0 to 999, and set enum
5151
// PI_MEM_ADVISE_RESET to 0.
5252
// 10.13 Added new PI_EXT_ONEAPI_QUEUE_DISCARD_EVENTS queue property.
53+
// 10.14 Add PI_EXT_INTEL_DEVICE_INFO_FREE_MEMORY as an extension for
54+
// piDeviceGetInfo.
5355

5456
#define _PI_H_VERSION_MAJOR 10
55-
#define _PI_H_VERSION_MINOR 13
57+
#define _PI_H_VERSION_MINOR 14
5658

5759
#define _PI_STRING_HELPER(a) #a
5860
#define _PI_CONCAT(a, b) _PI_STRING_HELPER(a.b)
@@ -272,6 +274,7 @@ typedef enum {
272274
PI_DEVICE_INFO_IMAGE_SRGB = 0x10027,
273275
// Return true if sub-device should do its own program build
274276
PI_DEVICE_INFO_BUILD_ON_SUBDEVICE = 0x10028,
277+
PI_EXT_INTEL_DEVICE_INFO_FREE_MEMORY = 0x10029,
275278
PI_DEVICE_INFO_ATOMIC_64 = 0x10110,
276279
PI_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES = 0x10111,
277280
PI_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES = 0x11000,

0 commit comments

Comments
 (0)