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

Const[i16] in step position of 'range' causes error message #2499

Closed
rebcabin opened this issue Feb 7, 2024 · 3 comments
Closed

Const[i16] in step position of 'range' causes error message #2499

rebcabin opened this issue Feb 7, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@rebcabin
Copy link
Contributor

rebcabin commented Feb 7, 2024

from lpython import i32, i16, Const
VR_SIZE: i32 = 32_768
l: Const[i32] = VR_SIZE
n: Const[i32] = 15
m: Const[i32] = 3
k: i32
M2: Const[i32] = 5  # ~~~~~~~~~~~~~~~~~~~~~~~~~~ ATTENTION ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A_ik: i16
jj: i32
ii: i32
i: i32
for jj in range(0, l, VR_SIZE):  # each VR-col chunk in B and C
    for ii in range(0, n, M2):  # each M2 block in A cols and B rows  # !!!!!!!!!!!!!!
        for i in range(0, M2):  # zero-out rows of C
            pass
        for k in range(0, m):  # rows of B
            for i in range(0, M2):
                pass
(lp) ┌─(~/Documents/GitHub/lpython/integration_tests)──────────────────────────────────────────────────────────────────────────────(brian@MacBook-Pro:s001)─┐
└─(07:13:11 on vector-backend ✹ ✭)──> lpython ../ISSUES/Issue2499.py                                                                     ──(Wed,Feb07)─┘
semantic error: For loop increment type should be Integer.
  --> ../ISSUES/Issue2499.py:13:5 - 18:20
   |
13 |        for ii in range(0, n, M2):  # each M2 block in A cols and B rows
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
...
   |
18 |                    pass
   | ...^^^^^^^^^^^^^^^^^^^^ 

@rebcabin rebcabin added the bug Something isn't working label Feb 7, 2024
@Shaikh-Ubaid
Copy link
Collaborator

Shaikh-Ubaid commented Feb 7, 2024

This #2501 would hopefully fix the constant step in loop issue.

There is also another issue in the above code.

VR_SIZE: i32 = 32_768
l: Const[i32] = VR_SIZE

VR_SIZE is a variable (not a constant) for which the value will be assigned at run time. So, we cannot use VR_SIZE as the constant/initialization value for l: Const[i32] = VR_SIZE.

Currently, we can do either of the following ways to fix the above.

VR_SIZE should also be a constant so that its value can be used to initialize another constant. For example:

VR_SIZE: Const[i32] = 32_768
l: Const[i32] = VR_SIZE

Or we can simply initialize l with the constant value. For example:

VR_SIZE: i32 = 32_768
l: Const[i32] = 32_768

@rebcabin
Copy link
Contributor Author

rebcabin commented Feb 7, 2024

Thanks. Yes, I missed that last one.

@Shaikh-Ubaid
Copy link
Collaborator

Completed in #2501.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants