Skip to content

Commit 9337180

Browse files
committed
fix global_id calculation
also fix testsuite setup
1 parent 6426cc8 commit 9337180

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

src/device/random.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ struct Philox2x32{R} <: RandomNumbers.AbstractRNG{UInt64} end
4949
elseif field === :ctr1
5050
@inbounds global_random_counters()[subgroup_id]
5151
elseif field === :ctr2
52-
global_id = get_global_id(1) + (get_global_id(2) - Int32(1)) * get_global_size(1)
53-
+ (get_global_id(3) - Int32(1)) * get_global_size(1) * get_global_size(2)
52+
global_id = get_global_id(1) + (get_global_id(2) - Int32(1)) * get_global_size(1) +
53+
(get_global_id(3) - Int32(1)) * get_global_size(1) * get_global_size(2)
5454
global_id % UInt32
5555
end::UInt32
5656
end

test/device/random.jl

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ function apply_seed(seed)
1818
end
1919
end
2020

21-
@testset "rand($T), seed $seed" for T in (
22-
Int32, UInt32, Int64, UInt64, Float32, Float64,
23-
), seed in (nothing, #=missing,=# 1234)
21+
eltypes = [filter(x -> !(x <: Complex), GPUArraysTestSuite.supported_eltypes(CLArray)); UInt16; UInt32; UInt64]
22+
23+
@testset "rand($T), seed $seed" for T in eltypes, seed in (nothing, #=missing,=# 1234)
2424
# different kernel invocations should get different numbers
2525
@testset "across launches" begin
2626
function kernel(A::AbstractArray{T}, seed) where {T}
@@ -82,14 +82,11 @@ end
8282
# NOTE: we don't just generate two numbers and compare them, instead generating a
8383
# couple more and checking they're not all the same, in order to avoid
8484
# occasional collisions with lower-precision types (i.e., Float16).
85-
# TODO: why is the third dimension broken?
86-
@test length(unique(Array(a))) > 1 broken = active_dim == 3 || active_dim == 6
85+
@test length(unique(Array(a))) > 1
8786
end
8887
end
8988

90-
@testset "basic randn($T), seed $seed" for T in (
91-
Float32, Float64,
92-
), seed in (nothing, #=missing,=# 1234)
89+
@testset "basic randn($T), seed $seed" for T in filter(x -> x <: Base.IEEEFloat, eltypes), seed in (nothing, #=missing,=# 1234)
9390
function kernel(A::AbstractArray{T}, seed) where {T}
9491
apply_seed(seed)
9592
tid = get_global_id(1)
@@ -110,9 +107,7 @@ end
110107
end
111108
end
112109

113-
@testset "basic randexp($T), seed $seed" for T in (
114-
Float32, Float64,
115-
), seed in (nothing, #=missing,=# 1234)
110+
@testset "basic randexp($T), seed $seed" for T in filter(x -> x <: Base.IEEEFloat, eltypes), seed in (nothing, #=missing,=# 1234)
116111
function kernel(A::AbstractArray{T}, seed) where {T}
117112
apply_seed(seed)
118113
tid = get_global_id(1)

test/setup.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function runtests(f, name, platform_filter)
9191

9292
# some tests require native execution capabilities
9393
requires_il = name in ["atomics", "execution", "intrinsics", "kernelabstractions"] ||
94-
startswith(name, "gpuarrays/")
94+
startswith(name, "gpuarrays/") || startswith(name, "device/")
9595

9696
ex = quote
9797
GC.gc(true)

0 commit comments

Comments
 (0)