c++,c,boost,macros,loop-unrolling
You can use templates to unroll. See the disassembly for the sample Live on Godbolt But -funroll-loops has the same effect for this sample. Live On Coliru template <unsigned N> struct faux_unroll { template <typename F> static void call(F const& f) { f(); faux_unroll<N-1>::call(f); } }; template <> struct faux_unroll<0u>...
c,gcc,optimization,loop-unrolling
in what contexts could this be useful if it usually makes the programs run more slowly? Well they are assuming if you choose this option you know what you are doing, if you don't you should not use this option. what is gcc going to do, well I used...
The CUDA 7.0 compiler will unroll this in my test. The loop indices are all known at compile time so there's no reason why it shouldn't be able to. Consider the following code, which sets a triangular portion of a to be 1. #define ROW_LENGTH 4 __global__ void triUnrollTest1(float* a)...