Skip to content

Commit

Permalink
tests for context reference counting + packed convert
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDanisch committed Aug 1, 2017
1 parent 1e5678b commit cf2dd89
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ using Base.Test

using OpenCL

@testset "aligned convert" begin
x = ((10f0, 1f0, 2f0), (10f0, 1f0, 2f0), (10f0, 1f0, 2f0))
x_aligned = cl.packed_convert(x)

@test x_aligned == ((10f0, 1f0, 2f0), cl.Pad{4}(), (10f0, 1f0, 2f0), cl.Pad{4}(), (10f0, 1f0, 2f0), cl.Pad{4}())
x_aligned_t = cl.packed_convert(typeof(x))
@test x_aligned_t == typeof(x_aligned)

x = cl.packed_convert(77f0)
@test x == 77f0
end

function create_test_buffer()
ctx = cl.create_some_context()
queue = cl.CmdQueue(ctx)
Expand All @@ -24,4 +36,9 @@ include("test_memory.jl")
include("test_buffer.jl")
include("test_array.jl")

@testset "context jl reference counting" begin
gc()
@test isempty(cl._ctx_reference_count)
end

end # module
16 changes: 16 additions & 0 deletions test/test_context.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,22 @@
for device in cl.devices(platform)
ctx = cl.Context(device)
@test ctx != nothing
ctx_id = ctx.id
ctx2 = cl.Context(ctx_id)
@test cl.is_ctx_id_alive(ctx_id)
@test ctx.id != C_NULL
@test ctx2.id != C_NULL
finalize(ctx)
@test ctx.id == C_NULL
@test ctx2.id != C_NULL
@test cl.is_ctx_id_alive(ctx_id)
finalize(ctx2)
@test ctx.id == C_NULL
@test ctx2.id == C_NULL
# jeez, this segfaults... WHY? I suspect a driver bug for refcount == 0?
# NVIDIA 381.22
#@test !cl.is_ctx_id_alive(ctx_id)

end
end
end
Expand Down Expand Up @@ -78,4 +93,5 @@
@test parsed_properties[2] == cl.cl_context_properties(platform.id)
end
end

end

0 comments on commit cf2dd89

Please sign in to comment.