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

Commit ff22962

Browse files
committed
Add compatibility for renaming SYCL namespaces
1 parent 4d3f7d9 commit ff22962

File tree

10 files changed

+42
-19
lines changed

10 files changed

+42
-19
lines changed

SYCL/Basic/built-ins/printf.cpp

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
#include <cstdint>
1212
#include <iostream>
1313

14+
/* https://github.com/intel/llvm/pull/2246: namespace compatibility mode*/
15+
__SYCL_INLINE_NAMESPACE(cl) {
16+
namespace sycl {
17+
namespace intel {};
18+
namespace ONEAPI {
19+
using namespace cl::sycl::intel;
20+
}}};
21+
1422
using namespace cl::sycl;
1523

1624
// According to OpenCL C spec, the format string must be in constant address
@@ -40,7 +48,7 @@ int main() {
4048
Queue.submit([&](handler &CGH) {
4149
CGH.single_task<class integral>([=]() {
4250
// String
43-
intel::experimental::printf(format_hello_world);
51+
ONEAPI::experimental::printf(format_hello_world);
4452
// Due to a bug in Intel CPU Runtime for OpenCL on Windows, information
4553
// printed using such format strings (without %-specifiers) might
4654
// appear in different order if output is redirected to a file or
@@ -49,8 +57,8 @@ int main() {
4957
// CHECK: {{(Hello, World!)?}}
5058

5159
// Integral types
52-
intel::experimental::printf(format_int, (int32_t)123);
53-
intel::experimental::printf(format_int, (int32_t)-123);
60+
ONEAPI::experimental::printf(format_int, (int32_t)123);
61+
ONEAPI::experimental::printf(format_int, (int32_t)-123);
5462
// CHECK: 123
5563
// CHECK-NEXT: -123
5664

@@ -59,8 +67,8 @@ int main() {
5967
// You can declare format string in non-global scope, but in this case
6068
// static keyword is required
6169
static const CONSTANT char format[] = "%f\n";
62-
intel::experimental::printf(format, 33.4f);
63-
intel::experimental::printf(format, -33.4f);
70+
ONEAPI::experimental::printf(format, 33.4f);
71+
ONEAPI::experimental::printf(format, -33.4f);
6472
}
6573
// CHECK-NEXT: 33.4
6674
// CHECK-NEXT: -33.4
@@ -72,21 +80,21 @@ int main() {
7280
using ocl_int4 = cl::sycl::vec<int, 4>::vector_t;
7381
{
7482
static const CONSTANT char format[] = "%v4d\n";
75-
intel::experimental::printf(format, (ocl_int4)v4);
83+
ONEAPI::experimental::printf(format, (ocl_int4)v4);
7684
}
7785

7886
// However, you are still able to print them by-element:
7987
{
80-
intel::experimental::printf(format_vec, (int32_t)v4.w(),
88+
ONEAPI::experimental::printf(format_vec, (int32_t)v4.w(),
8189
(int32_t)v4.z(), (int32_t)v4.y(),
8290
(int32_t)v4.x());
8391
}
8492
#else
8593
// On host side you always have to print them by-element:
86-
intel::experimental::printf(format_vec, (int32_t)v4.x(),
94+
ONEAPI::experimental::printf(format_vec, (int32_t)v4.x(),
8795
(int32_t)v4.y(), (int32_t)v4.z(),
8896
(int32_t)v4.w());
89-
intel::experimental::printf(format_vec, (int32_t)v4.w(),
97+
ONEAPI::experimental::printf(format_vec, (int32_t)v4.w(),
9098
(int32_t)v4.z(), (int32_t)v4.y(),
9199
(int32_t)v4.x());
92100
#endif // __SYCL_DEVICE_ONLY__
@@ -99,7 +107,7 @@ int main() {
99107
// According to OpenCL spec, argument should be a void pointer
100108
{
101109
static const CONSTANT char format[] = "%p\n";
102-
intel::experimental::printf(format, (void *)Ptr);
110+
ONEAPI::experimental::printf(format, (void *)Ptr);
103111
}
104112
// CHECK-NEXT: {{(0x)?[0-9a-fA-F]+$}}
105113
});
@@ -110,7 +118,7 @@ int main() {
110118
Queue.submit([&](handler &CGH) {
111119
CGH.parallel_for<class stream_string>(range<1>(10), [=](id<1> i) {
112120
// cast to uint64_t to be sure that we pass 64-bit unsigned value
113-
intel::experimental::printf(format_hello_world_2, (uint64_t)i.get(0));
121+
ONEAPI::experimental::printf(format_hello_world_2, (uint64_t)i.get(0));
114122
});
115123
});
116124
Queue.wait();

SYCL/Basic/group-algorithm/all_of.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
#include <algorithm>
1212
#include <cassert>
1313
#include <numeric>
14+
#include "ns_compat.h"
1415
using namespace sycl;
15-
using namespace sycl::intel;
16+
using namespace sycl::ONEAPI;
1617

1718
template <class Predicate>
1819
class all_of_kernel;

SYCL/Basic/group-algorithm/any_of.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
#include <algorithm>
1212
#include <cassert>
1313
#include <numeric>
14+
#include "ns_compat.h"
1415
using namespace sycl;
15-
using namespace sycl::intel;
16+
using namespace sycl::ONEAPI;
1617

1718
template <class Predicate>
1819
class any_of_kernel;

SYCL/Basic/group-algorithm/broadcast.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
#include <algorithm>
1212
#include <cassert>
1313
#include <numeric>
14+
#include "ns_compat.h"
1415
using namespace sycl;
15-
using namespace sycl::intel;
16+
using namespace sycl::ONEAPI;
1617

1718
class broadcast_kernel;
1819

SYCL/Basic/group-algorithm/exclusive_scan.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
#include <limits>
1414
#include <numeric>
1515
#include <vector>
16+
#include "ns_compat.h"
1617
using namespace sycl;
17-
using namespace sycl::intel;
18+
using namespace sycl::ONEAPI;
1819

1920
template <class BinaryOperation, int TestNumber>
2021
class exclusive_scan_kernel;

SYCL/Basic/group-algorithm/inclusive_scan.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
#include <limits>
1414
#include <numeric>
1515
#include <vector>
16+
#include "ns_compat.h"
1617
using namespace sycl;
17-
using namespace sycl::intel;
18+
using namespace sycl::ONEAPI;
1819

1920
template <class BinaryOperation, int TestNumber>
2021
class inclusive_scan_kernel;

SYCL/Basic/group-algorithm/leader.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99

1010
#include <CL/sycl.hpp>
1111
#include <cassert>
12+
#include "ns_compat.h"
1213
using namespace sycl;
13-
using namespace sycl::intel;
14+
using namespace sycl::ONEAPI;
1415

1516
class leader_kernel;
1617

SYCL/Basic/group-algorithm/none_of.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
#include <algorithm>
1212
#include <cassert>
1313
#include <numeric>
14+
#include "ns_compat.h"
1415
using namespace sycl;
15-
using namespace sycl::intel;
16+
using namespace sycl::ONEAPI;
1617

1718
template <class Predicate>
1819
class none_of_kernel;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* https://github.com/intel/llvm/pull/2231: namespace compatibility mode*/
2+
__SYCL_INLINE_NAMESPACE(cl) {
3+
namespace sycl {
4+
namespace intel {};
5+
namespace ONEAPI {
6+
using namespace cl::sycl::intel;
7+
}}};

SYCL/Basic/group-algorithm/reduce.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
#include <cassert>
1313
#include <limits>
1414
#include <numeric>
15+
#include "ns_compat.h"
1516
using namespace sycl;
16-
using namespace sycl::intel;
17+
using namespace sycl::ONEAPI;
1718

1819
template <class BinaryOperation>
1920
class reduce_kernel;

0 commit comments

Comments
 (0)