Skip to content

[SYCL][Fusion] Do not internalize stored argument pointers #8376

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
merged 2 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion sycl-fusion/passes/internalization/Internalization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,15 @@ Error SYCLInternalizerImpl::canPromoteValue(Value *Val,
}
break;
case Instruction::Load:
case Instruction::Store:
// Do not need to change anything here.
break;
case Instruction::Store:
if (Val == cast<StoreInst>(I)->getValueOperand()) {
return createStringError(
inconvertibleErrorCode(),
"It is not safe to promote values being stored to another pointer");
}
break;
default:
return createStringError(inconvertibleErrorCode(),
"Do not know how to handle value to promote");
Expand Down
11 changes: 11 additions & 0 deletions sycl-fusion/test/internalization/abort-kernel-info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
Kernels:
- KernelName: _ZTSZZ4mainENKUlRN4sycl3_V17handlerEE_clES2_E9KernelOne
Args:
Kinds: [ Accessor ]
Mask: [ 1 ]
BinInfo:
Format: SPIRV
AddressBits: 0
BinarySize: 10612
...
37 changes: 37 additions & 0 deletions sycl-fusion/test/internalization/abort-promote-stored-ptr.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
; RUN: opt -load-pass-plugin %shlibdir/SYCLKernelFusion%shlibext\
; RUN: -passes=sycl-internalization --sycl-info-path %S/abort-kernel-info.yaml -S %s -debug 2>&1 | FileCheck %s

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"
target triple = "spir64-unknown-unknown"

; CHECK: Unable to perform all promotions for function fused_0. Detailed information:
; CHECK: Failed to promote argument 0 of function fused_0: It is not safe to promote values being stored to another pointer

; CHECK-LABEL: define {{[^@]+}}@fused_0
; CHECK-SAME: (float addrspace(1)* align 4 %[[ACC:.*]])
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 {
; Scenario: Test private internalization is not performed when the
; input pointer is stored in another pointer.

; CHECK-NEXT: %[[ALLOCA:.*]] = alloca float addrspace(1)*, align 8
; CHECK-NEXT: store float addrspace(1)* %[[ACC]], float addrspace(1)** %[[ALLOCA]], align 8
; CHECK-NEXT: %[[ACC_PTR:.*]] = load float addrspace(1)*, float addrspace(1)** %[[ALLOCA]], align 8
; CHECK-NEXT: store float 7.000000e+00, float addrspace(1)* %[[ACC]], align 4
; CHECK-NEXT: %[[RES:.*]] = load float, float addrspace(1)* %[[ACC]], align 4
; CHECK-NEXT: ret void

%alloca = alloca float addrspace(1)*
store float addrspace(1)* %acc, float addrspace(1)** %alloca
%acc_ptr = load float addrspace(1)*, float addrspace(1)** %alloca
store float 7.0, float addrspace(1)* %acc
%res = load float, float addrspace(1)* %acc
ret void
}

!12 = !{i32 1}
!13 = !{!"none"}
!14 = !{!"float*"}
!15 = !{!""}
!16 = !{!"acc"}
!17 = !{!"private"}
!18 = !{i64 1}