Skip to content

Commit 166eeba

Browse files
authored
Fix Warnings After Switching to oneAPI 2024.0 release (#43)
* Fix warnings in SYCL code due to icpx/libsycl upgrade. * Most of these are due to SYCL 2020 spec deprecations (e.g. `get_pointer` -> `get_multi_ptr`). * Prevent dlworkload from crashing but provide notice it is not working as expected. Signed-off-by: Schilling, Matthew <[email protected]>
1 parent 4700b32 commit 166eeba

File tree

13 files changed

+85
-77
lines changed

13 files changed

+85
-77
lines changed

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
**/build
22
**/__pycache__
3+
build*/
4+
venv/
5+
.vscode/
6+
.vim/
7+
.cache/
8+
compile_commands.json
9+
CMakeUserPresets.json
10+
error_diff.txt

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.49.19
1+
0.49.20

samples/dpc_gemm/CMakeLists.txt

+8-4
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,23 @@ 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_GEMM CXX)
1313
SetCompilerFlags()
1414
SetBuildType()
1515

16-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -gline-tables-only")
17-
1816
add_executable(dpc_gemm main.cc)
17+
18+
target_compile_options(dpc_gemm PUBLIC -fsycl -gline-tables-only)
19+
20+
# target_link_options CMake >= 3.13
21+
set_target_properties(dpc_gemm PROPERTIES LINK_FLAGS "-fsycl -gline-tables-only")
22+
1923
target_include_directories(dpc_gemm
2024
PRIVATE "${PROJECT_SOURCE_DIR}/../../utils")
2125
if(CMAKE_INCLUDE_PATH)
2226
target_include_directories(dpc_gemm
2327
PUBLIC "${CMAKE_INCLUDE_PATH}")
24-
endif()
28+
endif()

samples/dpc_gemm/main.cc

+24-20
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include "utils.h"
1212

13-
#include <CL/sycl.hpp>
13+
#include <sycl/sycl.hpp>
1414

1515
#define A_VALUE 0.128f
1616
#define B_VALUE 0.256f
@@ -63,9 +63,12 @@ static float RunAndCheck(sycl::queue queue,
6363

6464
cgh.parallel_for<class __GEMM>(sycl::range<2>(size, size),
6565
[=](sycl::id<2> id) {
66-
GEMM(a_acc.get_pointer(),
67-
b_acc.get_pointer(),
68-
c_acc.get_pointer(),
66+
auto a_acc_ptr = a_acc.get_multi_ptr<sycl::access::decorated::no>();
67+
auto b_acc_ptr = b_acc.get_multi_ptr<sycl::access::decorated::no>();
68+
auto c_acc_ptr = c_acc.get_multi_ptr<sycl::access::decorated::no>();
69+
GEMM(a_acc_ptr.get(),
70+
b_acc_ptr.get(),
71+
c_acc_ptr.get(),
6972
size, id);
7073
});
7174
});
@@ -101,11 +104,21 @@ static void Compute(sycl::queue queue,
101104
}
102105

103106
int main(int argc, char* argv[]) {
104-
sycl::info::device_type device_type = sycl::info::device_type::gpu;
105-
if (argc > 1 && strcmp(argv[1], "cpu") == 0) {
106-
device_type = sycl::info::device_type::cpu;
107-
} else if (argc > 1 && strcmp(argv[1], "host") == 0) {
108-
device_type = sycl::info::device_type::host;
107+
sycl::device dev;
108+
try {
109+
dev = sycl::device(sycl::gpu_selector_v);
110+
if (argc > 1 && strcmp(argv[1], "cpu") == 0) {
111+
dev = sycl::device(sycl::cpu_selector_v);
112+
} else if (argc > 1 && strcmp(argv[1], "host") == 0) {
113+
dev = sycl::device(sycl::default_selector_v);
114+
}
115+
} catch (const sycl::exception& e) {
116+
std::cerr << "Error: Exception caught while executing SYCL " << e.what() << '\n';
117+
std::cerr << "Unable to select valid sycl device" << '\n';
118+
return EXIT_FAILURE;
119+
} catch (...) {
120+
std::cerr << "Unable to select valid sycl device" << '\n';
121+
return EXIT_FAILURE;
109122
}
110123

111124
unsigned size = 1024;
@@ -118,17 +131,8 @@ int main(int argc, char* argv[]) {
118131
repeat_count = std::stoul(argv[3]);
119132
}
120133

121-
std::unique_ptr<sycl::device_selector> selector(nullptr);
122-
if (device_type == sycl::info::device_type::cpu) {
123-
selector.reset(new sycl::cpu_selector);
124-
} else if (device_type == sycl::info::device_type::gpu) {
125-
selector.reset(new sycl::gpu_selector);
126-
} else if (device_type == sycl::info::device_type::host) {
127-
selector.reset(new sycl::host_selector);
128-
}
129-
130134
sycl::property_list prop_list{sycl::property::queue::enable_profiling()};
131-
sycl::queue queue(*selector.get(), sycl::async_handler{}, prop_list);
135+
sycl::queue queue(dev, sycl::async_handler{}, prop_list);
132136

133137
std::cout << "DPC++ Matrix Multiplication (matrix size: " << size <<
134138
" x " << size << ", repeats " << repeat_count << " times)" << std::endl;
@@ -148,4 +152,4 @@ int main(int argc, char* argv[]) {
148152

149153
std::cout << "Total execution time: " << time.count() << " sec" << std::endl;
150154
return 0;
151-
}
155+
}

samples/dpc_info/main.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ std::ostream& operator<<(std::ostream& out, sycl::aspect sycl_aspect) {
166166
break;
167167
#endif
168168
default:
169-
out << "<unkown-aspect: " << static_cast<std::size_t>(sycl_aspect) << ">";
169+
out << "<unknown-aspect: " << static_cast<std::size_t>(sycl_aspect) << ">";
170170
break;
171171
}
172172
return out;

sdk/samples/dlworkloads/main.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ void PrintUsage()
2121
std::cout << "It is a largely simpilified application to demo mixed programming ";
2222
std::cout << "on Intel GPU for deep learning (PyTorch&TensorFlow) workloads (ITEX&IPEX) ";
2323
std::cout << "with direct dpcpp kernel, onednn, onemkl, onedpl, onemkl, eigen, etc." << std::endl;
24-
std::cout << "IPEX: https://github.com/intel-innersource/frameworks.ai.pytorch.ipex-gpu" << std::endl;
25-
std::cout << "ITEX: https://github.com/intel-innersource/frameworks.ai.infrastructure.intel-extension-for-tensorflow.intel-extension-for-tensorflow" << std::endl;
24+
std::cout << "IPEX: https://github.com/intel/intel-extension-for-pytorch" << std::endl;
2625
std::cout << std::endl;
2726
std::cout << "The purpose of this application is to provide a basic rough requirement for sycl graph capture mode." << std::endl;
2827
std::cout << std::endl;
@@ -39,6 +38,9 @@ void PrintUsage()
3938
std::cout << std::endl;
4039
std::cout << "It is supposed that this application will be updated frequently, so this might be not the latest one." << std::endl;
4140
std::cout << std::endl;
41+
#if __LIBSYCL_MAJOR_VERSION >= 7
42+
std::cerr << "Notice: A portion of this sample was not build. To build the whole sample, revert to older oneAPI release (<= 2023.2.0)" << std::endl;
43+
#endif
4244
}
4345

4446
void run(sycl::queue *q)

sdk/samples/dlworkloads/model_mixedprogramming.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@ TinyTensor run_model_mixedprogramming(TinyTensor inp, sycl::queue *q)
1515
TinyTensor outp = run_syclkernel_operation_scaledown(inp, q);
1616
GlobalDeviceMemoryManager().free(inp.data);
1717

18+
// TODO([email protected]): Fails when run with XPTI tracing. We
19+
// need to figure out a way to uncomment this. It crashes PTI-SDK and
20+
// Unitrace built with OneAPI/ICPX >= 2024.0.0 .
1821
// the next operation uses oneDNN for conv2d
22+
#if __LIBSYCL_MAJOR_VERSION < 7
1923
inp = outp;
2024
outp = run_onednn_operation_conv2d(inp, q);
2125
GlobalDeviceMemoryManager().free(inp.data);
26+
#endif
2227

2328
// next operation uses oneMKL
2429
inp = outp;

sdk/samples/dpc_gemm/main.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ static float RunAndCheck(sycl::queue queue, const std::vector<float> &a,
8080

8181
cgh.parallel_for<class __GEMM>(
8282
sycl::range<2>(size, size), [=](sycl::id<2> id) {
83-
GEMM(a_acc.get_pointer(), b_acc.get_pointer(), c_acc.get_pointer(),
84-
size, id);
83+
auto a_acc_ptr = a_acc.get_multi_ptr<sycl::access::decorated::no>();
84+
auto b_acc_ptr = b_acc.get_multi_ptr<sycl::access::decorated::no>();
85+
auto c_acc_ptr = c_acc.get_multi_ptr<sycl::access::decorated::no>();
86+
GEMM(a_acc_ptr.get(), b_acc_ptr.get(), c_acc_ptr.get(), size, id);
8587
});
8688
});
8789
queue.wait_and_throw();

sdk/samples/dpc_gemm_threaded/main.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ static float RunAndCheck(sycl::queue queue, const std::vector<float>& a,
6868

6969
cgh.parallel_for<class __GEMM>(
7070
sycl::range<2>(size, size), [=](sycl::id<2> id) {
71-
GEMM(a_acc.get_pointer(),b_acc.get_pointer(),c_acc.get_pointer(),
72-
size, id);
71+
auto a_acc_ptr = a_acc.get_multi_ptr<sycl::access::decorated::no>();
72+
auto b_acc_ptr = b_acc.get_multi_ptr<sycl::access::decorated::no>();
73+
auto c_acc_ptr = c_acc.get_multi_ptr<sycl::access::decorated::no>();
74+
GEMM(a_acc_ptr.get(), b_acc_ptr.get(), c_acc_ptr.get(), size, id);
7375
});
7476
});
7577
queue.wait_and_throw();

sdk/samples/iso3dfd_dpcpp/src/iso3dfd_kernels.cpp

+21-13
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ void Iso3dfdIterationSLM(sycl::nd_item<3> &it, float *next, float *prev,
196196
*
197197
*/
198198
void Iso3dfdIterationGlobal(sycl::nd_item<3> &it, float *next, float *prev,
199-
float *vel, const float *coeff, int nx, int nxy,
199+
const float *vel, const float *coeff, int nx, int nxy,
200200
int bx, int by, int z_offset, int full_end_z) {
201201
// We compute the start and the end position in the grid
202202
// for each work-item.
@@ -381,17 +381,17 @@ bool Iso3dfdDevice(sycl::queue &q, float *ptr_next, float *ptr_prev,
381381
if (i % 2 == 0)
382382
h.parallel_for(
383383
nd_range(global_nd_range, local_nd_range), [=](auto it) {
384-
Iso3dfdIterationSLM(it, next.get_pointer(), prev.get_pointer(),
385-
vel.get_pointer(), coeff.get_pointer(),
386-
tab.get_pointer(), nx, nxy, bx, by,
384+
Iso3dfdIterationSLM(it, next.get(), prev.get(),
385+
vel.get(), coeff.get(),
386+
tab.get(), nx, nxy, bx, by,
387387
n3_block, end_z);
388388
});
389389
else
390390
h.parallel_for(
391391
nd_range(global_nd_range, local_nd_range), [=](auto it) {
392-
Iso3dfdIterationSLM(it, prev.get_pointer(), next.get_pointer(),
393-
vel.get_pointer(), coeff.get_pointer(),
394-
tab.get_pointer(), nx, nxy, bx, by,
392+
Iso3dfdIterationSLM(it, prev.get(), next.get(),
393+
vel.get(), coeff.get(),
394+
tab.get(), nx, nxy, bx, by,
395395
n3_block, end_z);
396396
});
397397

@@ -408,17 +408,25 @@ bool Iso3dfdDevice(sycl::queue &q, float *ptr_next, float *ptr_prev,
408408
if (i % 2 == 0)
409409
h.parallel_for(
410410
nd_range(global_nd_range, local_nd_range), [=](auto it) {
411-
Iso3dfdIterationGlobal(it, next.get_pointer(),
412-
prev.get_pointer(), vel.get_pointer(),
413-
coeff.get_pointer(), nx, nxy, bx, by,
411+
auto next_ptr = next.template get_multi_ptr<sycl::access::decorated::no>();
412+
auto prev_ptr = prev.template get_multi_ptr<sycl::access::decorated::no>();
413+
auto vel_ptr = vel.template get_multi_ptr<sycl::access::decorated::no>();
414+
auto coeff_ptr = coeff.template get_multi_ptr<sycl::access::decorated::no>();
415+
Iso3dfdIterationGlobal(it, next_ptr.get(),
416+
prev_ptr.get(), vel_ptr.get(),
417+
coeff_ptr.get(), nx, nxy, bx, by,
414418
n3_block, end_z);
415419
});
416420
else
417421
h.parallel_for(
418422
nd_range(global_nd_range, local_nd_range), [=](auto it) {
419-
Iso3dfdIterationGlobal(it, prev.get_pointer(),
420-
next.get_pointer(), vel.get_pointer(),
421-
coeff.get_pointer(), nx, nxy, bx, by,
423+
auto next_ptr = next.template get_multi_ptr<sycl::access::decorated::no>();
424+
auto prev_ptr = prev.template get_multi_ptr<sycl::access::decorated::no>();
425+
auto vel_ptr = vel.template get_multi_ptr<sycl::access::decorated::no>();
426+
auto coeff_ptr = coeff.template get_multi_ptr<sycl::access::decorated::no>();
427+
Iso3dfdIterationGlobal(it, prev_ptr.get(),
428+
next_ptr.get(), vel_ptr.get(),
429+
coeff_ptr.get(), nx, nxy, bx, by,
422430
n3_block, end_z);
423431
});
424432
#endif

sdk/samples/vector_sq_add/vector_sq_add.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ int main(int argc, char *argv[]) {
245245
auto print_queue_info = [](const sycl::queue &sycl_queue) {
246246
auto queue_type =
247247
get_native<sycl::backend::ext_oneapi_level_zero>(sycl_queue);
248-
#if __LIBSYCL_MAJOR_VERSION >= 6 && __LIBSYCL_MINOR_VERSION >= 2
248+
#if __LIBSYCL_MAJOR_VERSION > 6 || (__LIBSYCL_MAJOR_VERSION == 6 && __LIBSYCL_MINOR_VERSION >= 2)
249249
// 1 (default)
250250
if (auto *ptr_queue_handle =
251251
std::get_if<ze_command_list_handle_t>(&queue_type)) {

sdk/test/main_dpcgemm_fixture.cc

+4-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ float RunAndCheck(sycl::queue queue, const std::vector<float>& a, const std::vec
101101
auto c_acc = c_buf.get_access<sycl::access::mode::write>(cgh);
102102

103103
cgh.parallel_for<class __GEMM>(sycl::range<2>(size, size), [=](sycl::id<2> id) {
104-
GEMM(a_acc.get_pointer(), b_acc.get_pointer(), c_acc.get_pointer(), size, id);
104+
auto a_acc_ptr = a_acc.get_multi_ptr<sycl::access::decorated::no>();
105+
auto b_acc_ptr = b_acc.get_multi_ptr<sycl::access::decorated::no>();
106+
auto c_acc_ptr = c_acc.get_multi_ptr<sycl::access::decorated::no>();
107+
GEMM(a_acc_ptr.get(), b_acc_ptr.get(), c_acc_ptr.get(), size, id);
105108
});
106109
});
107110
queue.wait_and_throw();

sdk/test/main_vecsqadd_fixture.cc

-30
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,6 @@ void RunExternalCorrIdTest(queue &q, const DoubleVector &a, const DoubleVector &
214214
vecAdd(q, a, b, sq_add);
215215
print_results(sq_add, vector_size);
216216

217-
// print_queue_info(q);
218-
219217
StartTracing();
220218
vecAdd(q, c, d, sq_add2);
221219
StopTracing();
@@ -259,34 +257,6 @@ void RunVecsqadd(TestType a_test_type) {
259257
auto d_selector{gpu_selector_v};
260258
queue q(d_selector, NULL);
261259

262-
// Underlying queue handle object changes based on value of
263-
// SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=?
264-
auto print_queue_info = [](const sycl::queue &sycl_queue) {
265-
auto queue_type = get_native<sycl::backend::ext_oneapi_level_zero>(sycl_queue);
266-
#if __LIBSYCL_MAJOR_VERSION >= 6 && __LIBSYCL_MINOR_VERSION >= 2
267-
// 1 (default)
268-
if (auto *ptr_queue_handle = std::get_if<ze_command_list_handle_t>(&queue_type)) {
269-
printf("Queue ptr: 0x%p, native queue: 0x%p, native device: 0x%p \n", &sycl_queue,
270-
ptr_queue_handle,
271-
get_native<sycl::backend::ext_oneapi_level_zero>(sycl_queue.get_device()));
272-
273-
// 0
274-
} else if (auto *ptr_queue_handle = std::get_if<ze_command_queue_handle_t>(&queue_type)) {
275-
printf("Queue ptr: 0x%p, native queue: 0x%p, native device: 0x%p \n", &sycl_queue,
276-
ptr_queue_handle,
277-
get_native<sycl::backend::ext_oneapi_level_zero>(sycl_queue.get_device()));
278-
} else {
279-
std::cerr << "Underlying level zero queue handle could not be obtained." << '\n';
280-
}
281-
#else
282-
printf("Queue ptr: 0x%p, native queue: 0x%p, native device: 0x%p \n", &sycl_queue,
283-
get_native<sycl::backend::ext_oneapi_level_zero>(sycl_queue),
284-
get_native<sycl::backend::ext_oneapi_level_zero>(sycl_queue.get_device()));
285-
#endif
286-
};
287-
288-
print_queue_info(q);
289-
290260
// Start Tests by Type
291261

292262
if (a_test_type == TestType::RUN_ALL) {

0 commit comments

Comments
 (0)