Skip to content

Commit

Permalink
add option to bruteforce test to force count of worker threads
Browse files Browse the repository at this point in the history
- 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
  functianality

Signed-off-by: Katarzyna Cencelewska <[email protected]>
  • Loading branch information
kcencele committed Dec 13, 2024
1 parent 5b7af4b commit 662ad9e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion test_conformance/math_brute_force/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -540,7 +546,17 @@ static int ParseArgs(int argc, const char **argv)
gWimpyReductionFactor);
}

if (singleThreaded) SetThreadCount(1);
if (singleThreaded)
{
vlog("*** WARNING: Reduce worker threads to 1 ***\n");
SetThreadCount(1);
}
else if (forcedWorkerThreads > 0)
{
vlog("*** WARNING: Reduce worker threads to %d ***\n",
forcedWorkerThreads);
SetThreadCount(forcedWorkerThreads);
}

return 0;
}
Expand Down

0 comments on commit 662ad9e

Please sign in to comment.