File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
llvm/lib/SYCLLowerIR/ESIMD Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -635,6 +635,12 @@ size_t lowerSLMReservationCalls(Module &M) {
635
635
// - now set each kernel's SLMSize metadata to the pre-calculated value
636
636
for (auto &E : Kernel2MaxSLM) {
637
637
int MaxSLM = E.second ;
638
+ // Clamp negative values to 0. MaxSLM could have been not estimated, e.g.
639
+ // due to having __esimd_slm_init with non-const operand (specialization
640
+ // constant case). VC backend will use size provided in __esimd_slm_init
641
+ // if it is greater than value provided in metadata.
642
+ if (MaxSLM < 0 )
643
+ MaxSLM = 0 ;
638
644
llvm::Value *MaxSLMv =
639
645
llvm::ConstantInt::get (Type::getInt32Ty (M.getContext ()), MaxSLM);
640
646
const Function *Kernel = E.first ;
Original file line number Diff line number Diff line change
1
+ // RUN: %clangxx -O2 -fsycl -fsycl-device-only -Xclang -emit-llvm %s -o %t
2
+ // RUN: sycl-post-link -split-esimd -lower-esimd -O2 -S %t -o %t.table
3
+ // RUN: FileCheck %s -input-file=%t_esimd_0.ll
4
+
5
+ // Checks that we set 0 as VCSLMSize when slm_init is used with
6
+ // non-constant operand, like with specialization constant.
7
+
8
+ #include < sycl/detail/image_ocl_types.hpp>
9
+ #include < sycl/ext/intel/esimd.hpp>
10
+ #include < sycl/sycl.hpp>
11
+
12
+ using namespace sycl ::ext::intel::esimd;
13
+ using namespace sycl ::ext::intel::experimental::esimd;
14
+
15
+ constexpr sycl::specialization_id<uint64_t > Size (1024 );
16
+
17
+ int main () {
18
+ sycl::queue queue;
19
+ {
20
+ queue.submit ([&](sycl::handler &cgh) {
21
+ cgh.single_task <class Kernel3Name >(
22
+ [=](sycl::kernel_handler kh) SYCL_ESIMD_KERNEL {
23
+ slm_init (kh.get_specialization_constant <Size>());
24
+ });
25
+ // CHECK: define weak_odr dso_local spir_kernel void @{{.*}}(i8 addrspace(1)* noundef align 1 "VCArgumentIOKind"="0" %{{.*}}) local_unnamed_addr #1
26
+ });
27
+ }
28
+
29
+ return 0 ;
30
+ }
31
+
32
+ // CHECK: attributes #1 = { {{.*}} "VCSLMSize"="0"
You can’t perform that action at this time.
0 commit comments