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

is it possible to set @turbo thread = true/false at runtime? #499

Open
alex-s-gardner opened this issue Jun 9, 2023 · 3 comments
Open

Comments

@alex-s-gardner
Copy link
Contributor

I have a function that uses @turbo and has a threaded kwarg

function f(a, b; threaded = true)
c = similar(a)
@turbo thread = true for i = eachindex(a)
     c[i] = a[i]+b[i]
end
end

is it possible to pass the function kwarg threaded to @turbo to set thread ?

@chriselrod
Copy link
Member

Currently no, but you could add support for this.

@chriselrod
Copy link
Member

You could even take a naive approach, of doing the translation automatically from

@turbo thread=b for ...

to

if b && Threads.nthreads()>1
   @turbo thread=true for ...
else
   @turbo thread=false for ...
end

if you want to get more creative, you could try and integrate with the runtime threading profitability check LV already does based on the number of loop iterations and expected cost.

@alex-s-gardner
Copy link
Contributor Author

Thanks @chriselrod … I’ve coded up a solution for now but would like to see if I can create a PR later this summer

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

2 participants