AnsweredAssumed Answered

nested-if performance penalty if no else

Question asked by firespot on Aug 5, 2014
Latest reply on Aug 12, 2014 by dipak

Hi,

 

In 6.8.7.4 of the AMD OpenCL Programming Guide for AMD SDK (2.9; that's the version used here) it says there are performance penalties for nested if-statements and that "if blocks are nested k levels deep, 2^k nested conditional structures are generated".

Is this also applicable if an outer if-statement does not have any else-branches, or would this outer-if then not contribute to k?

 

E.g.:

 

<code>

if (someConditionUnknownAtCompileTimeButConstantAtRuntime)

{

// complex code here, including loops, nested ifs (these come with else-branches), etc.

}

</code>

 

I further suppose that a goto wouldn't make any difference?:

 

<code>

if (! someConditionUnknownAtCompileTimeButConstantAtRuntime)

  goto: End;

 

// complex code here, including loops, nested ifs (these come with else-branches), etc.

 

End:

</code>

 

any other suggestions?

thanks!

Outcomes