Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29277 Discussions

Does a lot of "if ... else" statements slow down the code?

Wee_Beng_T_
Beginner
1,444 Views
Hi,
I've a general question about F90. I've heard thatlots of "if ... else" statements slow down the code?
Especially with optimization and when one is trying to parallel the code.
Is this true? Or is this too general to define?
thanks!
0 Kudos
1 Solution
Steven_L_Intel1
Employee
1,443 Views
In general, yes, it would. Conditional statements pose difficulty for parallelization and vectorization, and a long series of IF-THEN can also cause instruction cache misses and other effects. But if that's what makes the code clearest, then use it.

This is not unique to Fortran - it would apply to any language.

View solution in original post

0 Kudos
1 Reply
Steven_L_Intel1
Employee
1,444 Views
In general, yes, it would. Conditional statements pose difficulty for parallelization and vectorization, and a long series of IF-THEN can also cause instruction cache misses and other effects. But if that's what makes the code clearest, then use it.

This is not unique to Fortran - it would apply to any language.
0 Kudos
Reply