jzarnett / ece459

ECE 459: Programming for Performance
446 stars 137 forks source link

fix nested loop semantics #75

Closed chjon closed 2 years ago

chjon commented 2 years ago

The original example for loop interchange does not preserve the semantic behaviour of the pre-transformation loop. The transformation should only change the order in which the program iterates over the indices - it should not change how the indices are used. In the original example, we have a[i][j] -> a[j][i], which is wrong. One of the pre- or post-transformation loops should be changed so that both versions of the code have a[j][i] or a[i][j].

Since j is the inner loop variable in the pre-transformation code and we're suggesting that Rust is row-major, the pre-transformation code should be changed to a[j][i] to demonstrate that the loop interchange transformation reorders indices to match the ordering of array elements.

patricklam commented 2 years ago

Whoops, looks like I got carried away with reordering. Thanks.