Skip to content

Commit 6d2eb7e

Browse files
committed
attempt to fix oneAPI test precompilation hang with Julia v1.10 by disabling package images
1 parent 61aa11d commit 6d2eb7e

4 files changed

Lines changed: 53 additions & 29 deletions

File tree

.buildkite/pipeline.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,13 @@ steps:
8888
- JuliaCI/julia#v1:
8989
version: "1.10"
9090
command: |
91-
julia -e 'using Pkg
91+
julia -e --pkgimages=no 'using Pkg
9292
93-
println("--- :julia: Instantiating environment")
94-
Pkg.add("oneAPI")
95-
Pkg.develop(path=".")
96-
97-
println("+++ :julia: Running tests")
98-
Pkg.test("AcceleratedKernels", test_args=["--oneAPI"])'
93+
println("--- :julia: Instantiating environment")
94+
Pkg.add("oneAPI")
95+
Pkg.develop(path=".")
96+
println("+++ :julia: Running tests")
97+
Pkg.test("AcceleratedKernels", test_args=["--oneAPI"])'
9998
agents:
10099
queue: "juliagpu"
101100
intel: "*"

src/rand/rand.jl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
const ALLOWED_RAND_SCALARS = Union{
2+
UInt8, UInt16, UInt32, UInt64,
3+
Int8, Int16, Int32, Int64,
4+
Float16, Float32, Float64,
5+
Bool
6+
}
7+
18
abstract type CounterRNGAlgorithm end
29

310

@@ -92,7 +99,8 @@ include("randn.jl")
9299
Fill `v` in-place with pseudo-random values using a counter-based RNG stream. For `v[i]`, the
93100
counter is `rng.offset + UInt64(i - 1)` in linear indexing order.
94101
95-
After filling `v`, `rng.offset` advances by `length(v)`.
102+
After filling `v`, `rng.offset` advances by `length(v)`. It can be called without `rng`, in which
103+
case the default `CounterRNG` is used.
96104
97105
Supported scalar element types are:
98106
- `UInt8`, `UInt16`, `UInt32`, `UInt64`
@@ -155,9 +163,13 @@ end
155163
backend::Backend,
156164
::Type{T},
157165
dims::Integer...;
166+
167+
# CPU settings
158168
max_tasks::Int=Threads.nthreads(),
159169
min_elems::Int=1,
160170
prefer_threads::Bool=true,
171+
172+
# GPU settings
161173
block_size::Int=256,
162174
) where T
163175
@@ -178,7 +190,8 @@ function rand(
178190
# GPU settings
179191
block_size::Int=256,
180192
) where T
181-
return _allocate_and_fill(
193+
@argcheck T <: ALLOWED_RAND_SCALARS "Unsupported eltype $T. Supported: $(ALLOWED_RAND_SCALARS)"
194+
return _allocate_and_fill_rand(
182195
rand!, rng, backend, T, dims...;
183196
max_tasks, min_elems, prefer_threads, block_size,
184197
)

src/rand/randn.jl

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
const ALLOWED_RANDN_SCALARS = Union{Float16, Float32, Float64}
1+
const ALLOWED_RANDN_SCALARS = Union{
2+
Float16, Float32, Float64
3+
}
24

3-
const U24_MAX_SAFE_MIDPOINT = UInt32(0x00fffffe) # 2^24 - 2
4-
const U53_MAX_SAFE_MIDPOINT = UInt64(0x001ffffffffffffe) # 2^53 - 2
5-
const MIDPOINT_SCALE_F32 = ldexp(Float32(1), -24) # 2^-24
6-
const MIDPOINT_SCALE_F64 = ldexp(Float64(1), -53) # 2^-53
5+
const OPEN01_MAX_MIDPOINT_INDEX_F32 = UInt32(0x00fffffe)
6+
const OPEN01_MAX_MIDPOINT_INDEX_F64 = UInt64(0x001ffffffffffffe)
7+
const OPEN01_MIDPOINT_SCALE_F32 = ldexp(Float32(1), -24)
8+
const OPEN01_MIDPOINT_SCALE_F64 = ldexp(Float64(1), -53)
79

810

911

@@ -19,16 +21,16 @@ Avoiding 0 is essential for Box-Muller due to the logarithm functions.
1921
# Convert random UInt32 bits to Float32 in (0, 1) using midpoint mapping on a 24-bit grid.
2022
@inline function uint32_to_open_unit_float32_midpoint(u::UInt32)::Float32
2123
# `min` keeps the top midpoint below one after Float32 rounding.
22-
k = min(u >> 8, U24_MAX_SAFE_MIDPOINT)
23-
return (Float32(k) + 0.5f0) * MIDPOINT_SCALE_F32
24+
k = min(u >> 8, OPEN01_MAX_MIDPOINT_INDEX_F32)
25+
return (Float32(k) + 0.5f0) * OPEN01_MIDPOINT_SCALE_F32
2426
end
2527

2628

2729
# Convert random UInt64 bits to Float64 in (0, 1) using midpoint mapping on a 53-bit grid.
2830
@inline function uint64_to_open_unit_float64_midpoint(u::UInt64)::Float64
2931
# `min` keeps the top midpoint below one after Float64 rounding.
30-
k = min(u >> 11, U53_MAX_SAFE_MIDPOINT)
31-
return (Float64(k) + 0.5) * MIDPOINT_SCALE_F64
32+
k = min(u >> 11, OPEN01_MAX_MIDPOINT_INDEX_F64)
33+
return (Float64(k) + 0.5) * OPEN01_MIDPOINT_SCALE_F64
3234
end
3335

3436

@@ -201,8 +203,6 @@ end
201203
# CPU settings
202204
max_tasks::Int=Threads.nthreads(),
203205
min_elems::Int=1,
204-
205-
# Implementation choice
206206
prefer_threads::Bool=true,
207207
208208
# GPU settings
@@ -215,6 +215,8 @@ For `v[i]`, the normal stream counter is `rng.offset + UInt64(i - 1)` in linear
215215
Values are generated using Box-Muller from midpoint-open uniforms in `(0, 1)`.
216216
217217
After filling `v`, `rng.offset` advances by `length(v)`.
218+
219+
It can be called without an `rng`, in which case the default `CounterRNG` will be used.
218220
"""
219221
function randn!(
220222
rng::CounterRNG,
@@ -269,9 +271,13 @@ end
269271
backend::Backend,
270272
::Type{T},
271273
dims::Integer...;
274+
275+
# CPU settings
272276
max_tasks::Int=Threads.nthreads(),
273277
min_elems::Int=1,
274278
prefer_threads::Bool=true,
279+
280+
# GPU settings
275281
block_size::Int=256,
276282
) where T
277283
@@ -283,12 +289,17 @@ function randn(
283289
backend::Backend,
284290
::Type{T},
285291
dims::Integer...;
292+
293+
# CPU settings
286294
max_tasks::Int=Threads.nthreads(),
287295
min_elems::Int=1,
288296
prefer_threads::Bool=true,
297+
298+
# GPU settings
289299
block_size::Int=256,
290300
) where T
291-
return _allocate_and_fill(
301+
@argcheck T <: ALLOWED_RANDN_SCALARS "Unsupported eltype $T. Supported: $(ALLOWED_RANDN_SCALARS)"
302+
return _allocate_and_fill_rand(
292303
randn!, rng, backend, T, dims...;
293304
max_tasks, min_elems, prefer_threads, block_size,
294305
)
@@ -299,9 +310,13 @@ function randn(
299310
backend::Backend,
300311
::Type{T},
301312
dims::Integer...;
313+
314+
# CPU settings
302315
max_tasks::Int=Threads.nthreads(),
303316
min_elems::Int=1,
304317
prefer_threads::Bool=true,
318+
319+
# GPU settings
305320
block_size::Int=256,
306321
) where T
307322
return randn(

src/rand/utilities.jl

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,19 @@
1616

1717

1818
# Shared allocation + fill helper for rand/randn convenience constructors.
19-
@inline function _allocate_and_fill(
19+
@inline function _allocate_and_fill_rand(
2020
fill!,
2121
rng::CounterRNG,
2222
backend::Backend,
2323
::Type{T},
2424
dims::Integer...;
25+
26+
# CPU settings
2527
max_tasks::Int=Threads.nthreads(),
2628
min_elems::Int=1,
2729
prefer_threads::Bool=true,
30+
31+
# GPU settings
2832
block_size::Int=256,
2933
) where {T}
3034
dims_int = Base.map(Int, dims)
@@ -34,13 +38,6 @@
3438
end
3539

3640

37-
# Internal scalar eltypes currently supported by rand!.
38-
const ALLOWED_RAND_SCALARS = Union{
39-
UInt8, UInt16, UInt32, UInt64,
40-
Int8, Int16, Int32, Int64,
41-
Float16, Float32, Float64,
42-
Bool
43-
}
4441

4542

4643
@inline _rand_scalar_uint_type(::Type{UInt8}) = UInt32

0 commit comments

Comments
 (0)