3 ms·
The loop size is all that matters. The thing that's being optimized is just: for (int i = 0; i < loop_size; i++) { some_work(); } Whatever some_work m
by Jtsummers 5y ago
The loop size is all that matters. The thing that's being optimized is just:
for (int i = 0; i < loop_size; i++) {
some_work();
}
Whatever some_work may be you want to unroll the loop to avoid the jumps. It could be an operation like:
c[i] = a[i] + b[i]
In which case you'd do like you suggest. But it could also just be some repeated operation on an entire data set, like in a simulation where you want to run loop_size iterations.