Skip to content
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

Crash in LLVM #1971

Closed
maleadt opened this issue Jun 17, 2023 · 1 comment · Fixed by JuliaGPU/GPUCompiler.jl#474
Closed

Crash in LLVM #1971

maleadt opened this issue Jun 17, 2023 · 1 comment · Fixed by JuliaGPU/GPUCompiler.jl#474
Labels
bug Something isn't working cuda kernels Stuff about writing CUDA kernels.

Comments

@maleadt
Copy link
Member

maleadt commented Jun 17, 2023

using CUDA

A = CUDA.rand(4, 4, 3)
B = CUDA.rand(4, 4)
C = similar(A)

function kernel!(C, A, B)
	i = threadIdx().x

	if (i <= size(A, 3))
		@inbounds C[:, :, i] = A[:, :, i] * B
	end

	return nothing
end

@cuda threads = size(A, 3) kernel!(C, A, B)
[1202] signal (11.1): Segmentation fault
in expression starting at REPL[6]:1
_ZN4llvm27DeadArgumentEliminationPass27RemoveDeadStuffFromFunctionEPNS_8FunctionE.part.424 at /home/tim/Julia/depot/juliaup/julia-1.9.1+0.x64.linux.gnu/bin/../lib/julia/libLLVM-14jl.so (unknown line)
_ZN4llvm27DeadArgumentEliminationPass3runERNS_6ModuleERNS_15AnalysisManagerIS1_JEEE at /home/tim/Julia/depot/juliaup/julia-1.9.1+0.x64.linux.gnu/bin/../lib/julia/libLLVM-14jl.so (unknown line)
_ZN12_GLOBAL__N_13DAE11runOnModuleERN4llvm6ModuleE.part.425 at /home/tim/Julia/depot/juliaup/julia-1.9.1+0.x64.linux.gnu/bin/../lib/julia/libLLVM-14jl.so (unknown line)
_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE at /home/tim/Julia/depot/juliaup/julia-1.9.1+0.x64.linux.gnu/bin/../lib/julia/libLLVM-14jl.so (unknown line)
LLVMRunPassManager at /home/tim/Julia/depot/juliaup/julia-1.9.1+0.x64.linux.gnu/bin/../lib/julia/libLLVM-14jl.so (unknown line)
LLVMRunPassManager at /home/tim/Julia/depot/packages/LLVM/bsdku/lib/13/libLLVM_h.jl:4898 [inlined]
run! at /home/tim/Julia/depot/packages/LLVM/bsdku/src/passmanager.jl:39 [inlined]
macro expansion at /home/tim/Julia/pkg/GPUCompiler/src/optim.jl:292 [inlined]
macro expansion at /home/tim/Julia/depot/packages/LLVM/bsdku/src/base.jl:98 [inlined]
optimize! at /home/tim/Julia/pkg/GPUCompiler/src/optim.jl:286

Should check with an assertions build, the CPU code here probably triggers something.

@maleadt maleadt added bug Something isn't working cuda kernels Stuff about writing CUDA kernels. labels Jun 17, 2023
@maleadt
Copy link
Member Author

maleadt commented Jun 19, 2023

Reduced to:

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-v32:32:32-v64:64:64-v128:128:128-n16:32:64-ni:10:11:12:13"
target triple = "nvptx64-nvidia-cuda"

define internal fastcc void @outer() {
top:
  call void (void ({} *, {} **, i32)*) null(void ({} *, {} **, i32)* @inner)
  ret void
}

define internal void @inner({} *, {} **, i32) {
fail7:
  %state = call [1 x i64] @julia.gpu.state_getter()
  ret void
}

declare [1 x i64] @julia.gpu.state_getter()
LLVM error: Call parameter type does not match function signature!
void ([1 x i64], {}*, {}**, i32)* @inner
 void ({}*, {}**, i32)*  call void null(void ([1 x i64], {}*, {}**, i32)* @inner)

IR corruption due to kernel rewrite pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cuda kernels Stuff about writing CUDA kernels.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant