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

dace fails to compile a function with nested loops #1550

Closed
rohanrayan opened this issue Mar 19, 2024 · 1 comment · Fixed by #1746
Closed

dace fails to compile a function with nested loops #1550

rohanrayan opened this issue Mar 19, 2024 · 1 comment · Fixed by #1746
Milestone

Comments

@rohanrayan
Copy link

Describe the bug
I have a simple program below:

N = dace.symbol('N')
@dace.program(auto_optimize=True)
def error_fn_dace(L:dace.float64[N, N], index:dace.uint64, active_size:dace.uint64):
    for i in range(index, active_size - 1):
        L[i + 1][i] = 1.0

        for j in range(i, active_size-1):
            L[j + 1][i] = 2.0

When trying to compile this function, I get an error, but if I change the j for loop to:
for j in range(i, active_size)
it compiles.

Could you please let me know if I am doing something wrong?

To Reproduce
Steps to reproduce the behavior:

  1. I am using dace v0.15.1
  2. I have attached the python code which produces the error
    error_report.txt

Expected behavior
The compilation should not fail

Desktop (please complete the following information):

  • OS: [Linux]
  • DaCe v0.15.1
@tbennun
Copy link
Collaborator

tbennun commented Nov 10, 2024

Thanks! This is an auto-optimize related failure, which is now fixed in #1746.

There was actually another issue with the code: using uint64 for the bounds and subtracting one would actually convert it to a float64, according to NumPy 1 rules:

>>> np.uint64(1) + 1
2.0

So the correct code (for OpenMP to work) would be:

    @dace.program(auto_optimize=True)
    def tester(L: dace.float64[N, N], index: dace.uint64, active_size: dace.uint64):
        for i in range(index, active_size - 1):
            L[i + 1][i] = 1.0

            for j in range(i, dace.int64(active_size - 1)):
                L[j + 1][i] = 2.0

If you change both arguments to dace.int64, the code runs even faster.

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