-
Notifications
You must be signed in to change notification settings - Fork 752
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
Changes from 1 commit
846e694
5e679f8
bdb1ff5
203edd6
dc74a5e
65ac140
6586846
a3c118b
30c5a03
3999939
c3f8757
ab4c68e
58db6b5
c009836
05b0af8
425bb97
890e4b0
89b49c8
b897a02
159b484
fe1450e
f7d9f31
9c59465
f4cfd63
b1b708e
ad5c50f
8771fb3
94b56df
68fb2b5
204cccb
59e5f0b
eb7997d
c34f5f2
ed896c6
5b95a01
8922d48
d439bfe
c37c9bb
2842545
87b5473
4b3fdde
f7b1782
170b344
5862f84
e7352f2
23ff551
c1b1a74
96f7cb5
aa8d164
7275b34
f308a4e
5950cd0
6a3589b
71e85cf
c2602c6
8db682d
9aa5193
81e7a4f
4bd54d7
e886e79
631e1f3
b912ab3
261def5
92375e4
f6efdec
999fea8
9fee895
1da2b10
f5e7918
5e4cdbc
c2a28d8
3be4eef
f0f382f
bdd04d7
e12eec1
bf22398
364fb99
62ea8ce
e4d66fc
e97af83
281e337
497b6ac
ddf8394
1896639
24c6f3a
2efd65d
cac1b20
ecbb2be
2116ca5
7b734e0
72c2b17
b8e840c
98463ad
7130ef4
c397857
30c3ca8
9696f11
730de70
f0e7cd9
b0297aa
a2595b9
ae23b63
4383f9f
179abad
b8dd5cf
b0356ce
4457a96
50a09ce
d7a5105
e0c44d3
a736a7f
71e8d97
949aead
462ff09
d170717
80cb0d6
1aa856c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Signed-off-by: Zahira Ammarguellat <zahira.ammarguellat@intel.com>
- Loading branch information
There are no files selected for viewing
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 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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]] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test missed the checks for the code produced by |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you accidentally removed There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 {} | ||
|
@@ -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> | ||
|
@@ -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; } | ||
|
@@ -285,7 +285,7 @@ class handler { | |
} | ||
}; | ||
|
||
class stream { | ||
class __attribute__((sycl_special_class(stream))) stream { | ||
accessor<int, 1, access::mode::read> acc; | ||
|
||
public: | ||
|
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if following flags are necessary:
|
||
|
||
bader marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#include "sycl.hpp" | ||
|
||
sycl::queue myQueue; | ||
sycl::handler H; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why these are declared as a global objects instead of |
||
|
||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for the one above, this makes the test less fragile.