I have an float array with size of 1 million
which I need to add the elements with same remaining in division to 10, I found reduction function but I should have 10 output instead of 1. To explain better, I need to parallelism the below function: (it’s not completely true… just I write that to explain)
for(int i = 0; i < size; i++) {
if (i%10 == 0)
output[0] += input[i];
if (i%10 == 1)
output[1] += input[i];
if (i%10 == 2)
output[2] += input[i];
if (i%10 == 3)
output[3] += input[i];
if (i%10 == 4)
output[4] += input[i];
if (i%10 == 5)
output[5] += input[i];
if (i%10 == 6)
output[6] += input[i];
if (i%10 == 7)
output[7] += input[i];
if (i%10 == 8)
output[8] += input[i];
if (i%10 == 9)
output[9] += input[i];
}