| 938 | } |
| 939 | |
| 940 | void callTestFunctions(test_definition testList[], |
| 941 | unsigned char selectedTestList[], |
| 942 | test_status resultTestList[], int testNum, |
| 943 | cl_device_id deviceToUse, |
| 944 | const test_harness_config &config) |
| 945 | { |
| 946 | // Execute tests serially |
| 947 | if (config.numWorkerThreads == 0) |
| 948 | { |
| 949 | for (int i = 0; i < testNum; ++i) |
| 950 | { |
| 951 | if (selectedTestList[i]) |
| 952 | { |
| 953 | resultTestList[i] = |
| 954 | callSingleTestFunction(testList[i], deviceToUse, config); |
| 955 | } |
| 956 | } |
| 957 | // Execute tests in parallel with the specified number of worker threads |
| 958 | } |
| 959 | else |
| 960 | { |
| 961 | // Queue all tests that need to run |
| 962 | for (int i = 0; i < testNum; ++i) |
| 963 | { |
| 964 | if (selectedTestList[i]) |
| 965 | { |
| 966 | gTestQueue.push_back(i); |
| 967 | } |
| 968 | } |
| 969 | |
| 970 | // Spawn thread pool |
| 971 | std::vector<std::thread *> threads; |
| 972 | test_harness_state state = { testList, resultTestList, deviceToUse, |
| 973 | config }; |
| 974 | for (unsigned i = 0; i < config.numWorkerThreads; i++) |
| 975 | { |
| 976 | log_info("Spawning worker thread %u\n", i); |
| 977 | threads.push_back(new std::thread(test_function_runner, &state)); |
| 978 | } |
| 979 | |
| 980 | // Wait for all threads to complete |
| 981 | for (auto th : threads) |
| 982 | { |
| 983 | th->join(); |
| 984 | } |
| 985 | assert(gTestQueue.size() == 0); |
| 986 | } |
| 987 | } |
| 988 | |
| 989 | void CL_CALLBACK notify_callback(const char *errinfo, const void *private_info, |
| 990 | size_t cb, void *user_data) |
no test coverage detected