Skip to content

Commit f278298

Browse files
authored
Fix dpc_info Build (#31)
* Fix building `dpc_info`. It fails to compile on icpx versions >= 2023.2.0. * Add comments to SYCL code deprecated with no obvious replacement. * Add list of SYCL Aspects to output
1 parent b51512a commit f278298

File tree

3 files changed

+167
-13
lines changed

3 files changed

+167
-13
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.49.15
1+
0.49.16

samples/dpc_info/CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,21 @@ if(WIN32)
66
set(CMAKE_CXX_COMPILER "dpcpp-cl.exe")
77
set(CMAKE_GENERATOR_TOOLSET "Intel(R) oneAPI DPC++ Compiler")
88
else()
9-
set(CMAKE_CXX_COMPILER "dpcpp")
9+
set(CMAKE_CXX_COMPILER "icpx")
1010
endif()
1111

1212
project(PTI_Samples_DPC_Info CXX)
1313
SetCompilerFlags()
1414
SetBuildType()
1515

1616
add_executable(dpc_info main.cc)
17+
18+
if(NOT WIN32)
19+
target_compile_options(dpc_info PUBLIC -fsycl)
20+
set_target_properties(dpc_info PROPERTIES LINK_FLAGS "-fsycl")
21+
endif()
22+
1723
if(CMAKE_INCLUDE_PATH)
1824
target_include_directories(dpc_info
1925
PUBLIC "${CMAKE_INCLUDE_PATH}")
20-
endif()
26+
endif()

samples/dpc_info/main.cc

Lines changed: 158 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <string>
44
#include <vector>
55

6-
#include <CL/sycl.hpp>
6+
#include <sycl/sycl.hpp>
77

88
#define TAB std::string(" ")
99

@@ -43,6 +43,134 @@ std::string ConvertBytesToString(size_t value) {
4343
return std::to_string(value / BYTES_IN_GB) + "GiB";
4444
}
4545

46+
std::ostream& operator<<(std::ostream& out, sycl::aspect sycl_aspect) {
47+
switch (sycl_aspect) {
48+
case sycl::aspect::cpu:
49+
out << "cpu";
50+
break;
51+
case sycl::aspect::gpu:
52+
out << "gpu";
53+
break;
54+
case sycl::aspect::accelerator:
55+
out << "accelerator";
56+
break;
57+
case sycl::aspect::custom:
58+
out << "custom";
59+
break;
60+
case sycl::aspect::emulated:
61+
out << "emulated";
62+
break;
63+
case sycl::aspect::host_debuggable:
64+
out << "host_debuggable";
65+
break;
66+
case sycl::aspect::fp16:
67+
out << "fp16";
68+
break;
69+
case sycl::aspect::fp64:
70+
out << "fp64";
71+
break;
72+
case sycl::aspect::atomic64:
73+
out << "atomic64";
74+
break;
75+
case sycl::aspect::image:
76+
out << "image";
77+
break;
78+
case sycl::aspect::online_compiler:
79+
out << "online_compiler";
80+
break;
81+
case sycl::aspect::online_linker:
82+
out << "online_linker";
83+
break;
84+
case sycl::aspect::queue_profiling:
85+
out << "queue_profiling";
86+
break;
87+
case sycl::aspect::usm_device_allocations:
88+
out << "usm_device_allocations";
89+
break;
90+
case sycl::aspect::usm_host_allocations:
91+
out << "usm_host_allocations";
92+
break;
93+
case sycl::aspect::usm_atomic_host_allocations:
94+
out << "usm_atomic_host_allocations";
95+
break;
96+
case sycl::aspect::usm_shared_allocations:
97+
out << "usm_shared_allocations";
98+
break;
99+
case sycl::aspect::usm_atomic_shared_allocations:
100+
out << "usm_atomic_shared_allocations";
101+
break;
102+
case sycl::aspect::usm_system_allocations:
103+
out << "usm_system_allocations";
104+
break;
105+
#if defined(SYCL_IMPLEMENTATION_INTEL)
106+
case sycl::aspect::ext_intel_pci_address:
107+
out << "ext_intel_pci_address";
108+
break;
109+
case sycl::aspect::ext_intel_gpu_eu_count:
110+
out << "ext_intel_gpu_eu_count";
111+
break;
112+
case sycl::aspect::ext_intel_gpu_eu_simd_width:
113+
out << "ext_intel_gpu_eu_simd_width";
114+
break;
115+
case sycl::aspect::ext_intel_gpu_slices:
116+
out << "ext_intel_gpu_slices";
117+
break;
118+
case sycl::aspect::ext_intel_gpu_subslices_per_slice:
119+
out << "ext_intel_gpu_subslices_per_slice";
120+
break;
121+
case sycl::aspect::ext_intel_gpu_eu_count_per_subslice:
122+
out << "ext_intel_gpu_eu_count_per_subslice";
123+
break;
124+
case sycl::aspect::ext_intel_max_mem_bandwidth:
125+
out << "ext_intel_max_mem_bandwidth";
126+
break;
127+
case sycl::aspect::ext_intel_mem_channel:
128+
out << "ext_intel_mem_channel";
129+
break;
130+
case sycl::aspect::ext_intel_device_info_uuid:
131+
out << "ext_intel_device_info_uuid";
132+
break;
133+
case sycl::aspect::ext_intel_gpu_hw_threads_per_eu:
134+
out << "ext_intel_gpu_hw_threads_per_eu";
135+
break;
136+
case sycl::aspect::ext_intel_free_memory:
137+
out << "ext_intel_free_memory";
138+
break;
139+
case sycl::aspect::ext_intel_device_id:
140+
out << "ext_intel_device_id";
141+
break;
142+
case sycl::aspect::ext_intel_memory_clock_rate:
143+
out << "ext_intel_memory_clock_rate";
144+
break;
145+
case sycl::aspect::ext_intel_memory_bus_width:
146+
out << "ext_intel_memory_bus_width";
147+
break;
148+
#if __LIBSYCL_MAJOR_VERSION > 6
149+
case sycl::aspect::ext_intel_legacy_image:
150+
out << "ext_intel_legacy_image";
151+
break;
152+
#endif
153+
#endif
154+
#if defined(SYCL_IMPLEMENTATION_ONEAPI)
155+
case sycl::aspect::ext_oneapi_srgb:
156+
out << "ext_oneapi_srgb";
157+
break;
158+
case sycl::aspect::ext_oneapi_native_assert:
159+
out << "ext_oneapi_native_assert";
160+
break;
161+
case sycl::aspect::ext_oneapi_cuda_async_barrier:
162+
out << "ext_oneapi_cuda_async_barrier";
163+
break;
164+
case sycl::aspect::ext_oneapi_bfloat16_math_functions:
165+
out << "ext_oneapi_bfloat16_math_functions";
166+
break;
167+
#endif
168+
default:
169+
out << "<unkown-aspect: " << static_cast<std::size_t>(sycl_aspect) << ">";
170+
break;
171+
}
172+
return out;
173+
}
46174

47175
int main(int argc, char* argv[]) {
48176
bool list_mode = false;
@@ -166,13 +294,14 @@ int main(int argc, char* argv[]) {
166294
(is_avilable ? "Yes" : "No") << std::endl;
167295

168296
bool is_compiler_avilable =
169-
device.get_info<sycl::info::device::is_compiler_available>();
297+
device.has(sycl::aspect::online_compiler);
298+
170299
std::cout << std::setw(TEXT_WIDTH) << std::left <<
171300
TAB + "Compiler Available " <<
172301
(is_compiler_avilable ? "Yes" : "No") << std::endl;
173302

174303
bool is_linker_avilable =
175-
device.get_info<sycl::info::device::is_linker_available>();
304+
device.has(sycl::aspect::online_linker);
176305
std::cout << std::setw(TEXT_WIDTH) << std::left <<
177306
TAB + "Linker Available " <<
178307
(is_linker_avilable ? "Yes" : "No") << std::endl;
@@ -197,7 +326,7 @@ int main(int argc, char* argv[]) {
197326
max_work_item_dimensions << std::endl;
198327

199328
sycl::id<3> sizes =
200-
device.get_info<sycl::info::device::max_work_item_sizes>();
329+
device.get_info<sycl::info::device::max_work_item_sizes<3>>();
201330
std::cout << std::setw(TEXT_WIDTH) << std::left <<
202331
TAB + "Max work item sizes " <<
203332
sizes[0] << " x " << sizes[1] << " x " << sizes[2] << std::endl;
@@ -232,6 +361,9 @@ int main(int argc, char* argv[]) {
232361
std::cout << "Other" << std::endl;
233362
}
234363

364+
// TODO([email protected]): Deprecated, however, I do not
365+
// know a drop-in replacement.
366+
// https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#_device_information_descriptors
235367
bool preferred_interop_user_sync =
236368
device.get_info<sycl::info::device::preferred_interop_user_sync>();
237369
std::cout << std::setw(TEXT_WIDTH) << std::left <<
@@ -244,32 +376,48 @@ int main(int argc, char* argv[]) {
244376
TAB + "Profiling timer resolution " <<
245377
profiling_timer_resolution << "ns" << std::endl;
246378

379+
// TODO([email protected]): Deprecated, however, I do not
380+
// know a drop-in replacement.
381+
// https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#_device_information_descriptors
247382
size_t printf_buffer_size =
248383
device.get_info<sycl::info::device::printf_buffer_size>();
249384
std::cout << std::setw(TEXT_WIDTH) << std::left <<
250385
TAB + "printf() buffer size" << printf_buffer_size << " (" <<
251386
ConvertBytesToString(printf_buffer_size) << ")" << std::endl;
252387

253-
std::vector<std::string> built_in_kernels =
254-
device.get_info<sycl::info::device::built_in_kernels>();
388+
auto built_in_kernels =
389+
device.get_info<sycl::info::device::built_in_kernel_ids>();
255390
std::cout << std::setw(TEXT_WIDTH) << std::left <<
256391
TAB + "Built-in kernels ";
257392
for (size_t i = 0; i < built_in_kernels.size(); ++i) {
258-
std::cout << built_in_kernels[i] << " ";
393+
std::cout << built_in_kernels[i].get_name() << " ";
259394
}
260395
std::cout << std::endl;
261396

397+
// TODO([email protected]): Deprecated, however, the
398+
// suggested replacement is not 1-for-1. I added the implementation
399+
// using aspects below. Keeping this for now.
400+
// https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#_device_information_descriptors
262401
std::vector<std::string> device_extensions =
263402
device.get_info<sycl::info::device::extensions>();
264403
std::cout << std::setw(TEXT_WIDTH) << std::left <<
265404
TAB + "Device Extensions ";
266-
for (size_t i = 0; i < device_extensions.size(); ++i) {
267-
std::cout << device_extensions[i] << " ";
405+
for (const auto& device_extension : device_extensions) {
406+
std::cout << device_extension << " ";
407+
}
408+
std::cout << std::endl;
409+
410+
auto device_aspects =
411+
device.get_info<sycl::info::device::aspects>();
412+
std::cout << std::setw(TEXT_WIDTH) << std::left <<
413+
TAB + "Device Aspects ";
414+
for (const auto& device_aspect : device_aspects) {
415+
std::cout << device_aspect << " ";
268416
}
269417
std::cout << std::endl << std::endl;
270418
}
271419
}
272420
}
273421

274422
return 0;
275-
}
423+
}

0 commit comments

Comments
 (0)