The following code:
#include <ppl.h>
int i;
vector<int> val(10),summ(10,0);
for(i=0;i<10;i++) val[i]=i;
parallel_for(0, 10, [&] (int y){
vector<int> vett(1000);
double vall=val[y];
for(i=0;i<vett.size();i++)
vett[i]=vall;
for(i=0;i<vett.size();i++)
summ[y]+=vett[i];
});
for(i=0;i<10;i++)
cout<<summ[i]<<endl;
Produces random output like: 0 1000 1468 204 3600 25 5898 7000 7456 1395
I should use "combinable" I guess, but the documentation I found about it is not very good. Do you know how to make this code work correctly? What if vett is a 2d vector?
Since I'd like to learn parallel computing, is it worthy learning this new microsoft library or there are better alternatives?