I have the following loop in c++
dword result = 0;
for ( int i = 0; i < 16; i++ ) {
result |= ( value[i] << (unsigned int)( i << 1 ) );
}
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.
My idea was to loop trough the value array in parallel:
And fill a new array with newarray[0] = value[0] << (unsigned int)(0 << 1 )
, newarray[1] = value[1] << (unsigned int)(1 << 1 )
, etc. Then I would OR the values in the array in parallel in a tree structure (see image).
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.
Thank you for your consideration of this matter, I look forward to a response.