-
Notifications
You must be signed in to change notification settings - Fork 789
[SYCL] Lift restrictions on free-function kernels when compiling at runtime #15892
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
sommerlukas
merged 8 commits into
intel:sycl
from
sommerlukas:skip-integration-header-ff-kernels
Nov 6, 2024
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
44ad31f
Omit free-function kernels from integration header
sommerlukas ef81032
Add test for RTC mode
sommerlukas b49f05b
Simplify option forwarding
sommerlukas f22abba
Code formatting
sommerlukas 40baf92
Address PR feedback
sommerlukas 3ce13f7
Address more PR feedback
sommerlukas bc9d7bb
Add driver forwarding test
sommerlukas 7596ad8
Merge branch 'sycl' into skip-integration-header-ff-kernels
sommerlukas 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
80 changes: 80 additions & 0 deletions
80
clang/test/CodeGenSYCL/free_function_int_header_rtc_mode.cpp
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,80 @@ | ||
// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -triple spir64-unknown-unknown -sycl-std=2020 -fsycl-rtc-mode -fsycl-int-header=%t.rtc.h %s | ||
// RUN: FileCheck -input-file=%t.rtc.h --check-prefixes=CHECK,CHECK-RTC %s | ||
|
||
// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -triple spir64-unknown-unknown -sycl-std=2020 -fno-sycl-rtc-mode -fsycl-int-header=%t.nortc.h %s | ||
// RUN: FileCheck -input-file=%t.nortc.h --check-prefixes=CHECK,CHECK-NORTC %s | ||
|
||
// This test checks that free-function kernel information is included or | ||
// excluded from the integration header, depending on the '-fsycl-rtc-mode' | ||
// flag. | ||
|
||
#include "sycl.hpp" | ||
|
||
[[__sycl_detail__::add_ir_attributes_function("sycl-single-task-kernel", 2)]] | ||
void free_function_single(int* ptr, int start, int end){ | ||
for(int i = start; i < end; ++i){ | ||
ptr[i] = start + 66; | ||
} | ||
} | ||
|
||
[[__sycl_detail__::add_ir_attributes_function("sycl-nd-range-kernel", 2)]] | ||
void free_function_nd_range(int* ptr, int start, int end){ | ||
for(int i = start; i < end; ++i){ | ||
ptr[i] = start + 66; | ||
} | ||
} | ||
|
||
template<typename KernelName, typename KernelFunc> | ||
__attribute__((sycl_kernel)) void kernel(const KernelFunc &kernelFunc){ | ||
kernelFunc(); | ||
} | ||
|
||
int main(){ | ||
sycl::accessor<int, 1, sycl::access::mode::read_write> accessorA; | ||
kernel<class Kernel_Function>( | ||
[=]() { | ||
accessorA.use(); | ||
}); | ||
return 0; | ||
} | ||
|
||
|
||
// CHECK: const char* const kernel_names[] = { | ||
// CHECK-NEXT: "{{.*}}__sycl_kernel_free_function_singlePiii", | ||
// CHECK-NEXT: "{{.*}}__sycl_kernel_free_function_nd_rangePiii", | ||
// CHECK-NEXT: "{{.*}}Kernel_Function", | ||
|
||
|
||
// CHECK: static constexpr const char* getName() { return "{{.*}}__sycl_kernel_free_function_singlePiii"; } | ||
// CHECK: static constexpr const char* getName() { return "{{.*}}__sycl_kernel_free_function_nd_rangePiii"; } | ||
// CHECK: static constexpr const char* getName() { return "{{.*}}Kernel_Function"; } | ||
|
||
// CHECK-RTC-NOT: free_function_single_kernel | ||
// CHECK-RTC-NOT: free_function_nd_range | ||
|
||
// CHECK-NORTC: void free_function_single(int *ptr, int start, int end); | ||
// CHECK-NORTC: static constexpr auto __sycl_shim[[#FIRST:]]() | ||
// CHECK-NORTC-NEXT: return (void (*)(int *, int, int))free_function_single; | ||
|
||
// CHECK-NORTC: struct ext::oneapi::experimental::is_kernel<__sycl_shim[[#FIRST]]()> { | ||
// CHECK-NORTC-NEXT: static constexpr bool value = true; | ||
|
||
// CHECK-NORTC: struct ext::oneapi::experimental::is_single_task_kernel<__sycl_shim[[#FIRST]]()> { | ||
// CHECK-NORTC-NEXT: static constexpr bool value = true; | ||
|
||
|
||
// CHECK-NORTC: void free_function_nd_range(int *ptr, int start, int end); | ||
// CHECK-NORTC: static constexpr auto __sycl_shim[[#SECOND:]]() { | ||
// CHECK-NORTC-NEXT: return (void (*)(int *, int, int))free_function_nd_range; | ||
|
||
// CHECK-NORTC: struct ext::oneapi::experimental::is_kernel<__sycl_shim[[#SECOND]]()> { | ||
// CHECK-NORTC-NEXT: static constexpr bool value = true; | ||
|
||
// CHECK-NORTC: struct ext::oneapi::experimental::is_nd_range_kernel<__sycl_shim2(), 2> { | ||
// CHECK-NORTC-NEXT: static constexpr bool value = true; | ||
|
||
// CHECK-NORTC: kernel_id ext::oneapi::experimental::get_kernel_id<__sycl_shim[[#FIRST]]()>() { | ||
// CHECK-NORTC-NEXT: return sycl::detail::get_kernel_id_impl(std::string_view{"{{.*}}__sycl_kernel_free_function_singlePiii"}); | ||
|
||
// CHECK-NORTC: kernel_id ext::oneapi::experimental::get_kernel_id<__sycl_shim[[#SECOND]]()>() { | ||
// CHECK-NORTC-NEXT: return sycl::detail::get_kernel_id_impl(std::string_view{"{{.*}}__sycl_kernel_free_function_nd_rangePiii"}); |
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,32 @@ | ||
/// | ||
/// Perform driver test for SYCL RTC mode. | ||
/// | ||
|
||
/// Check that the '-fsycl-rtc-mode' is correctly forwarded to the device | ||
/// compilation and only to the device compilation. | ||
|
||
// RUN: %clangxx -fsycl -fsycl-rtc-mode --no-offload-new-driver %s -### 2>&1 \ | ||
// RUN: | FileCheck %s | ||
|
||
// RUN: %clangxx -fsycl -fsycl-rtc-mode --offload-new-driver %s -### 2>&1 \ | ||
// RUN: | FileCheck %s | ||
|
||
// CHECK: clang{{.*}} "-fsycl-is-device" | ||
// CHECK-SAME: -fsycl-rtc-mode | ||
// CHECK: clang{{.*}} "-fsycl-is-host" | ||
// CHECK-NOT: -fsycl-rtc-mode | ||
|
||
|
||
/// Check that the '-fno-sycl-rtc-mode' is correctly forwarded to the device | ||
/// compilation and only to the device compilation. | ||
|
||
// RUN: %clangxx -fsycl -fno-sycl-rtc-mode --no-offload-new-driver %s -### 2>&1 \ | ||
// RUN: | FileCheck %s --check-prefix=NEGATIVE | ||
|
||
// RUN: %clangxx -fsycl -fno-sycl-rtc-mode --offload-new-driver %s -### 2>&1 \ | ||
// RUN: | FileCheck %s --check-prefix=NEGATIVE | ||
|
||
// NEGATIVE: clang{{.*}} "-fsycl-is-device" | ||
// NEGATIVE-SAME: -fno-sycl-rtc-mode | ||
// NEGATIVE: clang{{.*}} "-fsycl-is-host" | ||
// NEGATIVE-NOT: -fsycl-rtc-mode |
Oops, something went wrong.
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.