Skip to content

Kernel.h - Add loop unroll hint macros

Christopher Rob Jones requested to merge jonrob/Gaudi:AddLoopUnrollMacros into master

Can be useful in certain situations, when small fixed sized (compile time) loops are present.

Have used them in a number of situation in LHCb code to gain CPU performance (quite significant in some cases, e.g. lhcb/Rec!1583 (merged)) so think it would be useful to expose them more widely via Gaudi.

Usage is simple. Just use the macro directly before any loop you wish to unroll. e.g.

GAUDI_LOOP_UNROLL(N)
for ( std::size_t i = 0; i < N; ++i ) {
 // do stuff
}

Constraints on N are it needs to be something known at compile time.

Macro makes most sense when used with a fixed size (small) loops. However, in principle can be used with any loop, even dynamic sized ones, its just less clear what the gains are there.

Edited by Christopher Rob Jones

Merge request reports