How could I parallelize the following loop USING C++ AMP?
<p>I have the following loop in c++</p>

<pre><code>dword result = 0;
for ( int i = 0; i &lt; 16; i++ ) {
    result |= ( value[i] &lt;&lt; (unsigned int)( i &lt;&lt; 1 ) );
}
</code></pre>

<p>And I would like to parallelize it in amp. I know it might go slower then the actual non-parallelized version above, but I want to do it to learn something more about AMP.</p>

<p>My idea was to loop trough the value array in parallel:</p>

<p><img src="http://i.stack.imgur.com/CTaFV.png" alt="enter image description here"></p>

<p>And fill a new array with <code>newarray[0] = value[0] &lt;&lt; (unsigned int)(0 &lt;&lt; 1 )</code>, <code>newarray[1] = value[1] &lt;&lt; (unsigned int)(1 &lt;&lt; 1 )</code>, etc. Then I would OR the values in the array in parallel in a tree structure (see image). </p>

<p>I have tried to put this idea in some simple c++ amp code, but I don't succeed in it, so any help would be appreciated.</p>

<p>Thank you for your consideration of this matter, I look forward to a response.</p>
