Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit ecf1976

Browse files
committed
Small change
Signed-off-by: Rauf, Rana <[email protected]>
1 parent 1c68804 commit ecf1976

File tree

2 files changed

+132
-54
lines changed

2 files changed

+132
-54
lines changed

SYCL/Basic/intel-ext-device.cpp

Lines changed: 9 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -61,60 +61,6 @@ int main(int argc, char **argv) {
6161
std::cout << "Unknown" << std::endl;
6262
}
6363

64-
// Use Feature Test macro to see if extensions are supported.
65-
if (SYCL_EXT_INTEL_DEVICE_INFO >= 1) {
66-
67-
if (dev.has(aspect::ext_intel_pci_address)) {
68-
std::cout << "PCI address = "
69-
<< dev.get_info<info::device::ext_intel_pci_address>()
70-
<< std::endl;
71-
}
72-
if (dev.has(aspect::ext_intel_gpu_eu_count)) {
73-
totalEUs = dev.get_info<info::device::ext_intel_gpu_eu_count>();
74-
std::cout << "Number of EUs = " << totalEUs << std::endl;
75-
}
76-
if (dev.has(aspect::ext_intel_gpu_eu_simd_width)) {
77-
int w = dev.get_info<info::device::ext_intel_gpu_eu_simd_width>();
78-
std::cout << "EU SIMD width = " << w << std::endl;
79-
}
80-
if (dev.has(aspect::ext_intel_gpu_slices)) {
81-
numSlices = dev.get_info<info::device::ext_intel_gpu_slices>();
82-
std::cout << "Number of slices = " << numSlices << std::endl;
83-
}
84-
if (dev.has(aspect::ext_intel_gpu_subslices_per_slice)) {
85-
numSubslices = dev.get_info<
86-
info::device::ext_intel_gpu_subslices_per_slice>();
87-
std::cout << "Number of subslices per slice = " << numSubslices
88-
<< std::endl;
89-
}
90-
if (dev.has(aspect::ext_intel_gpu_eu_count_per_subslice)) {
91-
numEUsPerSubslice = dev.get_info<
92-
info::device::ext_intel_gpu_eu_count_per_subslice>();
93-
std::cout << "Number of EUs per subslice = " << numEUsPerSubslice
94-
<< std::endl;
95-
}
96-
if (dev.has(aspect::ext_intel_gpu_hw_threads_per_eu)) {
97-
numHWThreadsPerEU =
98-
dev.get_info<info::device::ext_intel_gpu_hw_threads_per_eu>();
99-
std::cout << "Number of HW threads per EU = " << numHWThreadsPerEU
100-
<< std::endl;
101-
}
102-
if (dev.has(aspect::ext_intel_max_mem_bandwidth)) {
103-
// not supported yet
104-
long m =
105-
dev.get_info<info::device::ext_intel_max_mem_bandwidth>();
106-
std::cout << "Maximum memory bandwidth = " << m << std::endl;
107-
}
108-
// This is the only data we can verify.
109-
if (totalEUs != numSlices * numSubslices * numEUsPerSubslice) {
110-
std::cout << "Error: EU Count is incorrect!" << std::endl;
111-
std::cout << "Failed!" << std::endl;
112-
return 1;
113-
}
114-
} // SYCL_EXT_INTEL_DEVICE_INFO
115-
116-
std::cout << "Using new api\n";
117-
11864
// Use Feature Test macro to see if extensions are supported.
11965
if (SYCL_EXT_INTEL_DEVICE_INFO >= 1) {
12066

@@ -166,9 +112,18 @@ int main(int argc, char **argv) {
166112
std::cout << "Failed!" << std::endl;
167113
return 1;
168114
}
115+
if (dev.has(aspect::ext_intel_device_info_uuid)) {
116+
auto UUID = dev.get_info<ext::intel::info::device::uuid>();
117+
std::cout << "Device UUID = ";
118+
for (int i = 0; i < 16; i++) {
119+
std::cout << std::to_string(UUID[i]);
120+
}
121+
std::cout << "\n";
122+
}
169123
} // SYCL_EXT_INTEL_DEVICE_INFO
170124
}
171125

126+
// Check if this experimental feature is supported
172127
#ifdef SYCL_EXT_ONEAPI_MAX_WORK_GROUP_QUERY
173128
sycl::id<1> groupD =
174129
dev.get_info<sycl::ext::oneapi::experimental::info::device::max_work_groups<1>>();
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
// RUN: %clangxx -fsycl %s -o %t.out
2+
// RUN: env SYCL_DEVICE_FILTER=level_zero:gpu %t.out
3+
// RUN: env SYCL_DEVICE_FILTER=opencl:gpu %t.out
4+
//
5+
// REQUIRES: gpu
6+
// UNSUPPORTED: cuda
7+
// UNSUPPORTED: hip
8+
// Temporarily disable on L0 due to fails in CI
9+
// UNSUPPORTED: level_zero
10+
11+
//==--------- intel-ext-device.cpp - SYCL device test ------------==//
12+
//
13+
// Returns the low-level device details. These are Intel-specific extensions
14+
// that are only supported on Level Zero.
15+
//
16+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
17+
// See https://llvm.org/LICENSE.txt for license information.
18+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
19+
//
20+
//===----------------------------------------------------------------------===//
21+
22+
#include <sycl/sycl.hpp>
23+
24+
#include <cassert>
25+
#include <iostream>
26+
27+
using namespace sycl;
28+
29+
#ifdef _WIN32
30+
#define setenv(name, value, overwrite) _putenv_s(name, value)
31+
#endif
32+
33+
int main(int argc, char **argv) {
34+
// Must be enabled at the beginning of the application
35+
// to obtain the PCI address
36+
setenv("SYCL_ENABLE_PCI", "1", 0);
37+
38+
int pltCount = 1;
39+
for (const auto &plt : platform::get_platforms()) {
40+
if (!plt.has(aspect::host)) {
41+
int devCount = 1;
42+
int totalEUs = 0;
43+
int numSlices = 0;
44+
int numSubslices = 0;
45+
int numEUsPerSubslice = 0;
46+
int numHWThreadsPerEU = 0;
47+
for (const auto &dev : plt.get_devices()) {
48+
std::cout << "Platform #" << pltCount++ << ":" << std::endl;
49+
if (dev.has(aspect::gpu)) {
50+
auto name = dev.get_info<info::device::name>();
51+
std::cout << "Device #" << devCount++ << ": "
52+
<< dev.get_info<info::device::name>() << ":" << std::endl;
53+
54+
std::cout << "Backend: ";
55+
if (plt.get_backend() == backend::ext_oneapi_level_zero) {
56+
std::cout << "Level Zero" << std::endl;
57+
} else if (plt.get_backend() == backend::opencl) {
58+
std::cout << "OpenCL" << std::endl;
59+
} else if (plt.get_backend() == backend::ext_oneapi_cuda) {
60+
std::cout << "CUDA" << std::endl;
61+
} else {
62+
std::cout << "Unknown" << std::endl;
63+
}
64+
65+
// Use Feature Test macro to see if extensions are supported.
66+
if (SYCL_EXT_INTEL_DEVICE_INFO >= 1) {
67+
68+
if (dev.has(aspect::ext_intel_pci_address)) {
69+
std::cout << "PCI address = "
70+
<< dev.get_info<info::device::ext_intel_pci_address>()
71+
<< std::endl;
72+
}
73+
if (dev.has(aspect::ext_intel_gpu_eu_count)) {
74+
totalEUs = dev.get_info<info::device::ext_intel_gpu_eu_count>();
75+
std::cout << "Number of EUs = " << totalEUs << std::endl;
76+
}
77+
if (dev.has(aspect::ext_intel_gpu_eu_simd_width)) {
78+
int w = dev.get_info<info::device::ext_intel_gpu_eu_simd_width>();
79+
std::cout << "EU SIMD width = " << w << std::endl;
80+
}
81+
if (dev.has(aspect::ext_intel_gpu_slices)) {
82+
numSlices = dev.get_info<info::device::ext_intel_gpu_slices>();
83+
std::cout << "Number of slices = " << numSlices << std::endl;
84+
}
85+
if (dev.has(aspect::ext_intel_gpu_subslices_per_slice)) {
86+
numSubslices = dev.get_info<
87+
info::device::ext_intel_gpu_subslices_per_slice>();
88+
std::cout << "Number of subslices per slice = " << numSubslices
89+
<< std::endl;
90+
}
91+
if (dev.has(aspect::ext_intel_gpu_eu_count_per_subslice)) {
92+
numEUsPerSubslice = dev.get_info<
93+
info::device::ext_intel_gpu_eu_count_per_subslice>();
94+
std::cout << "Number of EUs per subslice = " << numEUsPerSubslice
95+
<< std::endl;
96+
}
97+
if (dev.has(aspect::ext_intel_gpu_hw_threads_per_eu)) {
98+
numHWThreadsPerEU =
99+
dev.get_info<info::device::ext_intel_gpu_hw_threads_per_eu>();
100+
std::cout << "Number of HW threads per EU = " << numHWThreadsPerEU
101+
<< std::endl;
102+
}
103+
if (dev.has(aspect::ext_intel_max_mem_bandwidth)) {
104+
// not supported yet
105+
long m =
106+
dev.get_info<info::device::ext_intel_max_mem_bandwidth>();
107+
std::cout << "Maximum memory bandwidth = " << m << std::endl;
108+
}
109+
// This is the only data we can verify.
110+
if (totalEUs != numSlices * numSubslices * numEUsPerSubslice) {
111+
std::cout << "Error: EU Count is incorrect!" << std::endl;
112+
std::cout << "Failed!" << std::endl;
113+
return 1;
114+
}
115+
} // SYCL_EXT_INTEL_DEVICE_INFO
116+
}
117+
std::cout << std::endl;
118+
}
119+
}
120+
}
121+
std::cout << "Passed!" << std::endl;
122+
return 0;
123+
}

0 commit comments

Comments
 (0)