KernelAbstractions.jl
KernelAbstractions.jl copied to clipboard
[FR] Add nthreads argument to CPU backend
Hi! First of all congratulations on the fantastic package :)
Sometimes, seeing how the speed scales as a function of the number of threads is helpful.
My understanding is that right now the only way to change this is to run Julia differently julia --nthreads=X, and KA uses Julia's Threads.nthreads() (L95 here) to launch different processes:
https://github.com/JuliaGPU/KernelAbstractions.jl/blob/bafa3ccf706d1723aee5dcedf4180ca1c5dc16cb/src/cpu.jl#L93-L100
Could this be an argument of the CPU backend? For example, launching a kernel with CPU(8) would run with 8 threads (if 8 <= Threads.nthreads()). So we don't need to restart Julia with a different number of threads.
Obviously it doesn't need to be an argument in the backend, there might be a better way to implement this
Forgive me if there is a way to do this that I haven't realized.
Cheers!