File tree Expand file tree Collapse file tree 5 files changed +22
-3
lines changed Expand file tree Collapse file tree 5 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,9 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
30
30
[weakdeps ]
31
31
SpecialFunctions = " 276daf66-3868-5448-9aa4-cd146d93841b"
32
32
33
+ [sources ]
34
+ GPUCompiler = {rev = " tb/kernel_state_reference" , url = " https://github.com/JuliaGPU/GPUCompiler.jl.git" }
35
+
33
36
[extensions ]
34
37
SpecialFunctionsExt = " SpecialFunctions"
35
38
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ GPUCompiler.runtime_module(::MetalCompilerJob) = Metal
8
8
9
9
GPUCompiler. method_table (:: MetalCompilerJob ) = method_table
10
10
11
- GPUCompiler. kernel_state_type (job:: MetalCompilerJob ) = MtlRefValue{ KernelState}
11
+ GPUCompiler. kernel_state_type (job:: MetalCompilerJob ) = KernelState
12
12
13
13
function GPUCompiler. finish_module! (@nospecialize (job:: MetalCompilerJob ),
14
14
mod:: LLVM.Module , entry:: LLVM.Function )
Original file line number Diff line number Diff line change @@ -39,5 +39,4 @@ struct KernelState
39
39
random_seed:: UInt32
40
40
end
41
41
42
- # @inline @generated kernel_state() = GPUCompiler.kernel_state_value(KernelState)
43
- @inline @generated kernel_state () = GPUCompiler. kernel_state_value (MtlRefValue{KernelState})[]
42
+ @inline @generated kernel_state () = GPUCompiler. kernel_state_value (KernelState)
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
5
5
Dates = " ade2ca70-3891-5945-98fb-dc099432e06a"
6
6
Distributed = " 8ba89e20-285c-5b6f-9357-94700520ee1b"
7
7
GPUArrays = " 0c68f7d7-f131-5f86-a1c3-88cf8149b2d7"
8
+ GPUCompiler = " 61eb1bfa-7361-4325-ad38-22787b887f55"
8
9
InteractiveUtils = " b77e0a4c-d291-57a0-90e8-8db25a27a240"
9
10
JLD2 = " 033835bb-8acc-5ee8-8aae-3f567f8a3819"
10
11
KernelAbstractions = " 63c18a36-062a-441e-b654-da1e3ab1ce7c"
@@ -20,3 +21,6 @@ SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
20
21
StaticArrays = " 90137ffa-7385-5640-81b9-e52037218182"
21
22
Statistics = " 10745b16-79ce-11e8-11f9-7d13ad32a3b2"
22
23
Test = " 8dfed614-e22c-5e08-85e1-65c5234f0b40"
24
+
25
+ [sources ]
26
+ GPUCompiler = {rev = " tb/kernel_state_reference" , url = " https://github.com/JuliaGPU/GPUCompiler.jl.git" }
Original file line number Diff line number Diff line change
1
+ @testset " device-side rng" begin
2
+ function rand_kernel! (a)
3
+ i = thread_position_in_grid_1d ()
4
+ a[i] = rand (Float32)
5
+ return
6
+ end
7
+
8
+ n = 128
9
+ a = Metal. fill! (- 1f0 , n)
10
+ @metal threads= n rand_kernel! (a)
11
+ @test all (0 .<= a .< 1 )
12
+ @test length (unique (Array (a))) == n
13
+ end
You can’t perform that action at this time.
0 commit comments