-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL][NATIVECPU] Fix local scope module variables for native cpu (#1…
…5280) Although local scope variables inside the kernel are less common in SYCL, they can happen with hierarchical. This fixes the problem by adding a pass to replace the local scope variables which start life as globals with a struct which is allocated on the stack. Additionally, this required updating of the code which renames and removes kernel based on wrappers and vecz success. To simplify this we run the OCK utility pass TransferKernelMetadata which adds metadata to store the original kernel name. This in turn simplifies this code significantly. Note this fixes fails in kernel/kernel_attributes_wg_hint.cpp SYCL CTS for native cpu, which is being tested locally.
- Loading branch information
Showing
3 changed files
with
54 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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 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
39 changes: 39 additions & 0 deletions
39
sycl/test/check_device_code/native_cpu/local_module_scope.cpp
This file contains 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,39 @@ | ||
// REQUIRES: native_cpu_ock | ||
|
||
// RUN: %clangxx -fsycl -fsycl-targets=native_cpu -Xclang -sycl-std=2020 -mllvm -sycl-opt -mllvm -inline-threshold=500 -mllvm -sycl-native-cpu-no-vecz -mllvm -sycl-native-dump-device-ir %s | FileCheck %s | ||
|
||
// Check that local types structure is created and placed on the stack | ||
// We also check that the attribute mux-orig-fn is created as this is needed to | ||
// find the original function after this pass is run | ||
|
||
// CHECK: %localVarTypes = type { ptr addrspace(1) } | ||
// CHECK: define void @_ZTS4TestILi1ELi4EiE.NativeCPUKernel{{.*}} #[[ATTR:[0-9]*]] | ||
// CHECK: alloca %localVarTypes | ||
// CHECK: attributes #[[ATTR]] = {{.*}} "mux-orig-fn"="_ZTS4TestILi1ELi4EiE" | ||
|
||
#include "sycl.hpp" | ||
|
||
template <int dims, int size, typename T = int> struct Test; | ||
|
||
int main() { | ||
sycl::queue queue; | ||
|
||
constexpr int dims = 1; | ||
constexpr int size = 4; | ||
|
||
std::array<int, size> data; | ||
|
||
const auto range = sycl::range<dims>(size); | ||
const auto range_wg = sycl::range<dims>(1); | ||
{ | ||
sycl::buffer<int, dims> buf(data.data(), range); | ||
|
||
queue.submit([&](sycl::handler &cgh) { | ||
auto acc = sycl::accessor(buf, cgh, sycl::write_only); | ||
cgh.parallel_for_work_group<Test<dims, size>>( | ||
range, range_wg, [=](auto group) { acc[group.get_group_id()] = 42; }); | ||
}); | ||
queue.wait_and_throw(); | ||
} | ||
return 0; | ||
} |