Bumper.jl
Bumper.jl copied to clipboard
@no_escape is incompatible with Threads.@threads
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)
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" 😊