Skip to content

Override optimization parameters in cuda to avoid passes which break …#2939

Draft
wsmoses wants to merge 2 commits into
mainfrom
curaise
Draft

Override optimization parameters in cuda to avoid passes which break …#2939
wsmoses wants to merge 2 commits into
mainfrom
curaise

Conversation

@wsmoses

@wsmoses wsmoses commented Jun 3, 2026

Copy link
Copy Markdown
Member

…raising

companion to JuliaGPU/GPUCompiler.jl#823

cc @gbaraldi @vchuravy @giordano @maleadt

since GPUCompiler defines several APIs, like optimization_options, on the job itself -- downstream compilers that use the PTX codegen cannot modify these methods without type piracy on all targets, or vendoring the entire api.

Adding a type parameter to PTXCompilerTarget enables this to work without piracy or vendoring large parts of the codebase

Comment thread ext/ReactantCUDAExt.jl
Comment on lines +1609 to +1612
const ReactantCUDACompilerConfig = CompilerConfig{ReactantPTXCompilerTarget{ReactantPTXBackend}, CUDACompilerParams}
const ReactantCUDACompilerJob = CompilerJob{ReactantPTXCompilerTarget{ReactantPTXBackend},CUDACompilerParams}

GPUCompiler.optimization_options(job::ReactantCUDACompilerJob) = (; instcombine=!job.config.target.raising, ptxfastmath=!job.config.target.raising)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
const ReactantCUDACompilerConfig = CompilerConfig{ReactantPTXCompilerTarget{ReactantPTXBackend}, CUDACompilerParams}
const ReactantCUDACompilerJob = CompilerJob{ReactantPTXCompilerTarget{ReactantPTXBackend},CUDACompilerParams}
GPUCompiler.optimization_options(job::ReactantCUDACompilerJob) = (; instcombine=!job.config.target.raising, ptxfastmath=!job.config.target.raising)
const ReactantCUDACompilerConfig = CompilerConfig{
ReactantPTXCompilerTarget{ReactantPTXBackend},CUDACompilerParams
}
const ReactantCUDACompilerJob = CompilerJob{
ReactantPTXCompilerTarget{ReactantPTXBackend},CUDACompilerParams
}
function GPUCompiler.optimization_options(job::ReactantCUDACompilerJob)
return (;
instcombine=!job.config.target.raising, ptxfastmath=!job.config.target.raising
)
end

Comment thread ext/ReactantCUDAExt.jl
debuginfo = false
config = GPUCompiler.CompilerConfig(
GPUCompiler.PTXCompilerTarget(; cap=llvm_cap, ptx=llvm_ptx, debuginfo),
ReactantPTXCompilerTarget{ReactantPTXBackend}(; cap=llvm_cap, ptx=llvm_ptx, debuginfo, backendinfo=ReactantPTXBackend(raising())),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
ReactantPTXCompilerTarget{ReactantPTXBackend}(; cap=llvm_cap, ptx=llvm_ptx, debuginfo, backendinfo=ReactantPTXBackend(raising())),
ReactantPTXCompilerTarget{ReactantPTXBackend}(;
cap=llvm_cap,
ptx=llvm_ptx,
debuginfo,
backendinfo=ReactantPTXBackend(raising()),
),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant