Skip to content

Commit

Permalink
Note that the compiler performs loop unrolling (JuliaLang#46001)
Browse files Browse the repository at this point in the history
This makes the `@generated` example obsolete, though it is still illustrative.
  • Loading branch information
LilithHafner authored and Francesco Fucci committed Aug 11, 2022
1 parent 92ae33c commit a6908d7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion doc/src/manual/metaprogramming.md
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,8 @@ Both these implementations, although different, do essentially the same thing: a
over the dimensions of the array, collecting the offset in each dimension into the final index.

However, all the information we need for the loop is embedded in the type information of the arguments.
Thus, we can utilize generated functions to move the iteration to compile-time; in compiler parlance,
This allows the compiler to move the iteration to compile time and eliminate the runtime loops
altogether. We can utilize generated functions to achieve a simmilar effect; in compiler parlance,
we use generated functions to manually unroll the loop. The body becomes almost identical, but
instead of calculating the linear index, we build up an *expression* that calculates the index:

Expand Down

0 comments on commit a6908d7

Please sign in to comment.