Skip to content

Commit fa2704f

Browse files
authored
Merge pull request #206 from JuliaGPU/tb/hash
Hash structures by fields.
2 parents 20ed769 + 6ed5929 commit fa2704f

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

Diff for: src/interface.jl

+17
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ struct FunctionSpec{F,TT}
6767
world_age::UInt
6868
end
6969

70+
71+
function Base.hash(spec::FunctionSpec, h::UInt)
72+
h = hash(spec.f, h)
73+
h = hash(spec.tt, h)
74+
h = hash(spec.kernel, h)
75+
h = hash(spec.name, h)
76+
h = hash(spec.world_age, h)
77+
h
78+
end
79+
7080
# put the function and argument types in typevars
7181
# so that we can access it from generated functions
7282
# XXX: the default value of 0xffffffffffffffff is a hack, because we don't properly perform
@@ -121,6 +131,13 @@ function Base.show(io::IO, @nospecialize(job::CompilerJob{T})) where {T}
121131
print(io, "CompilerJob of ", job.source, " for ", T)
122132
end
123133

134+
function Base.hash(job::CompilerJob, h::UInt)
135+
h = hash(job.target, h)
136+
h = hash(job.source, h)
137+
h = hash(job.params, h)
138+
h
139+
end
140+
124141

125142
## interfaces and fallback definitions
126143

Diff for: src/ptx.jl

+16
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@ Base.@kwdef struct PTXCompilerTarget <: AbstractCompilerTarget
2323
maxregs::Union{Nothing,Int} = nothing
2424
end
2525

26+
function Base.hash(target::PTXCompilerTarget, h::UInt)
27+
h = hash(target.cap, h)
28+
h = hash(target.ptx, h)
29+
30+
h = hash(target.debuginfo, h)
31+
h = hash(target.unreachable, h)
32+
h = hash(target.exitable, h)
33+
34+
h = hash(target.minthreads, h)
35+
h = hash(target.maxthreads, h)
36+
h = hash(target.blocks_per_sm, h)
37+
h = hash(target.maxregs, h)
38+
39+
h
40+
end
41+
2642
source_code(target::PTXCompilerTarget) = "ptx"
2743

2844
llvm_triple(target::PTXCompilerTarget) = Int===Int64 ? "nvptx64-nvidia-cuda" : "nvptx-nvidia-cuda"

0 commit comments

Comments
 (0)