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

@only_one block is executed by a single iteration (not a single task) #100

Closed
CarloLucibello opened this issue Mar 28, 2024 · 1 comment · Fixed by #101
Closed

@only_one block is executed by a single iteration (not a single task) #100

CarloLucibello opened this issue Mar 28, 2024 · 1 comment · Fixed by #101

Comments

@CarloLucibello
Copy link
Contributor

CarloLucibello commented Mar 28, 2024

From my understanding of the docstring

  @only_one begin ... end

  This can be used inside a @tasks for ... end block to mark a region of code to be executed by only one
  of the parallel tasks (all other tasks skip over this region).

I was expecting

@tasks for i in 1:8
    @set ntasks = 2

    println(i, ": before")
    @only_one begin
        println(i, ": after")
    end
end

to print after 4 times (since a single task has to run 4 iterations of the loop). Instead, I get the output

5: before
1: before
5: after
6: before
2: before
7: before
8: before
3: before
4: before

Is this expected? Should the docstring be changed or I just got it wrong? It seems to me that this macro should be called @only_once instead.

carstenbauer added a commit that referenced this issue Mar 28, 2024
@carstenbauer carstenbauer mentioned this issue Mar 28, 2024
carstenbauer added a commit that referenced this issue Mar 28, 2024
@carstenbauer
Copy link
Member

This was indeed a bug. I committed a fix (to master). Feel free to try it out.

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

Successfully merging a pull request may close this issue.

2 participants