Skip to content

Commit 3d2b25e

Browse files
[SYCL][ABI Break] Remove "cl" namespace (#6518)
As part of the change, also start using "inline namespace _V1" to allow possible future ABI-affecting changes.
1 parent ee59723 commit 3d2b25e

File tree

510 files changed

+6220
-6138
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

510 files changed

+6220
-6138
lines changed

clang/lib/CodeGen/CGSYCLRuntime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ static bool isPFWI(const FunctionDecl &FD) {
4444
if (!MD)
4545
return false;
4646
static std::array<Util::DeclContextDesc, 3> Scopes = {
47-
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "cl"},
4847
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "sycl"},
48+
Util::DeclContextDesc{clang::Decl::Kind::Namespace, "_V1"},
4949
Util::DeclContextDesc{Decl::Kind::ClassTemplateSpecialization, "group"}};
5050
if (!Util::matchQualifiedTypeName(MD->getParent(), Scopes))
5151
return false;

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10426,8 +10426,8 @@ bool isDeviceAspectType(const QualType Ty) {
1042610426
return false;
1042710427

1042810428
std::array<std::pair<Decl::Kind, StringRef>, 3> Scopes = {
10429-
MakeDeclContextDesc(Decl::Kind::Namespace, "cl"),
1043010429
MakeDeclContextDesc(Decl::Kind::Namespace, "sycl"),
10430+
MakeDeclContextDesc(Decl::Kind::Namespace, "_V1"),
1043110431
MakeDeclContextDesc(Decl::Kind::Enum, "aspect")};
1043210432

1043310433
const auto *Ctx = cast<DeclContext>(ET->getDecl());

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -925,13 +925,13 @@ class MarkWIScopeFnVisitor : public RecursiveASTVisitor<MarkWIScopeFnVisitor> {
925925
return true;
926926
QualType Ty = Ctx.getRecordType(Call->getRecordDecl());
927927
if (!Util::isSyclType(Ty, "group", true /*Tmpl*/))
928-
// not a member of cl::sycl::group - continue search
928+
// not a member of sycl::group - continue search
929929
return true;
930930
auto Name = Callee->getName();
931931
if (((Name != "parallel_for_work_item") && (Name != "wait_for")) ||
932932
Callee->hasAttr<SYCLScopeAttr>())
933933
return true;
934-
// it is a call to cl::sycl::group::parallel_for_work_item/wait_for -
934+
// it is a call to sycl::group::parallel_for_work_item/wait_for -
935935
// mark the callee
936936
Callee->addAttr(
937937
SYCLScopeAttr::CreateImplicit(Ctx, SYCLScopeAttr::Level::WorkItem));
@@ -4215,7 +4215,7 @@ static const char *paramKind2Str(KernelParamKind K) {
42154215
// VB,
42164216
// std::array<T1, N>& VC, int param, T2 ... varargs) {
42174217
// ...
4218-
// deviceQueue.submit([&](cl::sycl::handler& cgh) {
4218+
// deviceQueue.submit([&](sycl::handler& cgh) {
42194219
// ...
42204220
// cgh.parallel_for<class SimpleVadd<T1, N, T2...>>(...)
42214221
// ...
@@ -4650,8 +4650,8 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
46504650
FwdDeclEmitter.Visit(K.NameType);
46514651
O << "\n";
46524652

4653-
O << "__SYCL_INLINE_NAMESPACE(cl) {\n";
46544653
O << "namespace sycl {\n";
4654+
O << "__SYCL_INLINE_VER_NAMESPACE(_V1) {\n";
46554655
O << "namespace detail {\n";
46564656

46574657
// Generate declaration of variable of type __sycl_device_global_registration
@@ -4795,8 +4795,8 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
47954795
}
47964796
O << "\n";
47974797
O << "} // namespace detail\n";
4798+
O << "} // __SYCL_INLINE_VER_NAMESPACE(_V1)\n";
47984799
O << "} // namespace sycl\n";
4799-
O << "} // __SYCL_INLINE_NAMESPACE(cl)\n";
48004800
O << "\n";
48014801
}
48024802

@@ -5076,8 +5076,8 @@ bool SYCLIntegrationFooter::emit(raw_ostream &OS) {
50765076
DeviceGlobOS << "\");\n";
50775077
} else {
50785078
EmittedFirstSpecConstant = true;
5079-
OS << "__SYCL_INLINE_NAMESPACE(cl) {\n";
50805079
OS << "namespace sycl {\n";
5080+
OS << "__SYCL_INLINE_VER_NAMESPACE(_V1) {\n";
50815081
OS << "namespace detail {\n";
50825082
OS << "template<>\n";
50835083
OS << "inline const char *get_spec_constant_symbolic_ID_impl<";
@@ -5095,8 +5095,8 @@ bool SYCLIntegrationFooter::emit(raw_ostream &OS) {
50955095
OS << "\";\n";
50965096
OS << "}\n";
50975097
OS << "} // namespace detail\n";
5098+
OS << "} // __SYCL_INLINE_VER_NAMESPACE(_V1)\n";
50985099
OS << "} // namespace sycl\n";
5099-
OS << "} // __SYCL_INLINE_NAMESPACE(cl)\n";
51005100
}
51015101
}
51025102

@@ -5132,8 +5132,8 @@ bool Util::isSyclSpecialType(const QualType Ty) {
51325132

51335133
bool Util::isSyclSpecConstantType(QualType Ty) {
51345134
std::array<DeclContextDesc, 6> Scopes = {
5135-
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "cl"),
51365135
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "sycl"),
5136+
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "_V1"),
51375137
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "ext"),
51385138
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "oneapi"),
51395139
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "experimental"),
@@ -5144,25 +5144,25 @@ bool Util::isSyclSpecConstantType(QualType Ty) {
51445144

51455145
bool Util::isSyclSpecIdType(QualType Ty) {
51465146
std::array<DeclContextDesc, 3> Scopes = {
5147-
Util::MakeDeclContextDesc(clang::Decl::Kind::Namespace, "cl"),
51485147
Util::MakeDeclContextDesc(clang::Decl::Kind::Namespace, "sycl"),
5148+
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "_V1"),
51495149
Util::MakeDeclContextDesc(Decl::Kind::ClassTemplateSpecialization,
51505150
"specialization_id")};
51515151
return matchQualifiedTypeName(Ty, Scopes);
51525152
}
51535153

51545154
bool Util::isSyclKernelHandlerType(QualType Ty) {
51555155
std::array<DeclContextDesc, 3> Scopes = {
5156-
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "cl"),
51575156
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "sycl"),
5157+
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "_V1"),
51585158
Util::MakeDeclContextDesc(Decl::Kind::CXXRecord, "kernel_handler")};
51595159
return matchQualifiedTypeName(Ty, Scopes);
51605160
}
51615161

51625162
bool Util::isSyclAccessorNoAliasPropertyType(QualType Ty) {
51635163
std::array<DeclContextDesc, 7> Scopes = {
5164-
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "cl"),
51655164
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "sycl"),
5165+
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "_V1"),
51665166
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "ext"),
51675167
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "oneapi"),
51685168
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "property"),
@@ -5174,8 +5174,8 @@ bool Util::isSyclAccessorNoAliasPropertyType(QualType Ty) {
51745174

51755175
bool Util::isSyclBufferLocationType(QualType Ty) {
51765176
std::array<DeclContextDesc, 7> Scopes = {
5177-
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "cl"),
51785177
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "sycl"),
5178+
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "_V1"),
51795179
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "ext"),
51805180
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "intel"),
51815181
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "property"),
@@ -5189,16 +5189,16 @@ bool Util::isSyclType(QualType Ty, StringRef Name, bool Tmpl) {
51895189
Decl::Kind ClassDeclKind =
51905190
Tmpl ? Decl::Kind::ClassTemplateSpecialization : Decl::Kind::CXXRecord;
51915191
std::array<DeclContextDesc, 3> Scopes = {
5192-
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "cl"),
51935192
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "sycl"),
5193+
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "_V1"),
51945194
Util::MakeDeclContextDesc(ClassDeclKind, Name)};
51955195
return matchQualifiedTypeName(Ty, Scopes);
51965196
}
51975197

51985198
bool Util::isAccessorPropertyListType(QualType Ty) {
51995199
std::array<DeclContextDesc, 5> Scopes = {
5200-
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "cl"),
52015200
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "sycl"),
5201+
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "_V1"),
52025202
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "ext"),
52035203
Util::MakeDeclContextDesc(Decl::Kind::Namespace, "oneapi"),
52045204
Util::MakeDeclContextDesc(Decl::Kind::ClassTemplateSpecialization,

clang/test/CodeGenSYCL/Inputs/sycl.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ __spirv_ControlBarrier(int, int, int) noexcept;
1010
#endif
1111

1212
// Dummy runtime classes to model SYCL API.
13-
inline namespace cl {
1413
namespace sycl {
14+
inline namespace _V1 {
1515
struct sampler_impl {
1616
#ifdef __SYCL_DEVICE_ONLY__
1717
__ocl_sampler_t m_Sampler;
@@ -491,7 +491,7 @@ class __attribute__((sycl_special_class)) stream {
491491
void __finalize() {}
492492

493493
private:
494-
cl::sycl::accessor<char, 1, cl::sycl::access::mode::read_write> Acc;
494+
sycl::accessor<char, 1, sycl::access::mode::read_write> Acc;
495495
int FlushBufferSize;
496496
};
497497

@@ -621,5 +621,5 @@ class image {
621621
}
622622
};
623623

624+
} // inline namespace _V1
624625
} // namespace sycl
625-
} // namespace cl

clang/test/CodeGenSYCL/accessor-readonly-invalid-lib.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// Test which verifies that readonly attribute is generated for unexpected access mode value.
44

55
// Dummy library with unexpected access::mode enum value.
6-
namespace cl {
76
namespace sycl {
7+
inline namespace _V1 {
88

99
namespace access {
1010

@@ -71,16 +71,16 @@ class __attribute__((sycl_special_class)) accessor {
7171
range<dimensions> MemRange, id<dimensions> Offset) {}
7272
};
7373

74+
} // inline namespace _V1
7475
} // namespace sycl
75-
} // namespace cl
7676

7777
template <typename name, typename Func>
7878
__attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) {
7979
kernelFunc();
8080
}
8181

8282
int main() {
83-
cl::sycl::accessor<int, 1, cl::sycl::access::mode::read> Acc;
83+
sycl::accessor<int, 1, sycl::access::mode::read> Acc;
8484
// CHECK: spir_kernel{{.*}}fake_kernel
8585
// CHECK-SAME: readonly
8686
kernel_single_task<class fake_kernel>([=]() {

clang/test/CodeGenSYCL/accessor-readonly.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#include "Inputs/sycl.hpp"
66

77
// CHECK-NOT: spir_kernel{{.*}}f0_kernel{{.*}}readonly
8-
void f0(cl::sycl::queue &myQueue, cl::sycl::buffer<int, 1> &in_buf, cl::sycl::buffer<int, 1> &out_buf) {
9-
myQueue.submit([&](cl::sycl::handler &cgh) {
10-
auto write_acc = out_buf.get_access<cl::sycl::access::mode::write>(cgh);
8+
void f0(sycl::queue &myQueue, sycl::buffer<int, 1> &in_buf, sycl::buffer<int, 1> &out_buf) {
9+
myQueue.submit([&](sycl::handler &cgh) {
10+
auto write_acc = out_buf.get_access<sycl::access::mode::write>(cgh);
1111
cgh.single_task<class f0_kernel>([write_acc] {});
1212
});
1313
}
@@ -16,10 +16,10 @@ void f0(cl::sycl::queue &myQueue, cl::sycl::buffer<int, 1> &in_buf, cl::sycl::bu
1616
// CHECK-NOT: readonly
1717
// CHECK-SAME: %_arg_write_acc{{.*}}%_arg_write_acc1{{.*}}%_arg_write_acc2{{.*}}%_arg_write_acc3
1818
// CHECK-SAME: readonly align 4 %_arg_read_acc
19-
void f1(cl::sycl::queue &myQueue, cl::sycl::buffer<int, 1> &in_buf, cl::sycl::buffer<int, 1> &out_buf) {
20-
myQueue.submit([&](cl::sycl::handler &cgh) {
21-
auto write_acc = out_buf.get_access<cl::sycl::access::mode::write>(cgh);
22-
auto read_acc = in_buf.get_access<cl::sycl::access::mode::read>(cgh);
19+
void f1(sycl::queue &myQueue, sycl::buffer<int, 1> &in_buf, sycl::buffer<int, 1> &out_buf) {
20+
myQueue.submit([&](sycl::handler &cgh) {
21+
auto write_acc = out_buf.get_access<sycl::access::mode::write>(cgh);
22+
auto read_acc = in_buf.get_access<sycl::access::mode::read>(cgh);
2323
cgh.single_task<class f1_kernel>([write_acc, read_acc] {});
2424
});
2525
}
@@ -28,10 +28,10 @@ void f1(cl::sycl::queue &myQueue, cl::sycl::buffer<int, 1> &in_buf, cl::sycl::bu
2828
// CHECK-SAME: readonly align 4 %_arg_read_acc
2929
// CHECK-NOT: readonly
3030
// CHECK-SAME: %_arg_write_acc
31-
void f2(cl::sycl::queue &myQueue, cl::sycl::buffer<int, 1> &in_buf, cl::sycl::buffer<int, 1> &out_buf) {
32-
myQueue.submit([&](cl::sycl::handler &cgh) {
33-
auto read_acc = in_buf.get_access<cl::sycl::access::mode::read>(cgh);
34-
auto write_acc = out_buf.get_access<cl::sycl::access::mode::write>(cgh);
31+
void f2(sycl::queue &myQueue, sycl::buffer<int, 1> &in_buf, sycl::buffer<int, 1> &out_buf) {
32+
myQueue.submit([&](sycl::handler &cgh) {
33+
auto read_acc = in_buf.get_access<sycl::access::mode::read>(cgh);
34+
auto write_acc = out_buf.get_access<sycl::access::mode::write>(cgh);
3535
cgh.single_task<class f2_kernel>([read_acc, write_acc] {});
3636
});
3737
}

clang/test/CodeGenSYCL/accessor_inheritance.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@
33

44
struct Base {
55
int A, B;
6-
cl::sycl::accessor<char, 1, cl::sycl::access::mode::read> AccField;
6+
sycl::accessor<char, 1, sycl::access::mode::read> AccField;
77
};
88

99
struct Captured : Base,
10-
cl::sycl::accessor<char, 1, cl::sycl::access::mode::read> {
10+
sycl::accessor<char, 1, sycl::access::mode::read> {
1111
int C;
1212
};
1313

1414
int main() {
1515
Captured Obj;
16-
cl::sycl::kernel_single_task<class kernel>(
16+
sycl::kernel_single_task<class kernel>(
1717
[=]() {
1818
Obj.use();
1919
});
2020
return 0;
2121
}
2222

2323
// Check kernel parameters
24-
// CHECK: %[[RANGE_TYPE:"struct.*cl::sycl::range"]]
25-
// CHECK: %[[ID_TYPE:"struct.*cl::sycl::id"]]
24+
// CHECK: %[[RANGE_TYPE:"struct.*sycl::_V1::range"]]
25+
// CHECK: %[[ID_TYPE:"struct.*sycl::_V1::id"]]
2626
// CHECK: define {{.*}}spir_kernel void @_ZTSZ4mainE6kernel
2727
// CHECK-SAME: i32 noundef [[ARG_A:%[a-zA-Z0-9_]+]],
2828
// CHECK-SAME: i32 noundef [[ARG_B:%[a-zA-Z0-9_]+]],
@@ -71,10 +71,10 @@ int main() {
7171
// Check accessors initialization
7272
// CHECK: [[ACC_FIELD:%[a-zA-Z0-9_]+]] = getelementptr inbounds %struct{{.*}}Base, ptr addrspace(4) [[GEP]], i32 0, i32 2
7373
// Default constructor call
74-
// CHECK: call spir_func void @_ZN2cl4sycl8accessorIcLi1ELNS0_6access4modeE1024ELNS2_6targetE2014ELNS2_11placeholderE0ENS0_3ext6oneapi22accessor_property_listIJEEEEC1Ev(ptr addrspace(4) {{[^,]*}} [[ACC_FIELD]])
74+
// CHECK: call spir_func void @_ZN4sycl3_V18accessorIcLi1ELNS0_6access4modeE1024ELNS2_6targetE2014ELNS2_11placeholderE0ENS0_3ext6oneapi22accessor_property_listIJEEEEC1Ev(ptr addrspace(4) {{[^,]*}} [[ACC_FIELD]])
7575
// CHECK: [[GEP1:%[a-zA-Z0-9_]+]] = getelementptr inbounds i8, ptr addrspace(4) [[GEP]], i64 20
7676
// Default constructor call
77-
// CHECK: call spir_func void @_ZN2cl4sycl8accessorIcLi1ELNS0_6access4modeE1024ELNS2_6targetE2014ELNS2_11placeholderE0ENS0_3ext6oneapi22accessor_property_listIJEEEEC2Ev(ptr addrspace(4) {{[^,]*}} [[GEP1]])
77+
// CHECK: call spir_func void @_ZN4sycl3_V18accessorIcLi1ELNS0_6access4modeE1024ELNS2_6targetE2014ELNS2_11placeholderE0ENS0_3ext6oneapi22accessor_property_listIJEEEEC2Ev(ptr addrspace(4) {{[^,]*}} [[GEP1]])
7878

7979
// CHECK C field initialization
8080
// CHECK: [[FIELD_C:%[a-zA-Z0-9_]+]] = getelementptr inbounds %struct{{.*}}Captured, ptr addrspace(4) [[GEP]], i32 0, i32 2

clang/test/CodeGenSYCL/accessor_no_alias_property.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@
55
#include "Inputs/sycl.hpp"
66

77
int main() {
8-
cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write,
9-
cl::sycl::access::target::global_buffer,
10-
cl::sycl::access::placeholder::false_t,
11-
cl::sycl::ext::oneapi::accessor_property_list<
12-
cl::sycl::ext::oneapi::property::no_alias::instance<true>>>
8+
sycl::accessor<int, 1, sycl::access::mode::read_write,
9+
sycl::access::target::global_buffer,
10+
sycl::access::placeholder::false_t,
11+
sycl::ext::oneapi::accessor_property_list<
12+
sycl::ext::oneapi::property::no_alias::instance<true>>>
1313
accessorA;
1414

15-
cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write,
16-
cl::sycl::access::target::global_buffer,
17-
cl::sycl::access::placeholder::false_t,
18-
cl::sycl::ext::oneapi::accessor_property_list<
19-
cl::sycl::ext::intel::property::buffer_location::instance<1>>>
15+
sycl::accessor<int, 1, sycl::access::mode::read_write,
16+
sycl::access::target::global_buffer,
17+
sycl::access::placeholder::false_t,
18+
sycl::ext::oneapi::accessor_property_list<
19+
sycl::ext::intel::property::buffer_location::instance<1>>>
2020
accessorB;
2121

2222
// Check that noalias parameter attribute is emitted when no_alias accessor property is used
2323
// CHECK: define {{.*}}spir_kernel void @_ZTSZ4mainE16kernel_function1({{.*}} noalias {{.*}} %_arg_accessorA, {{.*}})
24-
cl::sycl::kernel_single_task<class kernel_function1>(
24+
sycl::kernel_single_task<class kernel_function1>(
2525
[=]() {
2626
accessorA.use();
2727
});
@@ -30,7 +30,7 @@ int main() {
3030
// CHECK: define {{.*}}spir_kernel void @_ZTSZ4mainE16kernel_function2
3131
// CHECK-NOT: noalias
3232
// CHECK-SAME: {
33-
cl::sycl::kernel_single_task<class kernel_function2>(
33+
sycl::kernel_single_task<class kernel_function2>(
3434
[=]() {
3535
accessorB.use();
3636
});

0 commit comments

Comments
 (0)