Skip to content

Commit d7358ce

Browse files
authored
Add 1.11 support (#635)
1 parent 451ca7d commit d7358ce

File tree

11 files changed

+85
-37
lines changed

11 files changed

+85
-37
lines changed

.buildkite/pipeline.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,47 @@ steps:
4242
JULIA_AMDGPU_HIP_MUST_LOAD: "1"
4343
JULIA_AMDGPU_DISABLE_ARTIFACTS: "1"
4444

45+
- label: "Julia 1.11 typed pointers"
46+
plugins:
47+
- JuliaCI/julia#v1:
48+
version: "1.11"
49+
- JuliaCI/julia-test#v1:
50+
- JuliaCI/julia-coverage#v1:
51+
codecov: true
52+
agents:
53+
queue: "juliagpu"
54+
rocm: "*"
55+
rocmgpu: "*"
56+
if: build.message !~ /\[skip tests\]/
57+
command: "julia --project -e 'using Pkg; Pkg.update()'"
58+
timeout_in_minutes: 180
59+
env:
60+
JULIA_NUM_THREADS: 4
61+
JULIA_AMDGPU_CORE_MUST_LOAD: "1"
62+
JULIA_AMDGPU_HIP_MUST_LOAD: "1"
63+
JULIA_AMDGPU_DISABLE_ARTIFACTS: "1"
64+
65+
- label: "Julia 1.11 opaque pointers"
66+
plugins:
67+
- JuliaCI/julia#v1:
68+
version: "1.11"
69+
- JuliaCI/julia-test#v1:
70+
- JuliaCI/julia-coverage#v1:
71+
codecov: true
72+
agents:
73+
queue: "juliagpu"
74+
rocm: "*"
75+
rocmgpu: "*"
76+
if: build.message !~ /\[skip tests\]/
77+
command: "julia --project -e 'using Pkg; Pkg.update()'"
78+
timeout_in_minutes: 180
79+
env:
80+
JULIA_LLVM_ARGS: "-opaque-pointers"
81+
JULIA_NUM_THREADS: 4
82+
JULIA_AMDGPU_CORE_MUST_LOAD: "1"
83+
JULIA_AMDGPU_HIP_MUST_LOAD: "1"
84+
JULIA_AMDGPU_DISABLE_ARTIFACTS: "1"
85+
4586
- label: "GPU-less environment"
4687
plugins:
4788
- JuliaCI/julia#v1:

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88

99
docs/build
1010
docs/Manifest.toml
11-
Manifest.toml
11+
Manifest*.toml
1212
LocalPreferences.toml

src/AMDGPU.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ import .Runtime: Mem, ROCDim, ROCDim3
7474

7575
include("memory.jl")
7676

77-
const ci_cache = GPUCompiler.CodeCache()
7877
Base.Experimental.@MethodTable(method_table)
7978

8079
# Device sources must load _before_ the compiler infrastructure,

src/compiler/codegen.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ end
2323

2424
GPUCompiler.runtime_module(@nospecialize(::HIPCompilerJob)) = AMDGPU
2525

26-
GPUCompiler.ci_cache(@nospecialize(::HIPCompilerJob)) = AMDGPU.ci_cache
27-
2826
GPUCompiler.method_table(@nospecialize(::HIPCompilerJob)) = AMDGPU.method_table
2927

3028
GPUCompiler.kernel_state_type(@nospecialize(::HIPCompilerJob)) = AMDGPU.KernelState

src/compiler/zeroinit_lds.jl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ function zeroinit_lds!(mod::LLVM.Module, entry::LLVM.Function)
2222
to_init = []
2323
for gbl in LLVM.globals(mod)
2424
if startswith(LLVM.name(gbl), "__zeroinit")
25-
as = LLVM.addrspace(value_type(gbl))
25+
vt = value_type(gbl)
26+
as = LLVM.addrspace(vt)
2627
if as == AMDGPU.Device.AS.Local
27-
push!(to_init, gbl)
28+
sz = llvmsize(global_value_type(gbl))
29+
push!(to_init, (gbl, sz))
2830
end
2931
end
3032
end
@@ -37,13 +39,10 @@ function zeroinit_lds!(mod::LLVM.Module, entry::LLVM.Function)
3739
position!(builder, instruction)
3840

3941
# Use memset to clear all values to 0.
40-
for gbl in to_init
41-
sz = llvmsize(eltype(value_type(gbl)))
42+
for (gbl, sz) in to_init
4243
sz == 0 && continue
43-
4444
LLVM.memset!(builder, gbl,
45-
ConstantInt(UInt8(0)), ConstantInt(sz),
46-
LLVM.alignment(gbl))
45+
ConstantInt(UInt8(0)), ConstantInt(sz), LLVM.alignment(gbl))
4746
end
4847

4948
# Synchronize the workgroup to prevent races.

src/device/gcn/assertion.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ macro rocassert(ex, msgs...)
2929
msg = :(Main.Base.string($(Expr(:quote,msg))))
3030
end
3131

32-
return :($(esc(ex)) ? $(nothing)
33-
: rocassert_fail($(Val(Symbol(msg))),
34-
$(Val(__source__.file)),
35-
$(Val(__source__.line))))
32+
return :($(esc(ex)) ? $(nothing) :
33+
rocassert_fail(
34+
$(Val(Symbol(msg))),
35+
$(Val(__source__.file)),
36+
$(Val(__source__.line))))
3637
end
3738

3839
assert_counter = 0

src/device/gcn/math.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ for jltype in (Float64, Float32, Float16)
2222
type_suffix = fntypes[jltype]
2323

2424
for (mod, intrinsic) in DEFINED_UNARY_INTRNISICS
25-
# sin(Float16) is broken, we override it manually at the very bottom.
25+
# sin(::Float16) is broken, we override it manually at the very bottom.
2626
jltype == Float16 && intrinsic == :sin && continue
27+
# log(::Float16) is broken, we override it manually at the very bottom.
28+
# https://github.com/ROCm/llvm-project/blob/592734c97a3ddcb7ca4009ac94550595a52450ce/amd/device-libs/ocml/src/logH.cl#L15
29+
jltype == Float16 && intrinsic == :log && continue
2730

2831
fname = "extern __ocml_$(intrinsic)_$(type_suffix)"
2932
if isnothing(mod)
@@ -132,4 +135,5 @@ end
132135
end
133136

134137
# sin(Float16) is broken, so cast to Float32, see #177.
135-
@device_override Base.sin(x::Float16) = sin(Float32(x))
138+
@device_override Base.sin(x::Float16) = Float16(sin(Float32(x)))
139+
@device_override Base.log(x::Float16) = Float16(log(Float32(x)))

src/device/gcn/memory_static.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@
4242
entry = BasicBlock(llvm_f, "entry")
4343
position!(builder, entry)
4444

45-
ptr_with_as = gep!(builder, gv_typ, gv,
46-
[ConstantInt(0), ConstantInt(0)])
45+
ptr_with_as = gep!(builder, gv_typ, gv, [ConstantInt(0), ConstantInt(0)])
4746
ptr = bitcast!(builder, ptr_with_as, T_ptr_i8)
4847
ret!(builder, ptr)
4948
end

src/device/random.jl

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,18 @@ struct Philox2x32{R} <: RandomNumbers.AbstractRNG{UInt64}
6363
@inline function Philox2x32{R}() where R
6464
rng = new{R}()
6565
if rng.key == 0
66-
# initialize the key. this happens when first accessing the (0-initialized)
67-
# shared memory key from each block. if we ever want to make the device seed
68-
# controlable from the host, this would be the place to read a global seed.
69-
#
70-
# note however that it is undefined how shared memory persists across e.g.
71-
# launches, so we may not be able to rely on the zero initalization then.
72-
rng.key = Random.make_seed()
66+
# initialize the key. this happens when first accessing
67+
# the (0-initialized) shared memory key from each block.
68+
@static if VERSION >= v"1.11-"
69+
Random.seed!(rng, nothing)
70+
else
71+
rng.key = Random.make_seed()
72+
end
7373
end
7474
return rng
7575
end
7676
end
7777

78-
if VERSION >= v"1.11-"
79-
# `Random.seed!(::AbstractRNG)` now passes a `nothing` seed value
80-
Random.seed!(rng::Philox2x32, seed::Nothing) =
81-
Random.seed!(rng, Base.unsafe_trunc(UInt32, readcyclecounter()))
82-
else
83-
# ... where it used to call `Random_make_seed()`
84-
@device_override Random.make_seed() = Base.unsafe_trunc(UInt32, readcyclecounter())
85-
end
86-
8778
# default to 7 rounds; enough to pass SmallCrush
8879
@inline Philox2x32() = Philox2x32{7}()
8980

@@ -135,6 +126,7 @@ function Random.seed!(rng::Philox2x32, seed::Integer, counter::Integer=0)
135126
rng.ctr1 = counter
136127
return
137128
end
129+
138130
# seeding the implicit default RNG
139131
if VERSION >= v"1.11-"
140132
@device_override Random.seed!(seed) =
@@ -144,6 +136,15 @@ else
144136
Random.seed!(Random.default_rng(), seed)
145137
end
146138

139+
if VERSION >= v"1.11-"
140+
# `Random.seed!(::AbstractRNG)` now passes a `nothing` seed value
141+
Random.seed!(rng::Philox2x32, seed::Nothing) =
142+
Random.seed!(rng, Base.unsafe_trunc(UInt32, readcyclecounter()))
143+
else
144+
# ... where it used to call `Random_make_seed()`
145+
@device_override Random.make_seed() = Base.unsafe_trunc(UInt32, readcyclecounter())
146+
end
147+
147148
"""
148149
Random.rand(rng::Philox2x32, UInt32)
149150

src/discovery/discovery.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ function __init__()
142142
else
143143
# Detect HIP version, which will influence what device libraries to use.
144144
hip_version = Base.thisminor(_hip_runtime_version())
145-
hip_version > v"5.4" ? true : use_artifacts()
145+
# Check if opaque pointers are enabled and turn off artifacts.
146+
llvm_args = get(ENV, "JULIA_LLVM_ARGS", "")
147+
enabled_opaque_pointers = occursin("-opaque-pointers", llvm_args)
148+
(hip_version > v"5.4" && !enabled_opaque_pointers) ? true : use_artifacts()
146149
end
147150
# If ROCm 5.5+ - use artifact device libraries.
148151
global libdevice_libs = get_device_libs(from_artifact; rocm_path)

src/kernels/indexing.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Base.to_index(::ROCArray, I::AbstractArray{Bool}) = findall(I)
22

3-
# TODO Julia 1.11 specifics
3+
if VERSION >= v"1.11.0-DEV.1157"
4+
Base.to_indices(x::ROCArray, I::Tuple{AbstractArray{Bool}}) =
5+
(Base.to_index(x, I[1]),)
6+
end
47

58
function Base.findall(bools::AnyROCArray{Bool})
69
I = keytype(bools)

0 commit comments

Comments
 (0)