Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCL] Add ext_intel_device_id to sycl_ext_intel_device_info #7010

Merged
merged 1 commit into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions sycl/doc/extensions/supported/sycl_ext_intel_device_info.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,44 @@ The Feature Test Macro SYCL\_EXT\_INTEL\_DEVICE\_INFO will be defined as one of
| 2 | Device UUID is supported |
| 3 | HW threads per EU device query is supported |
| 4 | Free device memory query is supported |
| 5 | Device ID is supported |



# Device ID #

A new device descriptor will be added which will provide the device ID.

If the implementation is driven primarily by a PCI device with a PCI device ID, the device ID must be that PCI device ID. Otherwise, the choice of what to return may be dictated by operating system or platform policies - but should uniquely identify both the device version and any major configuration options (for example, core count in the case of multi-core devices).

## Version ##

The extension supports this query in version 5 and later.

## Device Information Descriptors ##

| Device Descriptors | Return Type | Description |
| ------------------ | ----------- | ----------- |
| ext\:\:intel\:\:info\:\:device\:\:device\_id | uint32\_t| Returns the device ID.|


## Aspects ##

A new aspect, ext\_intel\_device\_id, will be added.


## Error Condition ##

An invalid object runtime error will be thrown if the device does not support aspect\:\:ext\_intel\_device\_id.

## Example Usage ##

The device ID can be obtained using the standard get\_info() interface.

if (dev.has(aspect::ext_intel_device_id)) {
auto deviceID = dev.get_info<ext::intel::info::device::device_id>();
}



# Device UUID #
Expand Down
1 change: 1 addition & 0 deletions sycl/include/sycl/detail/pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ typedef enum {
// Intel UUID extension.
PI_DEVICE_INFO_UUID = 0x106A,
// These are Intel-specific extensions.
PI_DEVICE_INFO_DEVICE_ID = 0x4251,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value here is the same as the value of CL_DEVICE_ID_INTEL which is defined in the OpenCL extension cl_intel_device_attribute_query. I presume the intention is that the OpenCL plugin doesn't need any changes because we can pass PI_DEVICE_INFO_DEVICE_ID in place of CL_DEVICE_ID_INTEL and it will just work.

However, I don't see any code checking to see if the OpenCL implementation supports the cl_intel_device_attribute_query extension. Is that consistent with the way we use other OpenCL extensions? Do we just assume that OpenCL supports whatever extension we need without checking?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clGetDeviceInfo states that it returns

CL_​INVALID_​VALUE if param_name is not one of the supported values or if size in bytes specified by param_value_size is < size of return type as specified in the Device Queries table and param_value is not a NULL value or if param_name is a value that is available as an extension and the corresponding extension is not supported by the device.

The runtime uses this to determine if the aspect for each of the extension descriptors is supported or not. So OpenCL should be ready out-of-the-gate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I presume the intention is that the OpenCL plugin doesn't need any changes because we can pass PI_DEVICE_INFO_DEVICE_ID in place of CL_DEVICE_ID_INTEL and it will just work.

Yes, that is the intention.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is the intention.

I think it should be documented in the sources somehow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please be a bit more specific about what kind of documentation do you expect here? Most other constants in pi.h also map to an OpenCL parameter the same way, some of them are part of the core OpenCL but many others map to extensions. Neither of those are documented. So there's nothing new in the way PI_DEVICE_INFO_DEVICE_ID works here. I followed the conventions of the existing codebase.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, OK. I was under a wrong impression that we are only mapping PI to CL values in the OpenCL plugin, and this new one had a direct CL value used, which I thought needs a documentation. Nevermind.

PI_DEVICE_INFO_PCI_ADDRESS = 0x10020,
PI_DEVICE_INFO_GPU_EU_COUNT = 0x10021,
PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH = 0x10022,
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/sycl/feature_test.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ __SYCL_INLINE_VER_NAMESPACE(_V1) {
// Feature test macro definitions

// TODO: Move these feature-test macros to compiler driver.
#define SYCL_EXT_INTEL_DEVICE_INFO 3
#define SYCL_EXT_INTEL_DEVICE_INFO 5
#define SYCL_EXT_ONEAPI_SUB_GROUP_MASK 1
#define SYCL_EXT_ONEAPI_LOCAL_MEMORY 1
// As for SYCL_EXT_ONEAPI_MATRIX:
Expand Down
1 change: 1 addition & 0 deletions sycl/include/sycl/info/aspects.def
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ __SYCL_ASPECT(ext_intel_gpu_hw_threads_per_eu, 33)
__SYCL_ASPECT(ext_oneapi_cuda_async_barrier, 34)
__SYCL_ASPECT(ext_oneapi_bfloat16, 35)
__SYCL_ASPECT(ext_intel_free_memory, 36)
__SYCL_ASPECT(ext_intel_device_id, 37)
1 change: 1 addition & 0 deletions sycl/include/sycl/info/ext_intel_device_traits.def
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define __SYCL_PARAM_TRAITS_TEMPLATE_SPEC_NEEDS_UNDEF
#define __SYCL_PARAM_TRAITS_TEMPLATE_SPEC __SYCL_PARAM_TRAITS_SPEC
#endif
__SYCL_PARAM_TRAITS_SPEC(ext::intel, device, device_id, pi_uint32, PI_DEVICE_INFO_DEVICE_ID)
__SYCL_PARAM_TRAITS_SPEC(ext::intel, device, pci_address, std::string, PI_DEVICE_INFO_PCI_ADDRESS)
__SYCL_PARAM_TRAITS_SPEC(ext::intel, device, gpu_eu_count, pi_uint32, PI_DEVICE_INFO_GPU_EU_COUNT)
__SYCL_PARAM_TRAITS_SPEC(ext::intel, device, gpu_eu_simd_width, pi_uint32, PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH)
Expand Down
1 change: 1 addition & 0 deletions sycl/plugins/cuda/pi_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1928,6 +1928,7 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name,
}

// TODO: Investigate if this information is available on CUDA.
case PI_DEVICE_INFO_DEVICE_ID:
case PI_DEVICE_INFO_PCI_ADDRESS:
case PI_DEVICE_INFO_GPU_EU_COUNT:
case PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH:
Expand Down
1 change: 1 addition & 0 deletions sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName,
CASE_PI_UNSUPPORTED(PI_DEVICE_INFO_IL_VERSION)

// Intel-specific extensions
CASE_PI_UNSUPPORTED(PI_DEVICE_INFO_DEVICE_ID)
CASE_PI_UNSUPPORTED(PI_DEVICE_INFO_PCI_ADDRESS)
CASE_PI_UNSUPPORTED(PI_DEVICE_INFO_GPU_EU_COUNT)
CASE_PI_UNSUPPORTED(PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH)
Expand Down
1 change: 1 addition & 0 deletions sycl/plugins/hip/pi_hip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1819,6 +1819,7 @@ pi_result hip_piDeviceGetInfo(pi_device device, pi_device_info param_name,
case PI_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES:
// TODO: Investigate if this information is available on HIP.
case PI_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES:
case PI_DEVICE_INFO_DEVICE_ID:
case PI_DEVICE_INFO_PCI_ADDRESS:
case PI_DEVICE_INFO_GPU_EU_COUNT:
case PI_DEVICE_INFO_GPU_EU_SIMD_WIDTH:
Expand Down
3 changes: 3 additions & 0 deletions sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3141,6 +3141,9 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName,
}

// intel extensions for GPU information
case PI_DEVICE_INFO_DEVICE_ID:
return ReturnValue(
pi_uint32{Device->ZeDeviceProperties->deviceId});
case PI_DEVICE_INFO_PCI_ADDRESS: {
if (getenv("ZES_ENABLE_SYSMAN") == nullptr) {
zePrint("Set SYCL_ENABLE_PCI=1 to obtain PCI data.\n");
Expand Down
4 changes: 4 additions & 0 deletions sycl/source/detail/device_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ bool device_impl::has(aspect Aspect) const {
return get_info<info::device::usm_restricted_shared_allocations>();
case aspect::usm_system_allocations:
return get_info<info::device::usm_system_allocations>();
case aspect::ext_intel_device_id:
return getPlugin().call_nocheck<detail::PiApiKind::piDeviceGetInfo>(
MDevice, PI_DEVICE_INFO_DEVICE_ID, 0,
nullptr, &return_size) == PI_SUCCESS;
case aspect::ext_intel_pci_address:
return getPlugin().call_nocheck<detail::PiApiKind::piDeviceGetInfo>(
MDevice, PI_DEVICE_INFO_PCI_ADDRESS, 0, nullptr, &return_size) ==
Expand Down
7 changes: 7 additions & 0 deletions sycl/source/detail/device_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,13 @@ inline bool get_device_info_host<info::device::ext_intel_mem_channel>() {
// Specializations for intel extensions for Level Zero low-level
// detail device descriptors (not support on host).
template <>
inline uint32_t
get_device_info_host<ext::intel::info::device::device_id>() {
throw runtime_error(
"Obtaining the device ID is not supported on HOST device",
PI_ERROR_INVALID_DEVICE);
}
template <>
gmlueck marked this conversation as resolved.
Show resolved Hide resolved
inline std::string
get_device_info_host<ext::intel::info::device::pci_address>() {
throw runtime_error(
Expand Down
1 change: 1 addition & 0 deletions sycl/test/abi/sycl_symbols_linux.dump
Original file line number Diff line number Diff line change
Expand Up @@ -4162,6 +4162,7 @@ _ZNK4sycl3_V16device8get_infoINS0_3ext5intel4info6device21gpu_hw_threads_per_euE
_ZNK4sycl3_V16device8get_infoINS0_3ext5intel4info6device23gpu_subslices_per_sliceEEENS0_6detail19is_device_info_descIT_E11return_typeEv
_ZNK4sycl3_V16device8get_infoINS0_3ext5intel4info6device25gpu_eu_count_per_subsliceEEENS0_6detail19is_device_info_descIT_E11return_typeEv
_ZNK4sycl3_V16device8get_infoINS0_3ext5intel4info6device4uuidEEENS0_6detail19is_device_info_descIT_E11return_typeEv
_ZNK4sycl3_V16device8get_infoINS0_3ext5intel4info6device9device_idEEENS0_6detail19is_device_info_descIT_E11return_typeEv
_ZNK4sycl3_V16device8get_infoINS0_3ext6oneapi12experimental4info6device15max_work_groupsILi1EEEEENS0_6detail19is_device_info_descIT_E11return_typeEv
_ZNK4sycl3_V16device8get_infoINS0_3ext6oneapi12experimental4info6device15max_work_groupsILi2EEEEENS0_6detail19is_device_info_descIT_E11return_typeEv
_ZNK4sycl3_V16device8get_infoINS0_3ext6oneapi12experimental4info6device15max_work_groupsILi3EEEEENS0_6detail19is_device_info_descIT_E11return_typeEv
Expand Down
1 change: 1 addition & 0 deletions sycl/test/abi/sycl_symbols_windows.dump
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
??$get_info@Ucontext@kernel@info@_V1@sycl@@@kernel@_V1@sycl@@QEBA?AVcontext@12@XZ
??$get_info@Ucontext@queue@info@_V1@sycl@@@queue@_V1@sycl@@QEBA?AVcontext@12@XZ
??$get_info@Udevice@queue@info@_V1@sycl@@@queue@_V1@sycl@@QEBA?AVdevice@12@XZ
??$get_info@Udevice_id@device@info@intel@ext@_V1@sycl@@@device@_V1@sycl@@QEBAIXZ
??$get_info@Udevice_type@device@info@_V1@sycl@@@device@_V1@sycl@@QEBA?AW4device_type@info@12@XZ
??$get_info@Udevices@context@info@_V1@sycl@@@context@_V1@sycl@@QEBA?AV?$vector@Vdevice@_V1@sycl@@V?$allocator@Vdevice@_V1@sycl@@@std@@@std@@XZ
??$get_info@Udouble_fp_config@device@info@_V1@sycl@@@device@_V1@sycl@@QEBA?AV?$vector@W4fp_config@info@_V1@sycl@@V?$allocator@W4fp_config@info@_V1@sycl@@@std@@@std@@XZ
Expand Down