So,I have two loops that I would like to attempt to do a 10 x 10 unrolling on. I really have never done this. I have seen some simple examples that did not involve if/else statements or nested loops. So I am kind of at a loss how to do this for these loops.
All the variables are int.
The first loop is:
for (j=0; j < WIDTH; ++j) {
for (i = 0; i < HEIGHT; ++i) {
n = Calculate(prv, i, j);
if (prv[i][j] && (n == 3 || n == 2))
nxt[i][j] = true;
else if (!prv[i][j] && (n == 3))
nxt[i][j] = true;
else
nxt[i][j] = false;
}
}
I believe the secret is doing some sort of multiple accumulators, I am just not quite sure how that would look.
The second loop:
for (ii = i_left; ii < i_right; ++ii) {
for (jj = j_left; jj < j_right; ++jj) {
n += b[ii][jj];
}
}
Again, I believe this too would involve some sort of multiple accumulator approach as well.
Any help getting started on this would be greatly appreciated. Also, if there are any other ways to optimize the loops, I would appreciate those suggestions as well.
Thank you