mirror of
https://github.com/verilator/verilator.git
synced 2026-09-02 10:48:27 +02:00
Change default thread pool sizes to respect processor affinity (#6604)
Instead of using the number of processors in the host, use the number of processors available to the process, respecting cpu affinity assignments. Without pthreads, fall back and use the number of processors in the host as before. This is now applied everywhere so runing `nuamctl -C 0-3 verilator` or `numactl -C 0-3 Vsim` should behave as if the host has 4 cores (e.g. like in CI jobs)
This commit is contained in:
@@ -2807,11 +2807,11 @@ void VerilatedContext::threads(unsigned n) {
|
||||
|
||||
if (m_threads == n) return; // To avoid unnecessary warnings
|
||||
m_threads = n;
|
||||
const unsigned hardwareThreadsAvailable = std::thread::hardware_concurrency();
|
||||
if (m_threads > hardwareThreadsAvailable) {
|
||||
VL_PRINTF_MT("%%Warning: System has %u hardware threads but simulation thread count set "
|
||||
"to %u. This will likely cause significant slowdown.\n",
|
||||
hardwareThreadsAvailable, m_threads);
|
||||
const unsigned threadsAvailableToProcess = VlOs::getProcessDefaultParallelism();
|
||||
if (m_threads > threadsAvailableToProcess) {
|
||||
VL_PRINTF_MT("%%Warning: Process has %u hardware threads available, but simulation thread "
|
||||
"count set to %u. This will likely cause significant slowdown.\n",
|
||||
threadsAvailableToProcess, m_threads);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user