Explanation
Burst inferencing will fail if it detects overlapping accesses of array elements. Consider rewriting the code to eliminate any overlapping accesses in the same region.
Examples
- Loop-carried dependency with RAW
dependence:
//////////// ORIGINAL //////////// void foo(int *a) { for (long i = 2; i < 256; ++i) a[i] = a[i-2]; } //////////// UPDATED //////////// // Remove overlapping accesses in the same region void foo(int *a, int *b, int n) { int t0 = a[0]; int t1 = a[1]; for (int i = 2; i < n; ++i) { int t2 = t0; a[i] = t2; t2 = t1; t1 = t0; t0 = t2; } }
- Anti-dependency
(WAR):
//////////// ORIGINAL //////////// void foo(int *a, int n) { int buff[50]; for (long i = 0; i < n; ++i) { buff[i] = a[i] + 100; ... a[i] = buff[i]; } } //////////// UPDATED //////////// // Remove overlapping accesses in the same region void foo(int *a, int n) { int buff[50]; for (long i = 0; i < n; ++i) { buff[i] = a[i] + 100; ... } for (long i = 0; i < n; ++i) a[i] = buff[i]; }