|
17 | 17 | #include <cstdio>
|
18 | 18 | #include <cstring>
|
19 | 19 | #include <memory>
|
| 20 | +#include <sstream> |
20 | 21 | #include <string>
|
21 | 22 | #include <thread>
|
22 | 23 | #include <utility>
|
23 | 24 |
|
| 25 | +#include <level_zero/zes_api.h> |
24 | 26 | #include <level_zero/zet_api.h>
|
25 | 27 |
|
26 | 28 | #include "usm_allocator.hpp"
|
@@ -786,6 +788,12 @@ pi_result piPlatformsGet(pi_uint32 NumEntries, pi_platform *Platforms,
|
786 | 788 | setEnvVar("ZE_ENABLE_PARAMETER_VALIDATION", "1");
|
787 | 789 | }
|
788 | 790 |
|
| 791 | + // Enable SYSMAN support for obtaining the PCI address |
| 792 | + // and maximum memory bandwidth. |
| 793 | + if (getenv("SYCL_ENABLE_PCI") != nullptr) { |
| 794 | + setEnvVar("ZES_ENABLE_SYSMAN", "1"); |
| 795 | + } |
| 796 | + |
789 | 797 | // TODO: We can still safely recover if something goes wrong during the init.
|
790 | 798 | // Implement handling segfault using sigaction.
|
791 | 799 |
|
@@ -1578,6 +1586,42 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName,
|
1578 | 1586 | }
|
1579 | 1587 | return ReturnValue(Supported);
|
1580 | 1588 | }
|
| 1589 | + |
| 1590 | + // intel extensions for GPU information |
| 1591 | + case PI_DEVICE_INFO_PCI_ADDRESS: { |
| 1592 | + if (getenv("ZES_ENABLE_SYSMAN") == nullptr) { |
| 1593 | + zePrint("Set SYCL_ENABLE_PCI=1 to obtain PCI data.\n"); |
| 1594 | + return PI_INVALID_VALUE; |
| 1595 | + } |
| 1596 | + zes_pci_properties_t ZeDevicePciProperties = {}; |
| 1597 | + ZE_CALL(zesDevicePciGetProperties(ZeDevice, &ZeDevicePciProperties)); |
| 1598 | + std::stringstream ss; |
| 1599 | + ss << ZeDevicePciProperties.address.domain << ":" |
| 1600 | + << ZeDevicePciProperties.address.bus << ":" |
| 1601 | + << ZeDevicePciProperties.address.device << "." |
| 1602 | + << ZeDevicePciProperties.address.function; |
| 1603 | + return ReturnValue(ss.str().c_str()); |
| 1604 | + } |
| 1605 | + case PI_DEVICE_INFO_GPU_EU_COUNT: { |
| 1606 | + pi_uint32 count = Device->ZeDeviceProperties.numEUsPerSubslice * |
| 1607 | + Device->ZeDeviceProperties.numSubslicesPerSlice * |
| 1608 | + Device->ZeDeviceProperties.numSlices; |
| 1609 | + return ReturnValue(pi_uint32{count}); |
| 1610 | + } |
| 1611 | + case PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH: |
| 1612 | + return ReturnValue( |
| 1613 | + pi_uint32{Device->ZeDeviceProperties.physicalEUSimdWidth}); |
| 1614 | + case PI_DEVICE_INFO_GPU_SLICES: |
| 1615 | + return ReturnValue(pi_uint32{Device->ZeDeviceProperties.numSlices}); |
| 1616 | + case PI_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE: |
| 1617 | + return ReturnValue( |
| 1618 | + pi_uint32{Device->ZeDeviceProperties.numSubslicesPerSlice}); |
| 1619 | + case PI_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE: |
| 1620 | + return ReturnValue(pi_uint32{Device->ZeDeviceProperties.numEUsPerSubslice}); |
| 1621 | + case PI_DEVICE_INFO_MAX_MEM_BANDWIDTH: |
| 1622 | + // currently not supported in level zero runtime |
| 1623 | + return PI_INVALID_VALUE; |
| 1624 | + |
1581 | 1625 | default:
|
1582 | 1626 | zePrint("Unsupported ParamName in piGetDeviceInfo\n");
|
1583 | 1627 | zePrint("ParamName=%d(0x%x)\n", ParamName, ParamName);
|
|
0 commit comments