Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I haven't found anything about changing the optimization flags for a loop, however according to the documentation you can use the attribute <code>optimize</code> (look <a href="http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html" rel="nofollow">here</a> and <a href="http://www.acsu.buffalo.edu/~charngda/cc.html" rel="nofollow">here</a>) on a function to override the optimization settings for that function somewhat like this:</p> <pre><code>void foo() __attribute__((optimize("O2", "inline-functions"))) </code></pre> <p>If you want to change it for several functions, you can use <code>#pragma GCC optimize</code> to set it for all following functions (<a href="http://gcc.gnu.org/onlinedocs/gcc/Function-Specific-Option-Pragmas.html#Function-Specific-Option-Pragmas" rel="nofollow">look here</a>).</p> <p>So you should be able to compile the function containing crop with a different set of optimization flags, omitting the auto-vectorization. That has the disadvantage of hardcoding the compilation flags for that function, but is the best I found.</p> <p>With regards to restructuring for better performance the two points I already mentioned in the comments come to mind (assuming the ranges can't overlap):</p> <ul> <li><p>declaring the pointers as <code>__restrict</code> to tell the compiler that they don't alias (the area pointed to by one pointer won't be accessed by any other means inside the function). The possibility of pointer aliasing is a major stumbling block for the optimizer, since it can't easily reorder the accesses if it doesn't know if writing to <code>BufferD</code> will change the contents of <code>BufferS</code>.</p></li> <li><p>Replacing the inner loop with a call to copy:</p> <pre><code>std::copy(BufferS + rowOffsetS, BufferS + rowOffsetS + Destination.GetColumns(), BufferD + rowOffsetD); </code></pre> <p>The <code>copy</code> function is likely to be pretty well optimized (probably forwarding the arguments to <code>memmove</code>), so that might make your code faster, while also making your code shorter (always a plus).</p></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload