99#include < thread>
1010
1111namespace test ::config {
12+ inline unsigned baseline_concurrency () {
13+ return std::max (std::thread::hardware_concurrency (), 2u );
14+ }
15+
1216 struct prelim {
1317#if defined(ENABLE_MEMORY_PROFILING)
1418 const int prelim_test_iters { 2 };
@@ -23,19 +27,19 @@ namespace test::config {
2327 };
2428
2529 struct mpsc : public prelim {
26- const unsigned cores ;
30+ const unsigned concurrency ;
2731 const config_set set_a;
2832 const config_set set_b;
2933 const config_set set_c;
3034 const config_set set_d;
3135
3236 mpsc ()
3337 : prelim {},
34- cores { std::thread::hardware_concurrency () },
38+ concurrency { baseline_concurrency () },
3539 set_a { 1 , 1 },
36- set_b { std::max (1u , cores - 1 ), 1 },
37- set_c { cores , 1 },
38- set_d { cores << 1 , 1 } {}
40+ set_b { std::max (1u , concurrency - 1 ), 1 },
41+ set_c { concurrency , 1 },
42+ set_d { concurrency << 1 , 1 } {}
3943
4044 mpsc (const mpsc &) = delete ;
4145 mpsc (mpsc &&) = delete ;
@@ -46,19 +50,19 @@ namespace test::config {
4650 };
4751
4852 struct mpmc : public prelim {
49- const unsigned cores ;
53+ const unsigned concurrency ;
5054 const config_set set_a;
5155 const config_set set_b;
5256 const config_set set_c;
5357 const config_set set_d;
5458
5559 mpmc ()
5660 : prelim {},
57- cores { std::thread::hardware_concurrency () },
58- set_a { proportion (cores, cores >> 1 ) },
59- set_b { proportion (cores , static_cast <unsigned >(static_cast <double >(cores ) / 3.0 * 2.0 )) },
60- set_c { same (cores ) },
61- set_d { same (cores << 1 ) } {}
61+ concurrency { baseline_concurrency () },
62+ set_a { proportion (concurrency, concurrency >> 1 ) },
63+ set_b { proportion (concurrency , static_cast <unsigned >(static_cast <double >(concurrency ) / 3.0 * 2.0 )) },
64+ set_c { same (concurrency ) },
65+ set_d { same (concurrency << 1 ) } {}
6266
6367 mpmc (const mpmc &) = delete ;
6468 mpmc (mpmc &&) = delete ;
0 commit comments