From e17e6eef7b43f4edad95769fbb45e2a4a897aa0d Mon Sep 17 00:00:00 2001 From: Katarzyna Cencelewska Date: Tue, 17 Dec 2024 18:58:03 +0100 Subject: [PATCH] add option to bruteforce test to force count of worker threads (#2188) - to be able to have deterministic results it is useful to have a mechanism to force the same count of workers - this commit doesn't change the default settings but expands functionality Signed-off-by: Katarzyna Cencelewska Signed-off-by: Katarzyna Cencelewska --- test_conformance/math_brute_force/main.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test_conformance/math_brute_force/main.cpp b/test_conformance/math_brute_force/main.cpp index ec504e60..38954f3f 100644 --- a/test_conformance/math_brute_force/main.cpp +++ b/test_conformance/math_brute_force/main.cpp @@ -379,6 +379,7 @@ static int ParseArgs(int argc, const char **argv) gTestNames.push_back(""); int singleThreaded = 0; + int forcedWorkerThreads = 0; { // Extract the app name strncpy(appName, argv[0], MAXPATHLEN - 1); @@ -430,6 +431,11 @@ static int ParseArgs(int argc, const char **argv) case 'm': singleThreaded ^= 1; break; + case 't': + forcedWorkerThreads = atoi(argv[++i]); + vlog(" %d", forcedWorkerThreads); + break; + case 'g': gHasHalf ^= 1; break; case 'r': gTestFastRelaxed ^= 1; break; @@ -540,7 +546,17 @@ static int ParseArgs(int argc, const char **argv) gWimpyReductionFactor); } - if (singleThreaded) SetThreadCount(1); + if (singleThreaded) + { + vlog("*** WARNING: Force 1 worker thread ***\n"); + SetThreadCount(1); + } + else if (forcedWorkerThreads > 0) + { + vlog("*** WARNING: Force %d worker threads ***\n", + forcedWorkerThreads); + SetThreadCount(forcedWorkerThreads); + } return 0; }