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

Threads.@threads doesn't play nicely with Iterators.product #52343

Closed
RJDennis opened this issue Nov 29, 2023 · 4 comments
Closed

Threads.@threads doesn't play nicely with Iterators.product #52343

RJDennis opened this issue Nov 29, 2023 · 4 comments

Comments

@RJDennis
Copy link

Should we expect the following to error?

Threads.@threads for i in Iterators.product(1:3,1:2)
  println(i)
end
@mcabbott
Copy link
Contributor

While a normal for loop just iterates over the set, the threaded one has to be able to index it. At present that's not defined for ProductIterator, but it wouldn't be crazy to enable it.

See e.g. #48745 for discussion about indexing Generator (where there's a concern about side-effects).

@Seelengrab
Copy link
Contributor

I think this could be solved with #52096

@Seelengrab
Copy link
Contributor

With 1.11/#52096, the :greedy scheduler option can now handle this:

julia> Threads.@threads :greedy for i in Iterators.product(1:3,1:2)
         println(i)
       end
(2, 1)
(3, 1)
(1, 2)
(3, 2)
(1, 1)
(2, 2)

Does this solve the issue?

@RJDennis
Copy link
Author

Yes it does, thanks.

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

3 participants