|
| 1 | +// REQUIRES: aspect-ext_intel_device_info_luid |
| 2 | +// REQUIRES: gpu, level_zero, level_zero_dev_kit, windows |
| 3 | + |
| 4 | +// RUN: %{build} %level_zero_options -o %t.out |
| 5 | +// RUN: %{run} %t.out 2>&1 | FileCheck %s |
| 6 | + |
| 7 | +// Test that the LUID is read correctly from Level Zero. |
| 8 | + |
| 9 | +// CHECK: PASSED |
| 10 | +#include <iomanip> |
| 11 | +#include <iostream> |
| 12 | +#include <level_zero/ze_api.h> |
| 13 | +#include <sstream> |
| 14 | +#include <sycl/backend.hpp> |
| 15 | +#include <sycl/detail/core.hpp> |
| 16 | + |
| 17 | +int main() { |
| 18 | + sycl::device dev; |
| 19 | + auto luid = dev.get_info<sycl::ext::intel::info::device::luid>(); |
| 20 | + |
| 21 | + std::stringstream luid_sycl; |
| 22 | + for (int i = 0; i < luid.size(); ++i) { |
| 23 | + luid_sycl << std::hex << std::setw(2) << std::setfill('0') << int(luid[i]); |
| 24 | + } |
| 25 | + std::cout << "SYCL: " << luid_sycl.str() << std::endl; |
| 26 | + |
| 27 | + auto zedev = sycl::get_native<sycl::backend::ext_oneapi_level_zero>(dev); |
| 28 | + ze_device_properties_t device_properties{}; |
| 29 | + device_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES; |
| 30 | + |
| 31 | + ze_device_luid_ext_properties_t luid_device_properties{}; |
| 32 | + luid_device_properties.stype = ZE_STRUCTURE_TYPE_DEVICE_LUID_EXT_PROPERTIES; |
| 33 | + |
| 34 | + device_properties.pNext = &luid_device_properties; |
| 35 | + |
| 36 | + zeDeviceGetProperties(zedev, &device_properties); |
| 37 | + |
| 38 | + ze_device_luid_ext_properties_t *luid_dev_prop = |
| 39 | + static_cast<ze_device_luid_ext_properties_t *>(device_properties.pNext); |
| 40 | + |
| 41 | + std::stringstream luid_l0; |
| 42 | + for (int i = 0; i < ZE_MAX_DEVICE_LUID_SIZE_EXT; ++i) |
| 43 | + luid_l0 << std::hex << std::setw(2) << std::setfill('0') |
| 44 | + << int(luid_dev_prop->luid.id[i]); |
| 45 | + std::cout << "L0 : " << luid_l0.str() << std::endl; |
| 46 | + |
| 47 | + if (luid_sycl.str() != luid_l0.str()) { |
| 48 | + std::cout << "FAILED" << std::endl; |
| 49 | + return -1; |
| 50 | + } |
| 51 | + |
| 52 | + std::cout << "PASSED" << std::endl; |
| 53 | + return 0; |
| 54 | +} |
0 commit comments