Skip to content

Commit 570dc5e

Browse files
victor-edsbader
andauthored
[SYCL][Fusion] Do not internalize stored argument pointers (#8376)
When a pointer to be promoted is stored, internalization is no longer safe to perform. In this case, simply bail out and do not promote the given pointer. Signed-off-by: Victor Perez <[email protected]> Co-authored-by: Alexey Bader <[email protected]>
1 parent 1b22544 commit 570dc5e

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

sycl-fusion/passes/internalization/Internalization.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,15 @@ Error SYCLInternalizerImpl::canPromoteValue(Value *Val,
285285
}
286286
break;
287287
case Instruction::Load:
288-
case Instruction::Store:
289288
// Do not need to change anything here.
290289
break;
290+
case Instruction::Store:
291+
if (Val == cast<StoreInst>(I)->getValueOperand()) {
292+
return createStringError(
293+
inconvertibleErrorCode(),
294+
"It is not safe to promote values being stored to another pointer");
295+
}
296+
break;
291297
default:
292298
return createStringError(inconvertibleErrorCode(),
293299
"Do not know how to handle value to promote");
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
Kernels:
3+
- KernelName: _ZTSZZ4mainENKUlRN4sycl3_V17handlerEE_clES2_E9KernelOne
4+
Args:
5+
Kinds: [ Accessor ]
6+
Mask: [ 1 ]
7+
BinInfo:
8+
Format: SPIRV
9+
AddressBits: 0
10+
BinarySize: 10612
11+
...
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
; RUN: opt -load-pass-plugin %shlibdir/SYCLKernelFusion%shlibext\
2+
; RUN: -passes=sycl-internalization --sycl-info-path %S/abort-kernel-info.yaml -S %s -debug 2>&1 | FileCheck %s
3+
4+
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024"
5+
target triple = "spir64-unknown-unknown"
6+
7+
; CHECK: Unable to perform all promotions for function fused_0. Detailed information:
8+
; CHECK: Failed to promote argument 0 of function fused_0: It is not safe to promote values being stored to another pointer
9+
10+
; CHECK-LABEL: define {{[^@]+}}@fused_0
11+
; CHECK-SAME: (float addrspace(1)* align 4 %[[ACC:.*]])
12+
define spir_kernel void @fused_0(float addrspace(1)* align 4 %acc) !kernel_arg_addr_space !12 !kernel_arg_access_qual !13 !kernel_arg_type !14 !kernel_arg_type_qual !15 !kernel_arg_base_type !14 !kernel_arg_name !16 !sycl.kernel.promote !17 !sycl.kernel.promote.localsize !18 {
13+
; Scenario: Test private internalization is not performed when the
14+
; input pointer is stored in another pointer.
15+
16+
; CHECK-NEXT: %[[ALLOCA:.*]] = alloca float addrspace(1)*, align 8
17+
; CHECK-NEXT: store float addrspace(1)* %[[ACC]], float addrspace(1)** %[[ALLOCA]], align 8
18+
; CHECK-NEXT: %[[ACC_PTR:.*]] = load float addrspace(1)*, float addrspace(1)** %[[ALLOCA]], align 8
19+
; CHECK-NEXT: store float 7.000000e+00, float addrspace(1)* %[[ACC]], align 4
20+
; CHECK-NEXT: %[[RES:.*]] = load float, float addrspace(1)* %[[ACC]], align 4
21+
; CHECK-NEXT: ret void
22+
23+
%alloca = alloca float addrspace(1)*
24+
store float addrspace(1)* %acc, float addrspace(1)** %alloca
25+
%acc_ptr = load float addrspace(1)*, float addrspace(1)** %alloca
26+
store float 7.0, float addrspace(1)* %acc
27+
%res = load float, float addrspace(1)* %acc
28+
ret void
29+
}
30+
31+
!12 = !{i32 1}
32+
!13 = !{!"none"}
33+
!14 = !{!"float*"}
34+
!15 = !{!""}
35+
!16 = !{!"acc"}
36+
!17 = !{!"private"}
37+
!18 = !{i64 1}

0 commit comments

Comments
 (0)