mirror of
https://github.com/YosysHQ/yosys
synced 2025-11-08 23:35:08 +00:00
Run ABCs in parallel.
Large circuits can run hundreds or thousands of ABCs in a single AbcPass. For some circuits, some of those ABC runs can run for hundreds of seconds. Running ABCs in parallel with each other and in parallel with main-thread processing (reading and writing BLIF files, copying ABC BLIF output into the design) can give large speedups.
This commit is contained in:
parent
38f8165c80
commit
27462da208
6 changed files with 362 additions and 88 deletions
45
kernel/threading.cc
Normal file
45
kernel/threading.cc
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#include "kernel/yosys_common.h"
|
||||
#include "kernel/threading.h"
|
||||
|
||||
YOSYS_NAMESPACE_BEGIN
|
||||
|
||||
void DeferredLogs::flush()
|
||||
{
|
||||
for (auto &m : logs)
|
||||
if (m.error)
|
||||
YOSYS_NAMESPACE_PREFIX log_error("%s", m.text.c_str());
|
||||
else
|
||||
YOSYS_NAMESPACE_PREFIX log("%s", m.text.c_str());
|
||||
}
|
||||
|
||||
int ThreadPool::pool_size(int reserved_cores, int max_threads)
|
||||
{
|
||||
#ifdef YOSYS_ENABLE_THREADS
|
||||
int num_threads = std::min<int>(std::thread::hardware_concurrency() - reserved_cores, max_threads);
|
||||
return std::max(0, num_threads);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
ThreadPool::ThreadPool(int pool_size, std::function<void(int)> b)
|
||||
: body(std::move(b))
|
||||
{
|
||||
#ifdef YOSYS_ENABLE_THREADS
|
||||
threads.reserve(pool_size);
|
||||
for (int i = 0; i < pool_size; i++)
|
||||
threads.emplace_back([i, this]{ body(i); });
|
||||
#else
|
||||
log_assert(pool_size == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
ThreadPool::~ThreadPool()
|
||||
{
|
||||
#ifdef YOSYS_ENABLE_THREADS
|
||||
for (auto &t : threads)
|
||||
t.join();
|
||||
#endif
|
||||
}
|
||||
|
||||
YOSYS_NAMESPACE_END
|
||||
Loading…
Add table
Add a link
Reference in a new issue