Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "KernelAbstractions"
uuid = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
authors = ["Valentin Churavy <v.churavy@gmail.com> and contributors"]
version = "0.9.41"
version = "0.9.42"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
16 changes: 9 additions & 7 deletions src/cpu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,15 @@ function __run(obj, ndrange, iterspace, args, dynamic, static_threads)
if Nthreads == 1
__thread_run(1, len, rem, obj, ndrange, iterspace, args, dynamic)
else
if static_threads
Threads.@threads :static for tid in 1:Nthreads
__thread_run(tid, len, rem, obj, ndrange, iterspace, args, dynamic)
end
else
@sync for tid in 1:Nthreads
Threads.@spawn __thread_run(tid, len, rem, obj, ndrange, iterspace, args, dynamic)
let len = len, rem = rem, Nthreads = Nthreads
if static_threads
Threads.@threads :static for tid in 1:Nthreads
__thread_run(tid, len, rem, obj, ndrange, iterspace, args, dynamic)
end
else
@sync for tid in 1:Nthreads
Threads.@spawn __thread_run(tid, len, rem, obj, ndrange, iterspace, args, dynamic)
end
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ A = zeros(Int, Threads.nthreads())
kern_static(CPU(static = true), (1,))(A, ndrange = length(A))
@test A == 1:Threads.nthreads()

@testset "__run does not box (no per-launch Core.Box)" begin
ci = only(code_lowered(KernelAbstractions.__run, NTuple{6, Any}))
@test !any(e -> occursin("Box", string(e)), ci.code)
end

@kernel cpu = false function my_no_cpu_kernel(a)
end
@test_throws ErrorException("This kernel is unavailable for backend CPU") my_no_cpu_kernel(CPU())
Expand Down
Loading