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

Scalar variable not correctly generated for loop unrolling #28

Open
overrainbow opened this issue Dec 1, 2020 · 0 comments
Open

Scalar variable not correctly generated for loop unrolling #28

overrainbow opened this issue Dec 1, 2020 · 0 comments

Comments

@overrainbow
Copy link

This issue occurs in loop unrolling. For example:

/*@ begin PerfTuning (
  4   def build
  5   {
  6   arg build_command = 'gcc -O3';
  7   arg libs = '-lm -lrt';
  8   }
  9
 10   def performance_counter
 11   {
 12   arg repetitions = 10;
 13   }
 14
 15   def performance_params
 16   {
 17
 18     # Unroll-jam
 19     param U1_I[] = [1]+range(2,17,2);
 20
 21     # Scalar replacement
 22     param SCR[]  = [False,True];
 23
 24   }
 25
 26   def search
 27   {
 28     arg algorithm = 'Exhaustive';
 29   }
 30
 31   def input_params
 32   {
 33   param N[] = [1000];
 34   }
 35
 36   def input_vars
 37   {
 38   arg init_file = 'init.c';
 39   }
 40 ) @*/
 41
 42 #define max(x,y)    ((x) > (y)? (x) : (y))
 43 #define min(x,y)    ((x) < (y)? (x) : (y))
 44
 45 int i;
 46 double expect;`

 50 /*@ begin Loop(
 51
 52   transform Composite(
 53     unrolljam = (['i'],[U1_I]),
 54     scalarreplace = (SCR, 'double')
 55   )
 56   for (i = 0; i <= N-1; i++) {
 57     expect = expect + s[i];
 58   }
 59
 60   expect = expect/N;
 61 ) @*/
 62
 63
 64 /*@ end @*/
 65
 66 /*@ end @*/ 

In one generated variant:

for (int loop_56=0; loop_56 < 1; loop_56++)  {
 69     for (int i = 0; i <= N - 16; i = i + 16) {
 70       expect = expect + s[i];
 71       expect1 = expect1 + s[(i + 1)];
 72       expect2 = expect2 + s[(i + 2)];
 73       expect3 = expect3 + s[(i + 3)];
 74       expect4 = expect4 + s[(i + 4)];
 75       expect5 = expect5 + s[(i + 5)];
 76       expect6 = expect6 + s[(i + 6)];
 77       expect7 = expect7 + s[(i + 7)];
 78       expect8 = expect8 + s[(i + 8)];
 79       expect9 = expect9 + s[(i + 9)];
 80       expect10 = expect10 + s[(i + 10)];
 81       expect11 = expect11 + s[(i + 11)];
 82       expect12 = expect12 + s[(i + 12)];
 83       expect13 = expect13 + s[(i + 13)];
 84       expect14 = expect14 + s[(i + 14)];
 85       expect15 = expect15 + s[(i + 15)];
 86     }
 87     for (int i = N - ((N - (0)) % 16); i <= N - 1; i = i + 1) {
 88       expect = expect + s[i];
 89     }
 90   }
 91 expect = expect / N;

It raises errors for the scalar variable:

error: ‘expect1’ undeclared (first use in this function); did you mean ‘expect’?
expect1 = expect1 + s[(i + 1)];

Thanks!

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

No branches or pull requests

1 participant