mirror of
https://github.com/YosysHQ/yosys
synced 2025-12-18 18:28:35 +00:00
Merge pull request #5516 from rocallahan/limit-threads
Limit thread usage in tests
This commit is contained in:
commit
e08e9119ee
29 changed files with 46 additions and 5 deletions
|
|
@ -3,6 +3,20 @@
|
||||||
|
|
||||||
YOSYS_NAMESPACE_BEGIN
|
YOSYS_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
static int init_max_threads()
|
||||||
|
{
|
||||||
|
const char *v = getenv("YOSYS_MAX_THREADS");
|
||||||
|
if (v == nullptr)
|
||||||
|
return INT32_MAX;
|
||||||
|
return atoi(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int get_max_threads()
|
||||||
|
{
|
||||||
|
static int max_threads = init_max_threads();
|
||||||
|
return max_threads;
|
||||||
|
}
|
||||||
|
|
||||||
void DeferredLogs::flush()
|
void DeferredLogs::flush()
|
||||||
{
|
{
|
||||||
for (auto &m : logs)
|
for (auto &m : logs)
|
||||||
|
|
@ -12,10 +26,11 @@ void DeferredLogs::flush()
|
||||||
YOSYS_NAMESPACE_PREFIX log("%s", m.text.c_str());
|
YOSYS_NAMESPACE_PREFIX log("%s", m.text.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
int ThreadPool::pool_size(int reserved_cores, int max_threads)
|
int ThreadPool::pool_size(int reserved_cores, int max_worker_threads)
|
||||||
{
|
{
|
||||||
#ifdef YOSYS_ENABLE_THREADS
|
#ifdef YOSYS_ENABLE_THREADS
|
||||||
int num_threads = std::min<int>(std::thread::hardware_concurrency() - reserved_cores, max_threads);
|
int available_threads = std::min<int>(std::thread::hardware_concurrency(), get_max_threads());
|
||||||
|
int num_threads = std::min(available_threads - reserved_cores, max_worker_threads);
|
||||||
return std::max(0, num_threads);
|
return std::max(0, num_threads);
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -127,9 +127,9 @@ class ThreadPool
|
||||||
public:
|
public:
|
||||||
// Computes the number of worker threads to use.
|
// Computes the number of worker threads to use.
|
||||||
// `reserved_cores` cores are set aside for other threads (e.g. work on the main thread).
|
// `reserved_cores` cores are set aside for other threads (e.g. work on the main thread).
|
||||||
// `max_threads` --- don't return more workers than this.
|
// `max_worker_threads` --- don't return more workers than this.
|
||||||
// The result may be 0.
|
// The result may be 0.
|
||||||
static int pool_size(int reserved_cores, int max_threads);
|
static int pool_size(int reserved_cores, int max_worker_threads);
|
||||||
|
|
||||||
// Create a pool of threads running the given closure (parameterized by thread number).
|
// Create a pool of threads running the given closure (parameterized by thread number).
|
||||||
// `pool_size` must be the result of a `pool_size()` call.
|
// `pool_size` must be the result of a `pool_size()` call.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ../common-env.sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ../common-env.sh
|
||||||
set -e
|
set -e
|
||||||
for x in *.ys; do
|
for x in *.ys; do
|
||||||
echo "Running $x.."
|
echo "Running $x.."
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ../common-env.sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ../common-env.sh
|
||||||
|
|
||||||
OPTIND=1
|
OPTIND=1
|
||||||
seed="" # default to no seed specified
|
seed="" # default to no seed specified
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ../common-env.sh
|
||||||
set -e
|
set -e
|
||||||
for x in *.ys; do
|
for x in *.ys; do
|
||||||
echo "Running $x.."
|
echo "Running $x.."
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ../common-env.sh
|
||||||
|
|
||||||
# run this test many times:
|
# run this test many times:
|
||||||
# MAKE="make -j8" time bash -c 'for ((i=0; i<100; i++)); do echo "-- $i --"; bash run-test.sh || exit 1; done'
|
# MAKE="make -j8" time bash -c 'for ((i=0; i<100; i++)); do echo "-- $i --"; bash run-test.sh || exit 1; done'
|
||||||
|
|
|
||||||
1
tests/common-env.sh
Normal file
1
tests/common-env.sh
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
export YOSYS_MAX_THREADS=4
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
source ../common-env.sh
|
||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ../common-env.sh
|
||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ../common-env.sh
|
||||||
|
|
||||||
# run this test many times:
|
# run this test many times:
|
||||||
# time bash -c 'for ((i=0; i<100; i++)); do echo "-- $i --"; bash run-test.sh || exit 1; done'
|
# time bash -c 'for ((i=0; i<100; i++)); do echo "-- $i --"; bash run-test.sh || exit 1; done'
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ../common-env.sh
|
||||||
|
|
||||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ generate_target() {
|
||||||
echo "all: $target_name"
|
echo "all: $target_name"
|
||||||
echo ".PHONY: $target_name"
|
echo ".PHONY: $target_name"
|
||||||
echo "$target_name:"
|
echo "$target_name:"
|
||||||
printf "\t@%s\n" "$test_command"
|
printf "\t@YOSYS_MAX_THREADS=4 %s\n" "$test_command"
|
||||||
printf "\t@echo 'Passed %s'\n" "$target_name"
|
printf "\t@echo 'Passed %s'\n" "$target_name"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ../common-env.sh
|
||||||
|
|
||||||
OPTIND=1
|
OPTIND=1
|
||||||
seed="" # default to no seed specified
|
seed="" # default to no seed specified
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ../common-env.sh
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
for x in *.lib; do
|
for x in *.lib; do
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ../common-env.sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ../common-env.sh
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
OPTIND=1
|
OPTIND=1
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ../common-env.sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ../common-env.sh
|
||||||
|
|
||||||
# run this test many times:
|
# run this test many times:
|
||||||
# time bash -c 'for ((i=0; i<100; i++)); do echo "-- $i --"; bash run-test.sh || exit 1; done'
|
# time bash -c 'for ((i=0; i<100; i++)); do echo "-- $i --"; bash run-test.sh || exit 1; done'
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ../common-env.sh
|
||||||
set -e
|
set -e
|
||||||
for x in *.ys; do
|
for x in *.ys; do
|
||||||
echo "Running $x.."
|
echo "Running $x.."
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ../common-env.sh
|
||||||
set -e
|
set -e
|
||||||
for x in *.ys; do
|
for x in *.ys; do
|
||||||
echo "Running $x.."
|
echo "Running $x.."
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ../common-env.sh
|
||||||
set -e
|
set -e
|
||||||
for x in *.ys; do
|
for x in *.ys; do
|
||||||
echo "Running $x.."
|
echo "Running $x.."
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ../common-env.sh
|
||||||
set -e
|
set -e
|
||||||
for x in *.ys; do
|
for x in *.ys; do
|
||||||
echo "Running $x.."
|
echo "Running $x.."
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ../common-env.sh
|
||||||
|
|
||||||
# run this test many times:
|
# run this test many times:
|
||||||
# time bash -c 'for ((i=0; i<100; i++)); do echo "-- $i --"; bash run-test.sh || exit 1; done'
|
# time bash -c 'for ((i=0; i<100; i++)); do echo "-- $i --"; bash run-test.sh || exit 1; done'
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ../common-env.sh
|
||||||
|
|
||||||
OPTIND=1
|
OPTIND=1
|
||||||
seed="" # default to no seed specified
|
seed="" # default to no seed specified
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ../common-env.sh
|
||||||
|
|
||||||
OPTIND=1
|
OPTIND=1
|
||||||
seed="" # default to no seed specified
|
seed="" # default to no seed specified
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#/bin/bash -e
|
#/bin/bash -e
|
||||||
|
source ../common-env.sh
|
||||||
|
|
||||||
./runone.sh svinterface1
|
./runone.sh svinterface1
|
||||||
./runone.sh svinterface_at_top
|
./runone.sh svinterface_at_top
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ../common-env.sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
python3 generate.py $@
|
python3 generate.py $@
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue