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

@no_escape is incompatible with Threads.@threads #32

Open
vuthanho opened this issue Nov 29, 2023 · 1 comment
Open

@no_escape is incompatible with Threads.@threads #32

vuthanho opened this issue Nov 29, 2023 · 1 comment

Comments

@vuthanho
Copy link

julia> function f1()
           @no_escape begin
               y = @alloc(Int,10)
               Threads.@threads for val in y
                   println(val)
               end
           end
       end
ERROR: LoadError: The `return` keyword is not allowed to be used inside the `@no_escape` macro

I have to nest the for loop inside a function to trick it:

julia> function _f(y)
           Threads.@threads for val in y
               println(y)
           end
       end
_f (generic function with 1 method)
julia> function f2()
           @no_escape begin
               y = @alloc(Int,10)
               _f(y)
           end
       end
f2 (generic function with 1 method)
@AhmedSalih3d
Copy link

AhmedSalih3d commented Mar 23, 2024

Any update on this @MasonProtter ? I've found that Polyester.@Batch can work inside of the @no_escape block, but that unfortunately it does not always thread the code as it should.

EDIT: By "update" I meant "thought/comment" 😊

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