Skip to content

Commit 438bd84

Browse files
github-actions[bot]CompatHelper Juliagiordano
authored
CompatHelper: bump compat for GPUCompiler to 0.23-0.26 (#43)
* CompatHelper: bump compat for GPUCompiler to 0.23-0.26 * Require Julia v1.9 * Remove code no longer relevant in Julia v1.9 --------- Co-authored-by: CompatHelper Julia <compathelper_noreply@julialang.org> Co-authored-by: Mosè Giordano <mose@gnu.org>
1 parent 3611346 commit 438bd84

File tree

6 files changed

+33
-75
lines changed

6 files changed

+33
-75
lines changed

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "IPUToolkit"
22
uuid = "92e0b95a-4011-435a-96f4-10064551ddbe"
33
authors = ["Emily Dietrich <jakibaki@live.com>", "Luk Burchard <luk.burchard@gmail.com>", "Mosè Giordano <mose@gnu.org>"]
4-
version = "1.5.0"
4+
version = "1.6.0"
55

66
[deps]
77
Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31"
@@ -20,7 +20,7 @@ libcxxwrap_julia_jll = "3eaa8342-bff7-56a5-9981-c04077f7cee7"
2020
[compat]
2121
Clang = "0.14, 0.17.4"
2222
CxxWrap = "0.14"
23-
GPUCompiler = "0.21.4"
23+
GPUCompiler = "0.23, 0.24, 0.25, 0.26"
2424
JSON = "0.21.4"
2525
LLVM = "6"
2626
LinearAlgebra = "1"
@@ -29,5 +29,5 @@ ProgressMeter = "1.7"
2929
Scratch = "1.1"
3030
TOML = "1"
3131
UUIDs = "1"
32-
julia = "1.6"
32+
julia = "1.9"
3333
libcxxwrap_julia_jll = "0.11"

src/compiler/compiler.jl

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,7 @@ macro device_override(ex)
3636
ex = eval(ex)
3737
error()
3838
end
39-
code = quote
40-
$GPUCompiler.@override($method_table, $ex)
41-
end
42-
if isdefined(Base.Experimental, Symbol("@overlay"))
43-
return esc(code)
44-
else
45-
push!(overrides, code)
46-
return
47-
end
39+
return esc(:( Base.Experimental.@overlay($method_table, $ex) ))
4840
end
4941

5042
macro device_function(ex)

src/compiler/runtime.jl

Lines changed: 18 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -156,58 +156,32 @@ end
156156
@print_and_throw "asin(x) not defined for |x| > 1, x = " x
157157

158158
# range.jl
159-
@static if VERSION >= v"1.7-"
160-
@eval begin
161-
@device_override function Base.StepRangeLen{T,R,S,L}(ref::R, step::S, len::Integer,
162-
offset::Integer=1) where {T,R,S,L}
163-
if T <: Integer && !isinteger(ref + step)
164-
@print_and_throw("StepRangeLen{<:Integer} cannot have non-integer step")
165-
end
166-
len = convert(L, len)
167-
len >= zero(len) || @print_and_throw("StepRangeLen length cannot be negative")
168-
offset = convert(L, offset)
169-
L1 = oneunit(typeof(len))
170-
L1 <= offset <= max(L1, len) || @print_and_throw("StepRangeLen: offset must be in [1,...]")
171-
$(
172-
Expr(:new, :(StepRangeLen{T,R,S,L}), :ref, :step, :len, :offset)
173-
)
174-
end
175-
end
176-
else
177-
@device_override function Base.StepRangeLen{T,R,S}(ref::R, step::S, len::Integer,
178-
offset::Integer=1) where {T,R,S}
159+
@eval begin
160+
@device_override function Base.StepRangeLen{T,R,S,L}(ref::R, step::S, len::Integer,
161+
offset::Integer=1) where {T,R,S,L}
179162
if T <: Integer && !isinteger(ref + step)
180163
@print_and_throw("StepRangeLen{<:Integer} cannot have non-integer step")
181164
end
182-
len >= 0 || @print_and_throw("StepRangeLen length cannot be negative")
183-
1 <= offset <= max(1,len) || @print_and_throw("StepRangeLen: offset must be in [1,...]")
184-
new(ref, step, len, offset)
165+
len = convert(L, len)
166+
len >= zero(len) || @print_and_throw("StepRangeLen length cannot be negative")
167+
offset = convert(L, offset)
168+
L1 = oneunit(typeof(len))
169+
L1 <= offset <= max(L1, len) || @print_and_throw("StepRangeLen: offset must be in [1,...]")
170+
$(
171+
Expr(:new, :(StepRangeLen{T,R,S,L}), :ref, :step, :len, :offset)
172+
)
185173
end
186174
end
187175

188176
# LinearAlgebra
189-
@static if VERSION >= v"1.8-"
190-
@device_override function Base.setindex!(D::LinearAlgebra.Diagonal, v, i::Int, j::Int)
191-
@boundscheck checkbounds(D, i, j)
192-
if i == j
193-
@inbounds D.diag[i] = v
194-
elseif !iszero(v)
195-
@print_and_throw("cannot set off-diagonal entry to a nonzero value")
196-
end
197-
return v
177+
@device_override function Base.setindex!(D::LinearAlgebra.Diagonal, v, i::Int, j::Int)
178+
@boundscheck checkbounds(D, i, j)
179+
if i == j
180+
@inbounds D.diag[i] = v
181+
elseif !iszero(v)
182+
@print_and_throw("cannot set off-diagonal entry to a nonzero value")
198183
end
199-
end
200-
201-
# fastmath.jl
202-
@static if VERSION <= v"1.7-"
203-
## prevent fallbacks to libm
204-
for f in (:acosh, :asinh, :atanh, :cbrt, :cosh, :exp2, :expm1, :log1p, :sinh, :tanh)
205-
f_fast = Base.FastMath.fast_op[f]
206-
@eval begin
207-
@device_override Base.FastMath.$f_fast(x::Float32) = $f(x)
208-
@device_override Base.FastMath.$f_fast(x::Float64) = $f(x)
209-
end
210-
end
184+
return v
211185
end
212186

213187
end # module IPURuntime

src/compiler/vertices.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ end
7171
# In Julia v1.9 the default algorithm for sorting arrays requires a scratch area, but we
7272
# can't use it on an IPU because it'd need to allocate an extra array, so let's default to
7373
# the simple fully in-place `QuickSort`.
74-
if VERSION v"1.9.0-"
75-
Base.Sort.defalg(::VertexVector) = QuickSort
76-
end
74+
Base.Sort.defalg(::VertexVector) = QuickSort
7775

7876
# Simple methods, don't access the elements
7977
Base.show(io::IO, x::VertexVector) = Base.show_default(io, x)

test/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
88
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
99

1010
[compat]
11-
Enzyme = "0.11"
11+
Enzyme = "0.11, 0.12"
1212
StaticArrays = "1"

test/compiler.jl

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const check_bounds = Base.JLOptions().check_bounds == 1
55

66
using Test
77
using IPUToolkit.IPUCompiler
8-
using GPUCompiler: KernelError
8+
using GPUCompiler: GPUCompiler
99
using IPUToolkit.Poplar
1010
if Poplar.SDK_VERSION v"2.2.0" || !check_bounds
1111
using Enzyme
@@ -58,8 +58,9 @@ function test_compiler_program(device)
5858
end
5959

6060
# Test some invalid kernels
61-
@test_throws KernelError @codelet graph f_access_out_scalar(x::VertexScalar{Float32, Out}) = @ipushow x[]
62-
@test_throws KernelError @codelet graph f_set_in_scalar(x::VertexScalar{Float32, In}) = x[] = 3.14f0
61+
invalid_error = pkgversion(GPUCompiler) <= v"0.23" ? GPUCompiler.KernelError : GPUCompiler.InvalidIRError
62+
@test_throws invalid_error @codelet graph f_access_out_scalar(x::VertexScalar{Float32, Out}) = @ipushow x[]
63+
@test_throws invalid_error @codelet graph f_set_in_scalar(x::VertexScalar{Float32, In}) = x[] = 3.14f0
6364

6465
# This function would contain a reference to a literal pointer, likely an
6566
# invalid memory address on the IPU.
@@ -76,10 +77,7 @@ function test_compiler_program(device)
7677

7778
add_vertex(graph, prog, TimesTwo, inconst, outvec1)
7879
add_vertex(graph, prog, Sort, outvec1, outvec2)
79-
if VERSION v"1.7"
80-
# The `@device_override` business works well only on Julia v1.7+
81-
add_vertex(graph, prog, Sin, outvec2, outvec3)
82-
end
80+
add_vertex(graph, prog, Sin, outvec2, outvec3)
8381
add_vertex(graph, prog, Print, 3.14f0)
8482
# Pass as codelet a function with more than one method
8583
@test_throws ArgumentError add_vertex(graph, prog, +, outvec3)
@@ -92,10 +90,8 @@ function test_compiler_program(device)
9290
Poplar.GraphCreateHostRead(graph, "timestwo-read", outvec1)
9391
output_sort = similar(input)
9492
Poplar.GraphCreateHostRead(graph, "sort-read", outvec2)
95-
if VERSION v"1.7"
96-
output_sin = similar(input)
97-
Poplar.GraphCreateHostRead(graph, "sin-read", outvec3)
98-
end
93+
output_sin = similar(input)
94+
Poplar.GraphCreateHostRead(graph, "sin-read", outvec3)
9995

10096
flags = @cxxtest Poplar.OptionFlags()
10197
Poplar.OptionFlagsSet(flags, "debug.instrument", "true")
@@ -128,10 +124,8 @@ function test_compiler_program(device)
128124
@test output_timestwo == 2 .* input
129125
Poplar.EngineReadTensor(engine, "sort-read", output_sort)
130126
@test output_sort == sort(output_timestwo)
131-
if VERSION v"1.7"
132-
Poplar.EngineReadTensor(engine, "sin-read", output_sin)
133-
@test output_sin == sin.(output_sort)
134-
end
127+
Poplar.EngineReadTensor(engine, "sin-read", output_sin)
128+
@test output_sin == sin.(output_sort)
135129

136130
Poplar.detach_devices()
137131
end

0 commit comments

Comments
 (0)