Skip to content

Commit e9a62d6

Browse files
committed
Add cuda luid test
1 parent 80fb7d6 commit e9a62d6

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// REQUIREddS: aspect-ext_intel_device_info_luid
2+
// REQUIREddS: gpu, cuda, cuda_dev_kit, windows
3+
4+
// RUN: %{build} %cuda_options -o %t.out
5+
// RUN: %{run} %t.out
6+
7+
// Test that the LUID is read correctly from Level Zero.
8+
9+
#include <iomanip>
10+
#include <iostream>
11+
#include <sstream>
12+
#define SYCL_EXT_ONEAPI_BACKEND_CUDA_EXPERIMENTAL 1
13+
#include <cuda.h>
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 luidSYCLHex;
22+
for (int i = 0; i < luid.size(); ++i) {
23+
luidSYCLHex << std::hex << std::setw(2) << std::setfill('0')
24+
<< int(luid[i]);
25+
}
26+
std::cout << "SYCL: " << luidSYCLHex.str() << std::endl;
27+
28+
CUdevice cudaDevice = sycl::get_native<sycl::backend::ext_oneapi_cuda>(dev);
29+
30+
char *luidCuda = nullptr;
31+
32+
cuDeviceGetLuid(luidCuda, nullptr, cudaDevice);
33+
34+
std::stringstream luidCudaHex;
35+
for (int i = 0; i < 8; ++i)
36+
luidCudaHex << std::hex << std::setw(2) << std::setfill('0')
37+
<< int(luidCuda[i]);
38+
std::cout << "CUDA : " << luidCudaHex.str() << std::endl;
39+
40+
if (luidSYCLHex.str() != luidCudaHex.str()) {
41+
std::cout << "FAILED" << std::endl;
42+
return -1;
43+
}
44+
45+
std::cout << "PASSED" << std::endl;
46+
return 0;
47+
}

0 commit comments

Comments
 (0)