do d9 $ midicmd "stop" # s "midi" hush d9 $ midicmd "start" # s "midi" scalePattern = slow 16 "" d1 $ note ((scaleP scalePattern $ off 4 ((+ 2 ).slow 2) $ off 1 (inversion.slow 2) $ off 3 (inversion.slow 3) $ off 1.5 ((+ 2).rev.slow 2) $ generateMelodicSeed ))#s "[pe-gtr:10,midi]" #gain 1 #orbit 0 #midichan 1

Loop Unrolling

Loop unrolling is an optimization that is typically made by the compiler, although it can be manually accomplished in assembly. When an iteration occurs in the code, and the number of times the iteration loops is known at compile time, the loop can be unrolled. Unrolling the loop means replacing the iteration instruction with hard-coded instructions for each iteration one after the other. For example, consider the following loop:

for (size_t index=0; index<3; index++){
	std::cout<<index;
}

The unrolled version is:

std::cout<<1;
std::cout<<2;
std::cout<<3;

Since we know we are going to loop 3 times when we compile, we can replace the loop with hard-coded instructions. The resulting assembly is much faster than conditionally looping.


Notes mentioning this note



Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.