Skip to content
This repository was archived by the owner on May 27, 2021. It is now read-only.

Commit a5eebb4

Browse files
authored
Merge pull request #529 from JuliaGPU/tb/kwdef
Use kwdef for CompilerJob.
2 parents bb0923e + 5852e40 commit a5eebb4

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

src/compiler/common.jl

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
# common functionality
22

3-
struct CompilerJob
3+
Base.@kwdef struct CompilerJob
44
# core invocation
55
f::Base.Callable
66
tt::DataType
77
cap::VersionNumber
88
kernel::Bool
99

1010
# optional properties
11-
minthreads::Union{Nothing,CuDim}
12-
maxthreads::Union{Nothing,CuDim}
13-
blocks_per_sm::Union{Nothing,Integer}
14-
maxregs::Union{Nothing,Integer}
15-
name::Union{Nothing,String}
16-
17-
CompilerJob(f, tt, cap, kernel; name=nothing,
18-
minthreads=nothing, maxthreads=nothing,
19-
blocks_per_sm=nothing, maxregs=nothing) =
20-
new(f, tt, cap, kernel, minthreads, maxthreads, blocks_per_sm, maxregs, name)
11+
minthreads::Union{Nothing,CuDim} = nothing
12+
maxthreads::Union{Nothing,CuDim} = nothing
13+
blocks_per_sm::Union{Nothing,Integer} = nothing
14+
maxregs::Union{Nothing,Integer} = nothing
15+
name::Union{Nothing,String} = nothing
2116
end
2217

18+
CompilerJob(f, tt, cap, kernel; kwargs...) =
19+
CompilerJob(f=f, tt=tt, cap=cap, kernel=kernel; kwargs...)
20+
2321
# global job reference
2422
# FIXME: thread through `job` everywhere (deadlocks the Julia compiler when doing so with
2523
# the LLVM passes in CUDAnative)

src/compiler/driver.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# compiler driver and main interface
22

3+
# NOTE: the keyword arguments to compile/codegen control those aspects of compilation that
4+
# might have to be changed (e.g. set libraries=false when recursing, or set
5+
# strip=true for reflection). What remains defines the compilation job itself,
6+
# and those values are contained in the CompilerJob struct.
7+
38
# (::CompilerJob)
49
const compile_hook = Ref{Union{Nothing,Function}}(nothing)
510

@@ -17,12 +22,12 @@ The following keyword arguments are supported:
1722
- `libraries`: link the CUDAnative runtime and `libdevice` libraries (if required)
1823
- `dynamic_parallelism`: resolve dynamic parallelism (if required)
1924
- `optimize`: optimize the code (default: true)
20-
- `strip`: strip non-functional metadata and debug information (default: false)
25+
- `strip`: strip non-functional metadata and debug information (default: false)
2126
- `strict`: perform code validation either as early or as late as possible
2227
2328
Other keyword arguments can be found in the documentation of [`cufunction`](@ref).
2429
"""
25-
compile(target::Symbol, cap::VersionNumber, @nospecialize(f::Core.Function),
30+
compile(target::Symbol, cap::VersionNumber, @nospecialize(f::Base.Callable),
2631
@nospecialize(tt), kernel::Bool=true; libraries::Bool=true,
2732
dynamic_parallelism::Bool=true, optimize::Bool=true,
2833
strip::Bool=false, strict::Bool=true, kwargs...) =
@@ -51,7 +56,7 @@ end
5156

5257
function codegen(target::Symbol, job::CompilerJob;
5358
libraries::Bool=true, dynamic_parallelism::Bool=true, optimize::Bool=true,
54-
strip::Bool=false,strict::Bool=true)
59+
strip::Bool=false, strict::Bool=true)
5560
## Julia IR
5661

5762
@timeit_debug to "validation" check_method(job)

0 commit comments

Comments
 (0)