Add basic support to the harness for parallel test execution (#1687)

This change introduces a new command-line parameter to enable
parallel execution by a specified number of worker threads. When
parallel execution is requested, tests are distributed across
the worker threads. This behaviour is disabled by default.

This does not currently work for all suites as some of them are
using global variables to configure tests. For the suites that
do not use global state, this change reduced the execution time
by up to 5x on an 8-core machine.

Signed-off-by: Kévin Petit <kpet@free.fr>
This commit is contained in:
Kévin Petit
2023-04-25 19:30:42 +01:00
committed by GitHub
parent 033aa195c5
commit ff1369d94e
6 changed files with 168 additions and 46 deletions

View File

@@ -85,6 +85,14 @@ typedef enum test_status
TEST_SKIPPED_ITSELF = -100,
} test_status;
struct test_harness_config
{
int forceNoContextCreation;
int numElementsToUse;
cl_command_queue_properties queueProps;
unsigned numWorkerThreads;
};
extern int gFailCount;
extern int gTestCount;
extern cl_uint gReSeed;
@@ -117,9 +125,7 @@ extern int runTestHarnessWithCheck(int argc, const char *argv[], int testNum,
extern int parseAndCallCommandLineTests(int argc, const char *argv[],
cl_device_id device, int testNum,
test_definition testList[],
int forceNoContextCreation,
cl_command_queue_properties queueProps,
int num_elements);
const test_harness_config &config);
// Call this function if you need to do all the setup work yourself, and just
// need the function list called/ managed.
@@ -131,21 +137,19 @@ extern int parseAndCallCommandLineTests(int argc, const char *argv[],
// resultTestList is an array of statuses which contain the result of each
// selected test testNum is the number of tests in testList, selectedTestList
// and resultTestList contextProps are used to create a testing context for
// each test deviceToUse and numElementsToUse are all just passed to each
// each test deviceToUse and config are all just passed to each
// test function
extern void callTestFunctions(test_definition testList[],
unsigned char selectedTestList[],
test_status resultTestList[], int testNum,
cl_device_id deviceToUse,
int forceNoContextCreation, int numElementsToUse,
cl_command_queue_properties queueProps);
const test_harness_config &config);
// This function is called by callTestFunctions, once per function, to do setup,
// call, logging and cleanup
extern test_status
callSingleTestFunction(test_definition test, cl_device_id deviceToUse,
int forceNoContextCreation, int numElementsToUse,
cl_command_queue_properties queueProps);
extern test_status callSingleTestFunction(test_definition test,
cl_device_id deviceToUse,
const test_harness_config &config);
///// Miscellaneous steps