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

Allow disabling the linking of libdevice in CUDACompilerParams #2611

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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
Copy link
Member

Choose a reason for hiding this comment

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

We're using @kwdef

Suggested change
link_libdevice::Bool # Used by Reactant.jl
# for Reactant.jl, which raises NVVM intrinsics to MLIR
link_libdevice::Bool = true

end

CUDACompilerParams(;cap::VersionNumber, ptx::VersionNumber) = CUDACompilerParams(cap=cap, ptx=ptx, link_libdevice=true)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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
Comment on lines +32 to +34
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if !job.config.params.link_libdevice
return # Don't link libdevice, used by Reactant.jl to raise NVVM intrinsics into MLIR
end
job.config.params.link_libdevice || return

# only link if there's undefined __nv_ functions
if !any(fn->startswith(fn, "__nv_"), undefined_fns)
return
Expand Down
Loading