Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Add nthreads argument to CPU backend #507

Open
cncastillo opened this issue Aug 19, 2024 · 0 comments
Open

[FR] Add nthreads argument to CPU backend #507

cncastillo opened this issue Aug 19, 2024 · 0 comments

Comments

@cncastillo
Copy link

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:

function __run(obj, ndrange, iterspace, args, dynamic, static_threads)
N = length(iterspace)
Nthreads = Threads.nthreads()
if Nthreads == 1
len, rem = N, 0
else
len, rem = divrem(N, Nthreads)
end

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant