AMDGPU: Write LDS objects out as global symbols in code generation
Summary:
The symbols use the processor-specific SHN_AMDGPU_LDS section index
introduced with a previous change. The linker is then expected to resolve
relocations, which are also emitted.
Initially disabled for HSA and PAL environments until they have caught up
in terms of linker and runtime loader.
Some notes:
- The llvm.amdgcn.groupstaticsize intrinsics can no longer be lowered
to a constant at compile times, which means some tests can no longer
be applied.
The current "solution" is a terrible hack, but the intrinsic isn't
used by Mesa, so we can keep it for now.
- We no longer know the full LDS size per kernel at compile time, which
means that we can no longer generate a relevant error message at
compile time. It would be possible to add a check for the size of
individual variables, but ultimately the linker will have to perform
the final check.
Change-Id: If66dbf33fccfbf3609aefefa2558ac0850d42275
Reviewers: arsenm, rampitec, t-tye, b-sumner, jsjodin
Subscribers: qcolombet, kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D61494
llvm-svn: 364297
2019-06-25 19:52:30 +08:00
|
|
|
; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck -check-prefixes=CHECK,NOHSA %s
|
|
|
|
; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=kaveri -verify-machineinstrs < %s | FileCheck -check-prefixes=CHECK,HSA %s
|
|
|
|
; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=fiji -verify-machineinstrs < %s | FileCheck -check-prefixes=CHECK,HSA %s
|
2016-03-16 01:28:44 +08:00
|
|
|
|
2020-07-27 03:43:48 +08:00
|
|
|
; RUN: llc -global-isel -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck -check-prefixes=CHECK,NOHSA %s
|
|
|
|
; RUN: llc -global-isel -mtriple=amdgcn--amdhsa -mcpu=kaveri -verify-machineinstrs < %s | FileCheck -check-prefixes=CHECK,HSA %s
|
|
|
|
; RUN: llc -global-isel -mtriple=amdgcn--amdhsa -mcpu=fiji -verify-machineinstrs < %s | FileCheck -check-prefixes=CHECK,HSA %s
|
|
|
|
|
2016-03-16 01:28:44 +08:00
|
|
|
@lds0 = addrspace(3) global [512 x float] undef, align 4
|
|
|
|
@lds1 = addrspace(3) global [256 x float] undef, align 4
|
|
|
|
|
2016-07-23 01:01:33 +08:00
|
|
|
@large = addrspace(3) global [4096 x i32] undef, align 4
|
|
|
|
|
2016-07-19 07:09:51 +08:00
|
|
|
; CHECK-LABEL: {{^}}groupstaticsize_test0:
|
AMDGPU: Write LDS objects out as global symbols in code generation
Summary:
The symbols use the processor-specific SHN_AMDGPU_LDS section index
introduced with a previous change. The linker is then expected to resolve
relocations, which are also emitted.
Initially disabled for HSA and PAL environments until they have caught up
in terms of linker and runtime loader.
Some notes:
- The llvm.amdgcn.groupstaticsize intrinsics can no longer be lowered
to a constant at compile times, which means some tests can no longer
be applied.
The current "solution" is a terrible hack, but the intrinsic isn't
used by Mesa, so we can keep it for now.
- We no longer know the full LDS size per kernel at compile time, which
means that we can no longer generate a relevant error message at
compile time. It would be possible to add a check for the size of
individual variables, but ultimately the linker will have to perform
the final check.
Change-Id: If66dbf33fccfbf3609aefefa2558ac0850d42275
Reviewers: arsenm, rampitec, t-tye, b-sumner, jsjodin
Subscribers: qcolombet, kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D61494
llvm-svn: 364297
2019-06-25 19:52:30 +08:00
|
|
|
; NOHSA: v_mov_b32_e32 v{{[0-9]+}}, llvm.amdgcn.groupstaticsize@abs32@lo
|
|
|
|
; HSA: v_mov_b32_e32 v{{[0-9]+}}, 0x800{{$}}
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @groupstaticsize_test0(float addrspace(1)* %out, i32 addrspace(1)* %lds_size) #0 {
|
2016-03-16 01:28:44 +08:00
|
|
|
%tid.x = tail call i32 @llvm.amdgcn.workitem.id.x() #1
|
|
|
|
%idx.0 = add nsw i32 %tid.x, 64
|
|
|
|
%static_lds_size = call i32 @llvm.amdgcn.groupstaticsize() #1
|
|
|
|
store i32 %static_lds_size, i32 addrspace(1)* %lds_size, align 4
|
|
|
|
%arrayidx0 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds0, i32 0, i32 %idx.0
|
|
|
|
%val0 = load float, float addrspace(3)* %arrayidx0, align 4
|
|
|
|
store float %val0, float addrspace(1)* %out, align 4
|
|
|
|
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-07-19 07:09:51 +08:00
|
|
|
; CHECK-LABEL: {{^}}groupstaticsize_test1:
|
AMDGPU: Write LDS objects out as global symbols in code generation
Summary:
The symbols use the processor-specific SHN_AMDGPU_LDS section index
introduced with a previous change. The linker is then expected to resolve
relocations, which are also emitted.
Initially disabled for HSA and PAL environments until they have caught up
in terms of linker and runtime loader.
Some notes:
- The llvm.amdgcn.groupstaticsize intrinsics can no longer be lowered
to a constant at compile times, which means some tests can no longer
be applied.
The current "solution" is a terrible hack, but the intrinsic isn't
used by Mesa, so we can keep it for now.
- We no longer know the full LDS size per kernel at compile time, which
means that we can no longer generate a relevant error message at
compile time. It would be possible to add a check for the size of
individual variables, but ultimately the linker will have to perform
the final check.
Change-Id: If66dbf33fccfbf3609aefefa2558ac0850d42275
Reviewers: arsenm, rampitec, t-tye, b-sumner, jsjodin
Subscribers: qcolombet, kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D61494
llvm-svn: 364297
2019-06-25 19:52:30 +08:00
|
|
|
; NOHSA: v_mov_b32_e32 v{{[0-9]+}}, llvm.amdgcn.groupstaticsize@abs32@lo
|
|
|
|
; HSA: v_mov_b32_e32 v{{[0-9]+}}, 0xc00{{$}}
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @groupstaticsize_test1(float addrspace(1)* %out, i32 %cond, i32 addrspace(1)* %lds_size) {
|
2016-03-16 01:28:44 +08:00
|
|
|
entry:
|
|
|
|
%static_lds_size = call i32 @llvm.amdgcn.groupstaticsize() #1
|
|
|
|
store i32 %static_lds_size, i32 addrspace(1)* %lds_size, align 4
|
|
|
|
%tid.x = tail call i32 @llvm.amdgcn.workitem.id.x() #1
|
|
|
|
%idx.0 = add nsw i32 %tid.x, 64
|
|
|
|
%tmp = icmp eq i32 %cond, 0
|
|
|
|
br i1 %tmp, label %if, label %else
|
|
|
|
|
|
|
|
if: ; preds = %entry
|
|
|
|
%arrayidx0 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds0, i32 0, i32 %idx.0
|
|
|
|
%val0 = load float, float addrspace(3)* %arrayidx0, align 4
|
|
|
|
store float %val0, float addrspace(1)* %out, align 4
|
|
|
|
br label %endif
|
|
|
|
|
|
|
|
else: ; preds = %entry
|
|
|
|
%arrayidx1 = getelementptr inbounds [256 x float], [256 x float] addrspace(3)* @lds1, i32 0, i32 %idx.0
|
|
|
|
%val1 = load float, float addrspace(3)* %arrayidx1, align 4
|
|
|
|
store float %val1, float addrspace(1)* %out, align 4
|
|
|
|
br label %endif
|
|
|
|
|
|
|
|
endif: ; preds = %else, %if
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-07-23 01:01:33 +08:00
|
|
|
; Exceeds 16-bit simm limit of s_movk_i32
|
|
|
|
; CHECK-LABEL: {{^}}large_groupstaticsize:
|
AMDGPU: Write LDS objects out as global symbols in code generation
Summary:
The symbols use the processor-specific SHN_AMDGPU_LDS section index
introduced with a previous change. The linker is then expected to resolve
relocations, which are also emitted.
Initially disabled for HSA and PAL environments until they have caught up
in terms of linker and runtime loader.
Some notes:
- The llvm.amdgcn.groupstaticsize intrinsics can no longer be lowered
to a constant at compile times, which means some tests can no longer
be applied.
The current "solution" is a terrible hack, but the intrinsic isn't
used by Mesa, so we can keep it for now.
- We no longer know the full LDS size per kernel at compile time, which
means that we can no longer generate a relevant error message at
compile time. It would be possible to add a check for the size of
individual variables, but ultimately the linker will have to perform
the final check.
Change-Id: If66dbf33fccfbf3609aefefa2558ac0850d42275
Reviewers: arsenm, rampitec, t-tye, b-sumner, jsjodin
Subscribers: qcolombet, kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D61494
llvm-svn: 364297
2019-06-25 19:52:30 +08:00
|
|
|
; NOHSA: v_mov_b32_e32 v{{[0-9]+}}, llvm.amdgcn.groupstaticsize@abs32@lo
|
|
|
|
; HSA: v_mov_b32_e32 [[REG:v[0-9]+]], 0x4000{{$}}
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @large_groupstaticsize(i32 addrspace(1)* %size, i32 %idx) #0 {
|
2016-07-23 01:01:33 +08:00
|
|
|
%gep = getelementptr inbounds [4096 x i32], [4096 x i32] addrspace(3)* @large, i32 0, i32 %idx
|
|
|
|
store volatile i32 0, i32 addrspace(3)* %gep
|
|
|
|
%static_lds_size = call i32 @llvm.amdgcn.groupstaticsize()
|
|
|
|
store i32 %static_lds_size, i32 addrspace(1)* %size
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-03-16 01:28:44 +08:00
|
|
|
declare i32 @llvm.amdgcn.groupstaticsize() #1
|
|
|
|
declare i32 @llvm.amdgcn.workitem.id.x() #1
|
|
|
|
|
|
|
|
attributes #0 = { nounwind }
|
|
|
|
attributes #1 = { nounwind readnone }
|