Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCL] Adding support for 'sycl_special_class' attribute. #3892

Merged
merged 117 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
846e694
[SYCL] Implement sycl_special_class attribute
Fznamznon Jul 10, 2020
5e679f8
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Jun 5, 2021
bdb1ff5
Fix build issues
zahiraam Jun 7, 2021
203edd6
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Jun 7, 2021
dc74a5e
Fixing build errors
zahiraam Jun 7, 2021
65ac140
Indent
zahiraam Jun 7, 2021
6586846
Indent
zahiraam Jun 7, 2021
a3c118b
Fixed build errors
zahiraam Jun 8, 2021
30c5a03
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Jun 8, 2021
3999939
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Jun 9, 2021
c3f8757
Fix LIT tests
zahiraam Jun 11, 2021
ab4c68e
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Jun 11, 2021
58db6b5
Fixed build errors
zahiraam Jun 15, 2021
c009836
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Jun 15, 2021
05b0af8
Fixed build errors
zahiraam Jun 16, 2021
425bb97
Fixed build errors
zahiraam Jun 18, 2021
890e4b0
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Jun 18, 2021
89b49c8
Respond to review comments
zahiraam Jun 21, 2021
b897a02
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Jun 21, 2021
159b484
Respond to review comments
zahiraam Jun 21, 2021
fe1450e
Removed the enum argument from the attribute definition
zahiraam Jun 22, 2021
f7d9f31
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Jun 22, 2021
9c59465
Formatting
zahiraam Jun 22, 2021
f4cfd63
Fix LIT test pragma-attribute-supported-attributes-list
zahiraam Jun 22, 2021
b1b708e
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Jun 23, 2021
ad5c50f
Respond to review comments
zahiraam Jun 23, 2021
8771fb3
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Jun 23, 2021
94b56df
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Jul 7, 2021
68fb2b5
Making special classes type agnostic
zahiraam Jul 26, 2021
204cccb
fix conflicts
zahiraam Jul 27, 2021
59e5f0b
fix conflicts
zahiraam Jul 27, 2021
eb7997d
Fix format
zahiraam Jul 27, 2021
c34f5f2
Remove argument attribute from macro SYCL_SPECIAL_CLASS
zahiraam Jul 28, 2021
ed896c6
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Jul 28, 2021
5b95a01
Apply suggestions from code review to fix pre-commit tests.
bader Aug 1, 2021
8922d48
[SYCL][ROCm] Fix building libclc for AMD (#4199)
npmiller Jul 28, 2021
d439bfe
[SYCL] Fix some Doxygen build warnings (#4170)
vmaksimo Jul 28, 2021
c37c9bb
[SYCL] Add splitting module capabilities when compiling for NVPTX and…
Naghasan Jul 29, 2021
2842545
[SYCL] Restore the correct initialization for _statically_coalesce_va…
dm-vodopyanov Jul 29, 2021
87b5473
[opencl-aot] Add option to control output of verbose log (#4179)
linkren Jul 29, 2021
4b3fdde
[Doc] Update SYCL CUDA documentation (#4214)
Naghasan Jul 30, 2021
f7b1782
[SYCL][LIBCLC] Add support for non-uniform [I/F]Mul op in ptx-nvidiac…
jchlanda Jul 30, 2021
170b344
[SYCL][LIBCLC] Add subgroup builtins for AMDGCN (#4208)
jchlanda Jul 30, 2021
5862f84
[SYCL] Construct context from first device in unit tests (#4142)
npmiller Jul 30, 2021
e7352f2
[SYCL] Expansion of the class CG to CommandGroup (#4216)
denis-kabanov Jul 30, 2021
23ff551
[SYCL] Fix true missing on Windows (#4211)
Jul 30, 2021
c1b1a74
[SYCL][LIBCLC] Add sqrt for doubles for amdgcn-amdhsa (#4223)
npmiller Aug 1, 2021
96f7cb5
[Driver][SYCL] Enable adding of default device triple (#4175)
mdtoguchi Aug 1, 2021
aa8d164
[Driver][SYCL] Adjust header inclusion for source + generated footer …
mdtoguchi Aug 2, 2021
7275b34
[SYCL] Update windows driver version (#4215)
NikitaRudenkoIntel Aug 2, 2021
f308a4e
[SYCL] Fix initialization of interoperability memory objects (#4205)
sergey-semenov Aug 2, 2021
5950cd0
[SYCL] Replace filename default argument of code_location to nullptr …
Aug 2, 2021
6a3589b
[SYCL][Doc] Update ROCM section of GetStartedGuide (#4229)
rolandschulz Aug 2, 2021
71e85cf
Respond to review comments
zahiraam Aug 2, 2021
c2602c6
Remove driver changes
zahiraam Aug 2, 2021
8db682d
Remove non-related changes
zahiraam Aug 2, 2021
9aa5193
Fix SyclOptReport::handleSpecialType
zahiraam Aug 2, 2021
81e7a4f
Fix indentation
zahiraam Aug 2, 2021
4bd54d7
Remove unrelated changes
zahiraam Aug 2, 2021
e886e79
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Aug 5, 2021
631e1f3
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Aug 6, 2021
b912ab3
Fix for ESIMD failures
zahiraam Aug 8, 2021
261def5
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Aug 8, 2021
92375e4
Fix indentation
zahiraam Aug 8, 2021
f6efdec
Fix conflics
zahiraam Aug 10, 2021
999fea8
Fix conflics
zahiraam Aug 11, 2021
9fee895
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Aug 11, 2021
1da2b10
Fix conflics
zahiraam Aug 11, 2021
f5e7918
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Aug 16, 2021
5e4cdbc
Removed checkSyclAccessorType
zahiraam Aug 18, 2021
c2a28d8
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Aug 25, 2021
3be4eef
OptReport is now taking the type of the class
zahiraam Aug 25, 2021
f0f382f
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Sep 7, 2021
bdd04d7
Corrected the assert comments, fixed the string generated in the opt …
zahiraam Sep 7, 2021
e12eec1
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Sep 8, 2021
bf22398
Addressed Elizabeth's review comments
zahiraam Sep 8, 2021
364fb99
Fixed comment referring to 'sample'
zahiraam Sep 8, 2021
62ea8ce
Merge branch 'pr_2091' of https://github.com/zahiraam/llvm-1 into pr_…
zahiraam Sep 8, 2021
e4d66fc
Remove unrelated change
zahiraam Sep 8, 2021
e97af83
Deleted CodeGenSYCL/special-classes.cpp
zahiraam Sep 8, 2021
281e337
Remove unrelated change
zahiraam Sep 8, 2021
497b6ac
Remove unrelated change
zahiraam Sep 8, 2021
ddf8394
Remove unrelated change
zahiraam Sep 8, 2021
1896639
Remove unrelated change
zahiraam Sep 8, 2021
24c6f3a
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Sep 9, 2021
2efd65d
Remove unrelated change
zahiraam Sep 9, 2021
cac1b20
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Sep 9, 2021
ecbb2be
Remove unrelated change
zahiraam Sep 9, 2021
2116ca5
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Sep 10, 2021
7b734e0
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Sep 14, 2021
72c2b17
Removed the __init_esimd method
zahiraam Sep 14, 2021
b8e840c
Leaving the removal of __init_esimd method for another patch
zahiraam Sep 15, 2021
98463ad
Refactor code to handle accesors' parameters.
zahiraam Sep 15, 2021
7130ef4
Fix comments.
zahiraam Sep 15, 2021
c397857
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Sep 16, 2021
30c3ca8
Addressed review comments
zahiraam Sep 16, 2021
9696f11
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Sep 21, 2021
730de70
Put back the init_esimd and responded to review. The init_esimd chang…
zahiraam Sep 22, 2021
f0e7cd9
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Sep 22, 2021
b0297aa
Indentation
zahiraam Sep 23, 2021
a2595b9
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Sep 23, 2021
ae23b63
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Oct 4, 2021
4383f9f
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Oct 5, 2021
179abad
Fix LIT failures
zahiraam Oct 5, 2021
b8dd5cf
Fix format
zahiraam Oct 5, 2021
b0356ce
Fix format
zahiraam Oct 5, 2021
4457a96
Removing the property-list handing from (fake) FE header
zahiraam Oct 5, 2021
50a09ce
Merge remote-tracking branch 'remote/sycl' into pr_2091
zahiraam Oct 12, 2021
d7a5105
Making explicit the test for accessor kind and leave init_esimd as is…
zahiraam Oct 13, 2021
e0c44d3
Respond to review commentse
zahiraam Oct 14, 2021
a736a7f
Respond to review comment
zahiraam Oct 14, 2021
71e8d97
Respond to review comment
zahiraam Oct 14, 2021
949aead
Fix formatting
zahiraam Oct 14, 2021
462ff09
Fix formatting
zahiraam Oct 14, 2021
d170717
Removed clang-format directives and fixed indentation
zahiraam Oct 15, 2021
80cb0d6
Fix indentation
zahiraam Oct 15, 2021
1aa856c
Fix indentation
zahiraam Oct 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed build errors
Signed-off-by: Zahira Ammarguellat <zahira.ammarguellat@intel.com>
  • Loading branch information
zahiraam committed Jun 18, 2021
commit 425bb978c0674123d179e8be0d8b6316e247aa44
10 changes: 5 additions & 5 deletions clang/test/CodeGenSYCL/Inputs/sycl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct sampler_impl {
#endif
};

__attribute__((sycl_special_class(sampler))) class sampler {
class __attribute__((sycl_special_class(sampler))) sampler {
struct sampler_impl impl;
#ifdef __SYCL_DEVICE_ONLY__
void __init(__ocl_sampler_t Sampler) { impl.m_Sampler = Sampler; }
Expand Down Expand Up @@ -166,7 +166,7 @@ struct _ImplT {
template <typename dataT, int dimensions, access::mode accessmode,
access::target accessTarget = access::target::global_buffer,
access::placeholder isPlaceholder = access::placeholder::false_t>
__attribute__((sycl_special_class(accessor))) class accessor {
class __attribute__((sycl_special_class(accessor))) accessor {

public:
void use(void) const {}
Expand Down Expand Up @@ -232,7 +232,7 @@ struct _ImageImplT {
};

template <typename dataT, int dimensions, access::mode accessmode>
__attribute__((sycl_special_class(accessor))) class accessor<dataT, dimensions, accessmode, access::target::image, access::placeholder::false_t> {
class __attribute__((sycl_special_class(accessor))) accessor<dataT, dimensions, accessmode, access::target::image, access::placeholder::false_t> {
public:
void use(void) const {}
template <typename... T>
Expand All @@ -258,7 +258,7 @@ class accessor<dataT, dimensions, accessmode, access::target::host_image, access

// TODO: Add support for image_array accessor.
// template <typename dataT, int dimensions, access::mode accessmode>
//class accessor<dataT, dimensions, accessmode, access::target::image_array, access::placeholder::false_t>
// class accessor<dataT, dimensions, accessmode, access::target::image_array, access::placeholder::false_t>

class kernel {};
class context {};
Expand Down Expand Up @@ -410,7 +410,7 @@ class handler {
}
};

__attribute__((sycl_special_class(stream))) class stream {
class __attribute__((sycl_special_class(stream))) stream {
public:
stream(unsigned long BufferSize, unsigned long MaxStatementSize,
handler &CGH) {}
Expand Down
6 changes: 3 additions & 3 deletions clang/test/CodeGenSYCL/accessor_inheritance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ int main() {
// Check accessors initialization
// CHECK: [[ACC_FIELD:%[a-zA-Z0-9_]+]] = getelementptr inbounds %struct{{.*}}Base, %struct{{.*}}Base addrspace(4)* [[BITCAST]], i32 0, i32 2
// Default constructor call
// CHECK: call spir_func void @_ZN2cl4sycl8accessorIcLi1ELNS0_6access4modeE1024ELNS2_6targetE2014ELNS2_11placeholderE0ENS0_6ONEAPI22accessor_property_listIJEEEEC1Ev(%"class{{.*}}cl::sycl::accessor" addrspace(4)* {{[^,]*}} [[ACC_FIELD]])
// CHECK: call spir_func void @_ZN2cl4sycl8accessorIcLi1ELNS0_6access4modeE1024ELNS2_6targetE2014ELNS2_11placeholderE0EEC1Ev(%"class.{{.*}}.cl::sycl::accessor" addrspace(4)* align 4 dereferenceable_or_null(12) [[ACC_FIELD]])
// CHECK: [[BITCAST1:%[a-zA-Z0-9_]+]] = bitcast %struct{{.*}}Captured addrspace(4)* [[GEP]] to i8 addrspace(4)*
// CHECK: [[GEP1:%[a-zA-Z0-9_]+]] = getelementptr inbounds i8, i8 addrspace(4)* [[BITCAST1]], i64 20
// CHECK: [[BITCAST2:%[a-zA-Z0-9_]+]] = bitcast i8 addrspace(4)* [[GEP1]] to %"class{{.*}}cl::sycl::accessor" addrspace(4)*
// CHECK: [[BITCAST2:%[a-zA-Z0-9_]+]] = bitcast i8 addrspace(4)* [[GEP1]] to %"class._ZTSN2cl4sycl8accessorIcLi1ELNS0_6access4modeE1024ELNS2_6targetE2014ELNS2_11placeholderE0EEE.cl::sycl::accessor" addrspace(4)*
// Default constructor call
// CHECK: call spir_func void @_ZN2cl4sycl8accessorIcLi1ELNS0_6access4modeE1024ELNS2_6targetE2014ELNS2_11placeholderE0ENS0_6ONEAPI22accessor_property_listIJEEEEC2Ev(%"class{{.*}}cl::sycl::accessor" addrspace(4)* {{[^,]*}} [[BITCAST2]])
// CHECK: call spir_func void @_ZN2cl4sycl8accessorIcLi1ELNS0_6access4modeE1024ELNS2_6targetE2014ELNS2_11placeholderE0EEC2Ev(%"class{{.*}}cl::sycl::accessor" addrspace(4)* align 4 dereferenceable_or_null(12) [[BITCAST2]])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// CHECK: call spir_func void @_ZN2cl4sycl8accessorIcLi1ELNS0_6access4modeE1024ELNS2_6targetE2014ELNS2_11placeholderE0EEC2Ev(%"class{{.*}}cl::sycl::accessor" addrspace(4)* align 4 dereferenceable_or_null(12) [[BITCAST2]])
// CHECK: call spir_func void @_ZN2cl4sycl8accessorIcLi1ELNS0_6access4modeE1024ELNS2_6targetE2014ELNS2_11placeholderE0EEC2Ev(%"class{{.*}}cl::sycl::accessor" addrspace(4)* {{[^,]*}} [[BITCAST2]])

Same for the one above, this makes the test less fragile.


// CHECK C field initialization
// CHECK: [[FIELD_C:%[a-zA-Z0-9_]+]] = getelementptr inbounds %struct{{.*}}Captured, %struct{{.*}}Captured addrspace(4)* [[GEP]], i32 0, i32 2
Expand Down
80 changes: 80 additions & 0 deletions clang/test/CodeGenSYCL/special-classes.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// RUN: %clang_cc1 -S -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this test? Is this checking anything additional to what we already check in existing accessor/sampler/stream tests? If we're keeping test, please add a comment describing test

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address comment. I don't think this test is required since we already have other accessor/sampler/stream tests. Are you testing anything additional here?

#include "Inputs/sycl.hpp"

cl::sycl::queue myQueue;
cl::sycl::handler SH;

class AccessorBase {
int A;
public:
cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write,
cl::sycl::access::target::local>
acc;
};

class accessor {
public:
int field;
};

class stream {
public:
int field;
};

class sampler {
public:
int field;
};

int main() {

AccessorBase Accessor1;
accessor Accessor2 = {1};
stream Stream2;
cl::sycl::sampler Sampler1;
sampler Sampler2;

myQueue.submit([&](cl::sycl::handler &h) {
h.single_task<class kernel_function1>([=]() {
Accessor1.acc.use();
});
h.single_task<class kernel_function2>([=]() {
int a = Accessor2.field;
});

cl::sycl::stream Stream1{0, 0, SH};
h.single_task<class kernel_function3>([=]() {
int a = Stream2.field;
});

h.single_task<class kernelfunction4>([=] {
Sampler1.use();
});

h.single_task<class kernelfunction5>([=] {
int a = Sampler2.field;
});

});

return 0;
}

// CHECK: %[[RANGE_TYPE:"struct.*cl::sycl::range"]]
// CHECK: %[[ID_TYPE:"struct.*cl::sycl::id"]]
// CHECK: define dso_local spir_kernel void @{{.*}}kernel_function1
// CHECK-SAME: i32 [[ARG_A:%[a-zA-Z0-9_]+]],
// CHECK-SAME: i32 addrspace(1)* [[ACC1_DATA:%[a-zA-Z0-9_]+]],
// CHECK-SAME: %[[RANGE_TYPE]]* byval(%[[RANGE_TYPE]]) align 4 [[ACC1_DATA:%[a-zA-Z0-9_]+]],
// CHECK-SAME: %[[RANGE_TYPE]]* byval(%[[RANGE_TYPE]]) align 4 [[ACC2_DATA:%[a-zA-Z0-9_]+]],
// CHECK-SAME: %[[ID_TYPE]]* byval(%[[ID_TYPE]]) align 4 [[ACC3_DATA:%[a-zA-Z0-9_]+]])

// CHECK: [[ACC_FIELD:%[a-zA-Z0-9_]+]] = getelementptr inbounds %class.{{.*}}.AccessorBase, %class.{{.*}}.AccessorBase addrspace(4)* %3, i32 0, i32 1
// CHECK: call spir_func void @_ZN2cl4sycl8accessorIiLi1ELNS0_6access4modeE1026ELNS2_6targetE2016ELNS2_11placeholderE0EEC1Ev(%"class.{{.*}}.cl::sycl::accessor" addrspace(4)* align 4 dereferenceable_or_null(12) [[ACC_FIELD]])

// CHECK: [[ACC1_FIELD:%[a-zA-Z0-9_]+]] = getelementptr inbounds %class{{.*}}.AccessorBase, %class{{.*}}.AccessorBase addrspace(4)* %5, i32 0, i32 1
// CHECK: [[ACC1_DATA_LOAD:%[a-zA-Z0-9_]+]] = load i32 addrspace(1)*, i32 addrspace(1)* addrspace(4)* %_arg_acc.addr.ascast, align 8
// CHECK: call spir_func void @{{.*}}__init{{.*}}(%"class{{.*}}cl::sycl::accessor" addrspace(4)* {{.*}} [[ACC1_FIELD]], i32 addrspace(1)* [[ACC1_DATA_LOAD]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test missed the checks for the code produced by kernel_function2, kernel_function3, kernel_function4, kernel_function5


8 changes: 4 additions & 4 deletions clang/test/SemaSYCL/Inputs/sycl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ struct DeviceValueType<dataT, access::target::local> {
template <typename dataT, int dimensions, access::mode accessmode,
access::target accessTarget = access::target::global_buffer,
access::placeholder isPlaceholder = access::placeholder::false_t>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you accidentally removed typename propertyListT = ONEAPI::accessor_property_list<>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elizabethandrews That's the next thing I am trying to understand. Do all 3 classes (accessor, sampler and stream) have a property_list? What's the purpose of it?

__attribute__((sycl_special_class(accessor))) class accessor {
class __attribute__((sycl_special_class(accessor))) accessor {

public:
void use(void) const {}
Expand Down Expand Up @@ -162,7 +162,7 @@ struct _ImageImplT {
};

template <typename dataT, int dimensions, access::mode accessmode>
__attribute__((sycl_special_class(accessor))) class accessor<dataT, dimensions, accessmode, access::target::image, access::placeholder::false_t> {
class __attribute__((sycl_special_class(accessor))) accessor<dataT, dimensions, accessmode, access::target::image, access::placeholder::false_t> {
public:
void use(void) const {}
template <typename... T>
Expand All @@ -181,7 +181,7 @@ struct sampler_impl {
#endif
};

__attribute__((sycl_special_class(sampler))) class sampler {
class __attribute__((sycl_special_class(sampler))) sampler {
struct sampler_impl impl;
#ifdef __SYCL_DEVICE_ONLY__
void __init(__ocl_sampler_t Sampler) { impl.m_Sampler = Sampler; }
Expand Down Expand Up @@ -285,7 +285,7 @@ class handler {
}
};

class stream {
class __attribute__((sycl_special_class(stream))) stream {
accessor<int, 1, access::mode::read> acc;

public:
Expand Down
12 changes: 12 additions & 0 deletions clang/test/SemaSYCL/sampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ int main() {
return 0;
}

// CHECK: ClassTemplateDecl {{.*}} accessor
bader marked this conversation as resolved.
Show resolved Hide resolved
// CHECK: SYCLSpecialClassAttr {{.*}} Accessor
// CHECK: CXXRecordDecl {{.*}} implicit class accessor
// CHECK: AccessSpecDecl {{.*}} public
// CHECK: CXXMethodDecl {{.*}} use 'void () const'
// CHECK: ClassTemplateSpecializationDecl {{.*}} class accessor definition
// CHECK: SYCLSpecialClassAttr {{.*}} Accessor
// CHECK: CXXRecordDecl {{.*}} implicit class accessor
// CHECK: AccessSpecDecl {{.*}} public
// CHECK: CXXMethodDecl {{.*}} use 'void () const'
// CHECK: CXXMethodDecl {{.*}} use 'void (void *) const'

// Check declaration of the test kernel
// CHECK: FunctionDecl {{.*}}SamplerLambda{{.*}} 'void (sampler_t)'
//
Expand Down
87 changes: 87 additions & 0 deletions clang/test/SemaSYCL/special-classes.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// RUN: %clang_cc1 -S -fsycl-is-device -internal-isystem %S/Inputs -triple spir64 -ast-dump -sycl-std=2020 %s | FileCheck %s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if following flags are necessary:

  • -S I think -ast-dump provides the output we check in the test
  • -triple spir64 according to my understanding target triple doesn't impact AST, although it's required for CodeGen tests, it can be omitted in Sema tests.
  • -sycl-std=2020 Isn't SYCL 2020 a default version?


bader marked this conversation as resolved.
Show resolved Hide resolved
#include "sycl.hpp"

sycl::queue myQueue;
sycl::handler H;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why these are declared as a global objects instead of main function scope?


class AccessorBase {
int A;
public:
sycl::accessor<int, 1, sycl::access::mode::read_write,
sycl::access::target::local>
acc;
};

class accessor {
public:
int field;
};

class stream {
public:
int field;
};

class sampler {
public:
int field;
};

int main() {

AccessorBase Accessor1;
accessor Accessor2 = {1};
sycl::stream Stream1{0, 0, H};
stream Stream2;
sycl::sampler Sampler1;
sampler Sampler2;

myQueue.submit([&](sycl::handler &h) {
h.single_task<class kernel_function1>([=]() {
Accessor1.acc.use();
});
h.single_task<class kernel_function2>([=]() {
int a = Accessor2.field;
});

h.single_task<class kernel_function3>([=]() {
Stream1.use();
});
h.single_task<class kernel_function4>([=]() {
int a = Stream2.field;
});

h.single_task<class kernelfunction5>([=] {
Sampler1.use();
});

h.single_task<class kernelfunction6>([=] {
int a = Sampler2.field;
});

});

return 0;
}

// CHECK: ClassTemplateDecl {{.*}} accessor
// CHECK: CXXRecordDecl {{.*}} class accessor definition
// CHECK: SYCLSpecialClassAttr {{.*}} Accessor
// CHECK: CXXRecordDecl {{.*}} implicit class accessor

// CHECK: ClassTemplateSpecializationDecl {{.*}} class accessor definition
// CHECK: SYCLSpecialClassAttr{{.*}} Accessor
// CHECK: CXXRecordDecl {{.*}} prev {{.*}} implicit class accessor

// CHECK: ClassTemplateSpecializationDecl {{.*}} class accessor definition
// CHECK: SYCLSpecialClassAttr{{.*}} Accessor
// CHECK: CXXRecordDecl {{.*}} prev {{.*}} implicit class accessor

// CHECK: CXXRecordDecl {{.*}} referenced class sampler definition
// CHECK: SYCLSpecialClassAttr {{.*}} Sampler
// CHECK: CXXRecordDecl {{.*}} implicit class sampler

// CHECK: CXXRecordDecl {{.*}} prev {{.*}} referenced class stream definition
// CHECK: SYCLSpecialClassAttr {{.*}} Stream
// CHECK: CXXRecordDecl {{.*}} implicit referenced class stream
6 changes: 3 additions & 3 deletions sycl/include/CL/sycl/accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1787,7 +1787,7 @@ accessor(buffer<DataT, Dimensions, AllocatorT>, handler, Type1, Type2, Type3,
/// \ingroup sycl_api_acc
template <typename DataT, int Dimensions, access::mode AccessMode,
access::placeholder IsPlaceholder>
__SYCL_SPECIAL_CLASS(accessor) class accessor<
class __SYCL_SPECIAL_CLASS(accessor) accessor<
DataT, Dimensions, AccessMode, access::target::local, IsPlaceholder> :
#ifndef __SYCL_DEVICE_ONLY__
public detail::LocalAccessorBaseHost,
Expand Down Expand Up @@ -1982,7 +1982,7 @@ __SYCL_SPECIAL_CLASS(accessor) class accessor<
/// \ingroup sycl_api_acc
template <typename DataT, int Dimensions, access::mode AccessMode,
access::placeholder IsPlaceholder>
__SYCL_SPECIAL_CLASS(accessor) class accessor<
class __SYCL_SPECIAL_CLASS(accessor) accessor<
DataT, Dimensions, AccessMode, access::target::image, IsPlaceholder>
: public detail::image_accessor<DataT, Dimensions, AccessMode,
access::target::image, IsPlaceholder> {
Expand Down Expand Up @@ -2072,7 +2072,7 @@ class accessor<DataT, Dimensions, AccessMode, access::target::host_image,
/// \ingroup sycl_api_acc
template <typename DataT, int Dimensions, access::mode AccessMode,
access::placeholder IsPlaceholder>
__SYCL_SPECIAL_CLASS(accessor) class accessor<
class __SYCL_SPECIAL_CLASS(accessor) accessor<
DataT, Dimensions, AccessMode, access::target::image_array, IsPlaceholder>
: public detail::image_accessor<DataT, Dimensions + 1, AccessMode,
access::target::image, IsPlaceholder> {
Expand Down