Skip to content

Allow disabling the linking of libdevice in CUDACompilerParams #2611

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion src/compiler/compilation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
Base.@kwdef struct CUDACompilerParams <: AbstractCompilerParams
cap::VersionNumber
ptx::VersionNumber
link_libdevice::Bool # Used by Reactant.jl
end

CUDACompilerParams(;cap::VersionNumber, ptx::VersionNumber) = CUDACompilerParams(cap=cap, ptx=ptx, link_libdevice=true)
function Base.hash(params::CUDACompilerParams, h::UInt)
h = hash(params.cap, h)
h = hash(params.ptx, h)

h = hash(params.link_libdevice, h)
return h
end

Expand All @@ -27,6 +29,9 @@ GPUCompiler.isintrinsic(@nospecialize(job::CUDACompilerJob), fn::String) =
# link libdevice
function GPUCompiler.link_libraries!(@nospecialize(job::CUDACompilerJob), mod::LLVM.Module,
undefined_fns::Vector{String})
if !job.config.params.link_libdevice
return # Don't link libdevice, used by Reactant.jl to raise NVVM intrinsics into MLIR
end
# only link if there's undefined __nv_ functions
if !any(fn->startswith(fn, "__nv_"), undefined_fns)
return
Expand Down
Loading