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

[BUG] parallelize won't work with local variables (they turn to uninitialized) #3483

Closed
futurwasfree opened this issue Sep 14, 2024 · 2 comments
Assignees
Labels
bug Something isn't working mojo-repo Tag all issues with this label

Comments

@futurwasfree
Copy link

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):
        idx = y * s
        print(y, s, idx)

    parallelize[worker](h,1)


def main():
    calc(1000, 300)

like the following:

0 140731463405744 0
1 140731463405744 140731463405744
2 140731463405744 281462926811488
3 140731463405744 422194390217232
4 140731463405744 562925853622976
5 140731463405744 703657317028720
6 140731463405744 844388780434464
7 140731463405744 985120243840208
...

if I use s_ within worker function - print produces expected result:

0 1000 0
1 1000 1000
2 1000 2000
3 1000 3000
4 1000 4000
5 1000 5000
6 1000 6000
7 1000 7000
8 1000 8000
9 1000 9000
10 1000 10000

I expect them to work in a similar way.

Steps to reproduce

  • Include relevant code snippet or link to code that did not work as expected.
  • If applicable, add screenshots to help explain the problem.
  • If using the Playground, name the pre-existing notebook that failed and the steps that led to failure.
  • Include anything else that might help us debug the issue.

System information

- What OS did you do install Mojo on ?
Ubuntu 24.04
- Provide version information for Mojo by pasting the output of `mojo -v`
mojo 24.5.0 (e8aacb95)
- Provide Modular CLI version by pasting the output of `modular -v`
magic 0.2.3
@futurwasfree futurwasfree added bug Something isn't working mojo-repo Tag all issues with this label labels Sep 14, 2024
Copy link
Contributor

Mogball commented Sep 17, 2024

Thanks for filing this issue. This is a known bug that will be fixed soon!

@Mogball Mogball self-assigned this Sep 17, 2024
@futurwasfree
Copy link
Author

Thank you for looking into it!

@Mogball Mogball closed this as not planned Won't fix, can't repro, duplicate, stale Sep 26, 2024
@Mogball Mogball closed this as completed Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

2 participants