Skip to content

Repository files navigation

std::thread based thread pool

A simple std::thread based thread pool with a parallel-for loop implementation.

Example of how to perform STREAM benchmark scale operation in parallel:

voidscale(int i, double* a, double* b) {
a[i]=4*b[i];
}
intmain () {
ThreadPool pool(8);
int N = 1e9;
auto a = (double*)calloc(N,sizeof(double));
auto b = (double*)calloc(N,sizeof(double));
for (int i=0; i<N; i++) { b[i] = i; }
{
Timer timer([&](int elapsed) { cout << elapsed*1e-6 << " ms\n"; });
pool.ParallelFor(0,N,scale,a,b);
}
return0;
}

About

A simple C++11 threadpool

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages