-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Add new kernel-arg-runtime-aligned metadata. #5111
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
Merged
bader
merged 21 commits into
intel:sycl
from
srividya-sundaram:kernel-arg-runtime-aligned
Jan 18, 2022
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
0877490
[SYCL] Add kernel-arg-runtime-metadata for accessors
srividya-sundaram 5af8efc
Merge branch 'kernel-arg-runtime-aligned' of https://github.com/srivi…
srividya-sundaram 9f8e2a7
Add test
srividya-sundaram 9c1294c
Generate 1 bit integer
srividya-sundaram cca76ad
Update test
srividya-sundaram f515686
Address review comments
srividya-sundaram 062f67b
Add comment
srividya-sundaram 37f5d6a
Fix tests
srividya-sundaram 50fa645
Remove unrelated changes
srividya-sundaram 5d2755b
Remove unrelated change
srividya-sundaram 625f7ba
Remove unrelated change
srividya-sundaram bb8b8a3
Consolidate redundant attributes
srividya-sundaram 74a37bb
Remove extra line
srividya-sundaram 1353919
Address review comments
srividya-sundaram c31d93e
Fix clang-format
srividya-sundaram a95a498
Add test case for accessor and raw ptr
srividya-sundaram 093959f
Add ESIMD test case
srividya-sundaram f71552e
Modify comment
srividya-sundaram a67543b
Fix clang format
srividya-sundaram ddde72a
Merge branch 'sycl' into kernel-arg-runtime-aligned
srividya-sundaram 3575bb3
Update kernel-arg-accessor-pointer.cpp
srividya-sundaram File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -triple spir64-unknown-unknown -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s | ||
|
||
// This test checks if the metadata "kernel-arg-runtime-aligned" | ||
// is generated if the kernel captures an accessor. | ||
|
||
#include "sycl.hpp" | ||
|
||
using namespace cl::sycl; | ||
|
||
queue q; | ||
|
||
int main() { | ||
|
||
using Accessor = | ||
accessor<int, 1, access::mode::read_write, access::target::global_buffer>; | ||
Accessor acc[2]; | ||
srividya-sundaram marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
accessor<int, 1, access::mode::read, access::target::global_buffer> readOnlyAccessor; | ||
|
||
accessor<float, 2, access::mode::write, | ||
access::target::local, | ||
access::placeholder::true_t> | ||
acc3; | ||
|
||
// kernel_A parameters : int*, sycl::range<1>, sycl::range<1>, sycl::id<1>, | ||
// int*, sycl::range<1>, sycl::range<1>,sycl::id<1>. | ||
q.submit([&](handler &h) { | ||
h.single_task<class kernel_A>([=]() { | ||
acc[1].use(); | ||
}); | ||
}); | ||
|
||
// kernel_readOnlyAcc parameters : int*, sycl::range<1>, sycl::range<1>, sycl::id<1>. | ||
q.submit([&](handler &h) { | ||
elizabethandrews marked this conversation as resolved.
Show resolved
Hide resolved
|
||
h.single_task<class kernel_readOnlyAcc>([=]() { | ||
readOnlyAccessor.use(); | ||
}); | ||
}); | ||
|
||
// kernel_B parameters : none. | ||
q.submit([&](handler &h) { | ||
h.single_task<class kernel_B>([=]() { | ||
int result = 5; | ||
}); | ||
}); | ||
|
||
int a = 10; | ||
|
||
// kernel_C parameters : int. | ||
q.submit([&](handler &h) { | ||
h.single_task<class kernel_C>([=]() { | ||
int x = a; | ||
}); | ||
}); | ||
|
||
// Using raw pointers to represent USM pointers. | ||
// kernel_arg_runtime_aligned is not generated for raw pointers. | ||
int *x; | ||
float *y; | ||
q.submit([&](handler &h) { | ||
h.single_task<class usm_ptr>([=]() { | ||
*x = 42; | ||
*y = 3.14; | ||
}); | ||
}); | ||
|
||
// Using local accessor as a kernel parameter. | ||
// kernel_arg_runtime_aligned is generated for pointers from local accessors. | ||
q.submit([&](handler &h) { | ||
h.single_task<class localAccessor>([=]() { | ||
acc3.use(); | ||
}); | ||
}); | ||
|
||
// kernel_acc_raw_ptr parameters : int*, sycl::range<1>, sycl::range<1>, sycl::id<1>, int*. | ||
int *rawPtr; | ||
q.submit([&](handler &h) { | ||
h.single_task<class kernel_acc_raw_ptr>([=]() { | ||
readOnlyAccessor.use(); | ||
*rawPtr = 10; | ||
}); | ||
}); | ||
|
||
// Check if kernel_arg_accessor_ptr metadata is generated for ESIMD kernels that capture | ||
// an accessor. | ||
q.submit([&](handler &h) { | ||
h.single_task<class esimd_kernel_with_acc>([=]() __attribute__((sycl_explicit_simd)) { | ||
readOnlyAccessor.use(); | ||
}); | ||
}); | ||
} | ||
|
||
// Check kernel_A parameters | ||
// CHECK: define {{.*}}spir_kernel void @{{.*}}kernel_A | ||
// CHECK-SAME: i32 addrspace(1)* [[MEM_ARG1:%[a-zA-Z0-9_]+]], | ||
// CHECK-SAME: %"struct.cl::sycl::range"* byval{{.*}}align 4 [[ACC_RANGE1:%[a-zA-Z0-9_]+_1]], | ||
// CHECK-SAME: %"struct.cl::sycl::range"* byval{{.*}}align 4 [[MEM_RANGE1:%[a-zA-Z0-9_]+_2]], | ||
// CHECK-SAME: %"struct.cl::sycl::id"* byval{{.*}}align 4 [[OFFSET1:%[a-zA-Z0-9_]+_3]], | ||
// CHECK-SAME: i32 addrspace(1)* [[MEM_ARG2:%[a-zA-Z0-9_]+_4]], | ||
// CHECK-SAME: %"struct.cl::sycl::range"* byval{{.*}}align 4 [[ACC_RANGE2:%[a-zA-Z0-9_]+_6]], | ||
// CHECK-SAME: %"struct.cl::sycl::range"* byval{{.*}}align 4 [[MEM_RANGE2:%[a-zA-Z0-9_]+_7]], | ||
// CHECK-SAME: %"struct.cl::sycl::id"* byval{{.*}}align 4 [[OFFSET2:%[a-zA-Z0-9_]+_8]]) | ||
// CHECK-SAME: !kernel_arg_runtime_aligned !5 | ||
|
||
// Check kernel_readOnlyAcc parameters | ||
// CHECK: define {{.*}}spir_kernel void @{{.*}}kernel_readOnlyAcc | ||
// CHECK-SAME: i32 addrspace(1)* readonly [[MEM_ARG1:%[a-zA-Z0-9_]+]], | ||
// CHECK-SAME: %"struct.cl::sycl::range"* byval{{.*}}align 4 [[ACC_RANGE1:%[a-zA-Z0-9_]+_1]], | ||
// CHECK-SAME: %"struct.cl::sycl::range"* byval{{.*}}align 4 [[MEM_RANGE1:%[a-zA-Z0-9_]+_2]], | ||
// CHECK-SAME: %"struct.cl::sycl::id"* byval{{.*}}align 4 [[OFFSET1:%[a-zA-Z0-9_]+_3]] | ||
// CHECK-SAME: !kernel_arg_runtime_aligned !14 | ||
|
||
// Check kernel_B parameters | ||
// CHECK: define {{.*}}spir_kernel void @{{.*}}kernel_B | ||
// CHECK-NOT: kernel_arg_runtime_aligned | ||
|
||
// Check kernel_C parameters | ||
// CHECK: define {{.*}}spir_kernel void @{{.*}}kernel_C | ||
// CHECK-SAME: i32 [[MEM_ARG1:%[a-zA-Z0-9_]+]] | ||
// CHECK-NOT: kernel_arg_runtime_aligned | ||
|
||
// Check usm_ptr parameters | ||
// CHECK: define {{.*}}spir_kernel void @{{.*}}usm_ptr | ||
// CHECK-SAME: i32 addrspace(1)* [[MEM_ARG1:%[a-zA-Z0-9_]+]], | ||
// CHECK-SAME: float addrspace(1)* [[MEM_ARG1:%[a-zA-Z0-9_]+]] | ||
// CHECK-NOT: kernel_arg_runtime_aligned | ||
|
||
// CHECK: define {{.*}}spir_kernel void @{{.*}}localAccessor | ||
// CHECK-SAME: float addrspace(1)* [[MEM_ARG1:%[a-zA-Z0-9_]+]], | ||
// CHECK-SAME: %"struct.cl::sycl::range.5"* byval{{.*}}align 4 [[ACC_RANGE1:%[a-zA-Z0-9_]+_1]], | ||
// CHECK-SAME: %"struct.cl::sycl::range.5"* byval{{.*}}align 4 [[MEM_RANGE1:%[a-zA-Z0-9_]+_2]], | ||
// CHECK-SAME: %"struct.cl::sycl::id.6"* byval{{.*}}align 4 [[OFFSET1:%[a-zA-Z0-9_]+_3]] | ||
// CHECK-SAME: !kernel_arg_runtime_aligned !14 | ||
|
||
// Check kernel_acc_raw_ptr parameters | ||
// CHECK: define {{.*}}spir_kernel void @{{.*}}kernel_acc_raw_ptr | ||
// CHECK-SAME: i32 addrspace(1)* readonly [[MEM_ARG1:%[a-zA-Z0-9_]+]], | ||
// CHECK-SAME: %"struct.cl::sycl::range"* byval{{.*}}align 4 [[ACC_RANGE1:%[a-zA-Z0-9_]+_1]], | ||
// CHECK-SAME: %"struct.cl::sycl::range"* byval{{.*}}align 4 [[MEM_RANGE1:%[a-zA-Z0-9_]+_2]], | ||
// CHECK-SAME: %"struct.cl::sycl::id"* byval{{.*}}align 4 [[OFFSET1:%[a-zA-Z0-9_]+_3]] | ||
// CHECK-SAME: i32 addrspace(1)* [[MEM_ARG1:%[a-zA-Z0-9_]+]] | ||
// CHECK-SAME: !kernel_arg_runtime_aligned !26 | ||
|
||
// Check esimd_kernel_with_acc parameters | ||
// CHECK: define {{.*}}spir_kernel void @{{.*}}esimd_kernel_with_acc | ||
// CHECK-SAME: !kernel_arg_accessor_ptr | ||
|
||
// Check kernel-arg-runtime-aligned metadata. | ||
// The value of any metadata element is 1 for any kernel arguments | ||
// that corresponds to the base pointer of an accessor and 0 otherwise. | ||
// CHECK: !5 = !{i1 true, i1 false, i1 false, i1 false, i1 true, i1 false, i1 false, i1 false} | ||
// CHECK: !14 = !{i1 true, i1 false, i1 false, i1 false} | ||
// CHECK: !26 = !{i1 true, i1 false, i1 false, i1 false, i1 false} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.