Skip to content

Instantly share code, notes, and snippets.

@mebjas
Created July 11, 2022 09:15
Show Gist options
  • Select an option

  • Save mebjas/241dc9f965649184c1a2eadd94a68801 to your computer and use it in GitHub Desktop.

Select an option

Save mebjas/241dc9f965649184c1a2eadd94a68801 to your computer and use it in GitHub Desktop.
Example of loop unrolling vs default
# Without Loop Unrolling
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) {
for (int c = 0; c < 3; ++c) {
output(x, y, c) = input(x, y, c) + b;
}
}
}
# With Loop Unrolling
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) {
output(x, y, 0) = input(x, y, 0) + b;
output(x, y, 1) = input(x, y, 1) + b;
output(x, y, 2) = input(x, y, 2) + b;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment