forked from JuliaGPU/CUDA.jl
/
pool.jl
38 lines (30 loc) · 982 Bytes
/
pool.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
CUDA.alloc(0)
@test_throws OutOfGPUMemoryError CuArray{Int}(undef, 10^20)
@testset "@allocated" begin
@test (CUDA.@allocated CuArray{Int32}(undef,1)) == 4
end
@testset "@timed" begin
out = CUDA.@timed CuArray{Int32}(undef, 1)
@test isa(out.value, CuArray{Int32})
@test out.gpu_bytes > 0
end
@testset "@time" begin
ret, out = @grab_output CUDA.@time CuArray{Int32}(undef, 1)
@test isa(ret, CuArray{Int32})
@test occursin("1 GPU allocation: 4 bytes", out)
x = CuArray{Int32}(undef, 6)
ret, out = @grab_output CUDA.@time Base.unsafe_wrap(CuArray, pointer(x), (2, 3))
@test isa(ret, CuArray{Int32})
@test !occursin("GPU allocation", out)
end
@testset "reclaim" begin
CUDA.reclaim(1024)
CUDA.reclaim()
@test CUDA.@retry_reclaim(isequal(42), 42) == 42
@test CUDA.@retry_reclaim(isequal(42), 41) == 41
end
@testset "memory_status" begin
CUDA.memory_status(devnull)
CUDA.used_memory()
CUDA.cached_memory()
end