Comments on: if ( simd ) { o_O }, or How to Vectorize Code With Different Execution Paths Could you post your code again? It's incomplete. Cheers, Andre Could you post your code again? It’s incomplete.

Cheers,

Andre

]]>
By: inter1965/2011/04/06/if-simd-o_o-or-how-to-vectorize-code-with-different-execution-paths-2/#comment-3674 inter1965 Sat, 07 May 2011 11:23:48 +0000 with the following code which is adapted from func1: /********************************************************/ void func(const size_t size, const float * const __restrict__ a, float * const __restrict__ b, float * const __restrict__ c) { for (size_t i(0); i=0.0f) { b[i] = -b[i]; } else { c[i] = -c[i]; } } } /*****************************************************/ I got the following reply from GCC 4.6.0 a.cpp:7: note: ===== analyze_loop_nest ===== a.cpp:7: note: === vect_analyze_loop_form === a.cpp:7: note: not vectorized: control flow in loop. a.cpp:7: note: bad loop form. a.cpp:3: note: vectorized 0 loops in function. So i'm curious too. How could you enable gcc and other compilers to deal with those non-trivial code path. with the following code which is adapted from func1:
/********************************************************/
void func(const size_t size,
const float * const __restrict__ a,
float * const __restrict__ b,
float * const __restrict__ c) {
for (size_t i(0); i=0.0f) {
b[i] = -b[i];
} else {
c[i] = -c[i];
}
}
}
/*****************************************************/
I got the following reply from GCC 4.6.0
a.cpp:7: note: ===== analyze_loop_nest =====
a.cpp:7: note: === vect_analyze_loop_form ===
a.cpp:7: note: not vectorized: control flow in loop.
a.cpp:7: note: bad loop form.
a.cpp:3: note: vectorized 0 loops in function.
So i’m curious too. How could you enable gcc and other compilers to deal with those non-trivial code path.

]]>
By: Andre Leiradella/2011/04/06/if-simd-o_o-or-how-to-vectorize-code-with-different-execution-paths-2/#comment-2415 Andre Leiradella Thu, 07 Apr 2011 03:25:33 +0000 For all of these examples I would just turn on auto vectorization in gcc and be done with it. I only use manual vectorization for large, yet simple functions, ie. more than 10 lines with one simple code path. For all of these examples I would just turn on auto vectorization in gcc and be done with it. I only use manual vectorization for large, yet simple functions, ie. more than 10 lines with one simple code path.

]]>
By: Andy-Thomason/2011/04/06/if-simd-o_o-or-how-to-vectorize-code-with-different-execution-paths-2/#comment-2388 Andy-Thomason Wed, 06 Apr 2011 07:56:40 +0000 SSE4.1 added pblendv, blendvps, etc ... Not as good as vsel or selb as there are byte rather than bit selects, but still useful with most masks. SSE4.1 added pblendv, blendvps, etc … Not as good as vsel or selb as there are byte rather than bit selects, but still useful with most masks.

]]>
By: Andre Leiradella/2011/04/06/if-simd-o_o-or-how-to-vectorize-code-with-different-execution-paths-2/#comment-2384 Andre Leiradella Wed, 06 Apr 2011 02:54:08 +0000 This reminds me of the techniques shader compilers use to avoid branching instructions. This reminds me of the techniques shader compilers use to avoid branching instructions.

]]>
By: Alex Rosenberg/2011/04/06/if-simd-o_o-or-how-to-vectorize-code-with-different-execution-paths-2/#comment-2382 Alex Rosenberg Wed, 06 Apr 2011 01:19:36 +0000