parallelize and @parameter issue in Mojo 24.5
I am trying to convert my projects to Mojo 24.5. Right now I face the following issue.
When running
I get 4507533440 printed as result.
In the @parameter doc https://docs.modular.com/mojo/manual/decorators/parameter it says
This is an unsafe feature because we currently do not model the lifetimes of capture-by-reference.
but up to 24.4 i never had this issue. Did i miss some fundamental change here? Any advice how to handle this would be great. Thx 🙏
ps
adding
at the end of this demo would solve the issue but that gets complicated and ugly in my projects ...
@parameter | Modular Docs
Executes a function or if statement at compile time.
4 Replies
GitHub
[BUG] parallelize won't work with local variables (they turn to uni...
Bug description Calling the following code produces garbage values for s and idx: from algorithm import parallelize fn calc(s: Int, h: Int): var s = 5000 var h = 100 @parameter fn worker(y:Int): ...
thanks a lot @sora
I think this is resolved on the latest nightly
thanks @sora , i just tried the little demo i posted with the current nightly (mojo 2024.9.2305 - f7b111af) and yeah, it worked as expected