Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
parallel_for_queued.cpp
Go to the documentation of this file.
1
#ifndef NO_MULTITHREADING
2
#include "
log.hpp
"
3
#include "
thread.hpp
"
4
#include "
thread_pool.hpp
"
5
#include <atomic>
6
#include <condition_variable>
7
#include <functional>
8
#include <mutex>
9
#include <queue>
10
#include <thread>
11
#include <vector>
12
13
namespace
bb
{
19
void
parallel_for_queued
(
size_t
num_iterations,
const
std::function<
void
(
size_t
)>& func)
20
{
21
static
ThreadPool
pool(
get_num_cpus
());
22
23
// info("wait for pool enter");
24
pool.
wait
();
25
for
(
size_t
i = 0; i < num_iterations; ++i) {
26
// info("enqueing iteration ", i);
27
pool.
enqueue
([=]() { func(i); });
28
}
29
// info("wait for pool exit");
30
pool.
wait
();
31
// info("pool finished work");
32
}
33
}
// namespace bb
34
#endif
bb::ThreadPool
Definition
thread_pool.hpp:13
bb::ThreadPool::wait
void wait()
Definition
thread_pool.cpp:37
bb::ThreadPool::enqueue
void enqueue(const std::function< void()> &task)
Definition
thread_pool.cpp:28
log.hpp
bb
Entry point for Barretenberg command-line interface.
Definition
acir_format_getters.cpp:6
bb::parallel_for_queued
void parallel_for_queued(size_t num_iterations, const std::function< void(size_t)> &func)
Definition
parallel_for_queued.cpp:19
bb::get_num_cpus
size_t get_num_cpus()
Definition
thread.hpp:12
thread.hpp
thread_pool.hpp
src
barretenberg
common
parallel_for_queued.cpp
Generated by
1.9.8