Skip to content

Commit d0cee46

Browse files
Merge pull request #201 from Alexander-Barth/master
fix allocate_threadpool when NNPACK_CPU_THREADS is set
2 parents c8b7661 + 37dae3f commit d0cee46

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/nnpack/NNPACK.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ Allows NNPACK to intelligently choose which threadpool to use for getting the be
3434
performance.
3535
"""
3636
function allocate_threadpool()
37-
global NNPACK_CPU_THREADS = NNPACK_CPU_THREADS > 8 ? UInt64(8) : floor(log2(NNPACK_CPU_THREADS))
38-
for i in 1:Int(NNPACK_CPU_THREADS)
37+
global NNPACK_CPU_THREADS = NNPACK_CPU_THREADS > 8 ? UInt64(8) : UInt64(exp2(floor(log2(NNPACK_CPU_THREADS))))
38+
for i in 0:Int(log2(NNPACK_CPU_THREADS))
3939
threads = UInt64(2^i)
4040
push!(shared_threadpool_dict, threads => Ref(pthreadpool_create(threads)))
4141
end

0 commit comments

Comments
 (0)