mirror of
https://github.com/ivabus/pantry
synced 2024-11-14 12:35:10 +03:00
22 lines
422 B
C++
22 lines
422 B
C++
|
#include <iostream>
|
||
|
#include <tbb/blocked_range.h>
|
||
|
#include <tbb/parallel_reduce.h>
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
auto total = tbb::parallel_reduce(
|
||
|
tbb::blocked_range<int>(0, 100),
|
||
|
0.0,
|
||
|
[&](tbb::blocked_range<int> r, int running_total)
|
||
|
{
|
||
|
for (int i=r.begin(); i < r.end(); ++i) {
|
||
|
running_total += i + 1;
|
||
|
}
|
||
|
|
||
|
return running_total;
|
||
|
}, std::plus<int>()
|
||
|
);
|
||
|
|
||
|
std::cout << total << std::endl;
|
||
|
return 0;
|
||
|
}
|