File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -45,15 +45,15 @@ Consider a code example (Listing 1) that uses the C++17 parallel STL algorithm `
4545std::valarray<double > a (N);
4646
4747// Data placement is wrong, so parallel update is slow.
48- std::for_each(par, std::begin(a), std::end(a),
49- [ =] (double& a_i) { scalar * a_i ; });
50-
48+ std::for_each(par, std::begin(a), std::end(a),
49+ [ =] (double& a_i) { a_i * = scalar ; });
50+
5151// Use future affinity interface to migrate data at next
5252// use and move pages closer to next accessing thread.
5353...
5454// Faster, because data are local now.
55- std::for_each(par, std::begin(a), std::end(a),
56- [ =] (double& a ) { scalar * a_i ; } );
55+ std::for_each(par, std::begin(a), std::end(a),
56+ [ =] (double& a_i ) { a_i * = scalar ; });
5757```
5858*Listing 1: Parallel vector update example*
5959
You can’t perform that action at this time.
0 commit comments