Typechecker Issue
Opened this issue · 3 comments
The typechecker catches this
let arr: ubit<10>[10][10];
let perm: ubit<10>[10];
for (let i=0..10) {
let x = perm[i];
let y = perm[i+1];
let v = arr[x][y];
}
however this seems to not be caught
let arr: ubit<10>[10][10];
let perm: ubit<10>[10];
for (let i=0..10) {
let v = arr[perm[i]][perm[i+1]];
}
Oh odd! Maybe it is not assigning a dynamic index type to the accesses memories?
AffineType check tries to consume the array. Looking at the contents of contentList
from getConsumeList
bank 0 of the variable arr
is consumed. Banks of the variable perm
are not consumed.
Surely enough as bank 0 of arr is consumed the type-checker catches the following
let arr: ubit<10>[10][10];
let perm: ubit<10>[10];
for (let i=0..10) {
let v = arr[perm[i]][perm[i+1]];
let y = arr[1][2];
}
[Type error] [Line 6, Column 13] Bank 0 for physical resource `arr' already consumed.
let y = arr[1][2];
^
`arr' originally had 1 resource(s).
Previous locations that consumed bank 0:
[5.13] Required 1 resource(s):
let v = arr[perm[i]][perm[i+1]];
^
Last gadget trace was:
[{0}][{0}]
[{0}]
and even
let arr: ubit<10>[10][10];
let perm: ubit<10>[10];
for (let i=0..10) {
let v = arr[perm[i]][perm[i+1]];
let y = arr[perm[i+2]][perm[i+3]];
}
Adding a screenshot of the stacktrace from debugging.
https://github.com/cucapra/dahlia/blob/master/src/main/scala/typechecker/AffineCheck.scala#L279-L293
![Screenshot 2024-01-10 at 12 15 42 PM](https://private-user-images.githubusercontent.com/20227996/295474212-f3a1baec-9254-413f-a467-29a981d483c8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA1MzY3MzAsIm5iZiI6MTcyMDUzNjQzMCwicGF0aCI6Ii8yMDIyNzk5Ni8yOTU0NzQyMTItZjNhMWJhZWMtOTI1NC00MTNmLWE0NjctMjlhOTgxZDQ4M2M4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA5VDE0NDcxMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTdjMTdjNTFmMjI0MTZkZGE2YzNkYzkxMDNlYjFkYTE4YTJlOTNhZjIyYzc1NmNiNWZlNjBkYzNmNWRlYjQ0MmEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.v_N5GgFv0j3EOZXOC_P7XW0s1rstNNjHd1Uo4nIAucE)
Hm, the problem is that perm[i]
needs to imply that all banks in a particular dimension need to be consumed. Currently, it is only saying that one bank is being consumed. This probably needs to be changes in Gadgets.scala
or something