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

Add an unofficial 'isa' option to target different PTX ISAs. #4

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
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
14 changes: 13 additions & 1 deletion src/wrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ function kwargs_to_options(kwargs)
continue
end

# -isa is not supported and bypasses the official API
if k == :isa
for phase in ("opt", "llc")
# XXX: also lnk on libNVVM from CUDA 12.4
push!(options, "-X$phase", "-mattr=+ptx$(v.major)$(v.minor)")
end
continue
end

# support version numbers for specifying the compute architecture
if k == :arch && v isa VersionNumber
v = "compute_$(v.major)$(v.minor)"
Expand Down Expand Up @@ -143,14 +152,17 @@ end
Link and compile all NVVM IR modules added to the NVVM program `prog` to PTX code.
The target datalayout in the linked IR program is used to determine the address size.

The following compiler options are supported:
The following compiler options are supported by NVVM
- `debug` or `g`: whether to enable debug information
- `opt`: the optimization level to use
- `arch`: the compute architecture to target, e.g. `compute_75` or `v"7.5"`
- `ftz`: flush denormal values to zero
- `prec_sqrt`: whether to use use IEEE round-to-nearest sqrt, or an approximation
- `prec_div`: whether to use IEEE round-to-nearest division, or an approximation
- `fma`: enable FMA contraction

The following options are not officially supported by NVVM:
- `isa`: which PTX instruction set to use, e.g., `v"6.1"`
"""
function compile(prog::Program; kwargs...)
options = kwargs_to_options(kwargs)
Expand Down
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ end
compile(prog; opt=0)
compile(prog; ftz=false)
compile(prog; prec_sqrt=true)

# unofficial ones
@test contains(compile(prog; isa=v"6.0"), ".version 6.0")
@test contains(compile(prog; isa=v"6.1"), ".version 6.1")
end

end
Loading