Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29281 Discussions

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

Wee_Beng_T_
Beginner
1,451 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,450 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,451 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