diff --git a/CMakeLists.txt b/CMakeLists.txt index 6fed6e6b..2b213663 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,7 @@ include(${BRANCH_TYPE}/CustomConfig.cmake OPTIONAL) if (MSVC) add_compile_options($<$:/MP>) set(CMAKE_CXX_STANDARD_LIBRARIES "delayimp.lib") + set(CMAKE_CXX_STANDARD_LIBRARIES "winmm.lib") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:OpenCL.dll") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:ze_loader.dll") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ignore:4199") diff --git a/source/benchmarks/ulls_benchmark/implementations/l0/kernel_with_work_periodic_l0.cpp b/source/benchmarks/ulls_benchmark/implementations/l0/kernel_with_work_periodic_l0.cpp index 05656a43..ff35e426 100644 --- a/source/benchmarks/ulls_benchmark/implementations/l0/kernel_with_work_periodic_l0.cpp +++ b/source/benchmarks/ulls_benchmark/implementations/l0/kernel_with_work_periodic_l0.cpp @@ -9,12 +9,13 @@ #include "framework/test_case/register_test_case.h" #include "framework/utility/file_helper.h" #include "framework/utility/power_meter.h" +#include "framework/utility/sleep.h" #include "framework/utility/timer.h" #include "definitions/kernel_with_work_periodic.h" #include -#include + static TestResult run(const KernelWithWorkPeriodicArguments &arguments, Statistics &statistics) { MeasurementFields typeSelector(MeasurementUnit::Microseconds, MeasurementType::Cpu); @@ -72,11 +73,11 @@ static TestResult run(const KernelWithWorkPeriodicArguments &arguments, Statisti const auto submissionDelay = std::chrono::microseconds(arguments.timeBetweenSubmissions); for (auto i = 0u; i < arguments.iterations; ++i) { const auto sleepToTimeoutUllsController = std::chrono::microseconds(10000); - std::this_thread::sleep_for(sleepToTimeoutUllsController); + sleep(sleepToTimeoutUllsController); Timer::Clock::duration executionTime(0); ASSERT_ZE_RESULT_SUCCESS(powerMeter.measureStart()); for (auto numKernel = 0u; numKernel < arguments.numSubmissions; ++numKernel) { - std::this_thread::sleep_for(submissionDelay); + sleep(submissionDelay); timer.measureStart(); ASSERT_ZE_RESULT_SUCCESS(zeCommandQueueExecuteCommandLists(levelzero.commandQueue, 1, &cmdList, nullptr)); ASSERT_ZE_RESULT_SUCCESS(zeCommandQueueSynchronize(levelzero.commandQueue, std::numeric_limits::max())); diff --git a/source/benchmarks/ulls_benchmark/implementations/ocl/queue_concurrency_ocl.cpp b/source/benchmarks/ulls_benchmark/implementations/ocl/queue_concurrency_ocl.cpp index 7f8392c7..6afa6f34 100644 --- a/source/benchmarks/ulls_benchmark/implementations/ocl/queue_concurrency_ocl.cpp +++ b/source/benchmarks/ulls_benchmark/implementations/ocl/queue_concurrency_ocl.cpp @@ -9,13 +9,13 @@ #include "framework/ocl/utility/queue_families_helper.h" #include "framework/test_case/register_test_case.h" #include "framework/utility/file_helper.h" +#include "framework/utility/sleep.h" #include "framework/utility/timer.h" #include "definitions/queue_concurrency.h" #include #include -#include static TestResult run(const QueueConcurrencyArguments &arguments, Statistics &statistics) { MeasurementFields typeSelector(MeasurementUnit::Microseconds, MeasurementType::Cpu); diff --git a/source/benchmarks/ulls_benchmark/implementations/ocl/queue_priorities_ocl.cpp b/source/benchmarks/ulls_benchmark/implementations/ocl/queue_priorities_ocl.cpp index bb31bfb7..df62fec0 100644 --- a/source/benchmarks/ulls_benchmark/implementations/ocl/queue_priorities_ocl.cpp +++ b/source/benchmarks/ulls_benchmark/implementations/ocl/queue_priorities_ocl.cpp @@ -102,7 +102,7 @@ static TestResult run(const QueuePrioritiesArguments &arguments, Statistics &sta ASSERT_CL_SUCCESS(clEnqueueNDRangeKernel(highPriorityQueue, highPriorityKernel, 1, nullptr, &gws, &lws, 0, nullptr, nullptr)); ASSERT_CL_SUCCESS(clFinish(highPriorityQueue)); ASSERT_CL_SUCCESS(retVal); - std::this_thread::sleep_for(std::chrono::milliseconds(arguments.sleepTime)); + sleep(std::chrono::milliseconds(arguments.sleepTime)); // benchmark size_t gwsLowPriority = 64 * 1024 * 1024; @@ -112,7 +112,7 @@ static TestResult run(const QueuePrioritiesArguments &arguments, Statistics &sta ASSERT_CL_SUCCESS(clEnqueueNDRangeKernel(lowPriorityQueue, lowPriorityKernel, 1, nullptr, &gwsLowPriority, &lws, 0, nullptr, nullptr)); ASSERT_CL_SUCCESS(clFlush(lowPriorityQueue)); - std::this_thread::sleep_for(std::chrono::milliseconds(arguments.sleepTime)); + sleep(std::chrono::milliseconds(arguments.sleepTime)); // now submit high priority kernel timer.measureStart(); @@ -122,7 +122,7 @@ static TestResult run(const QueuePrioritiesArguments &arguments, Statistics &sta ASSERT_CL_SUCCESS(retVal); statistics.pushValue(timer.get(), typeSelector.getUnit(), typeSelector.getType()); ASSERT_CL_SUCCESS(clFinish(lowPriorityQueue)); - std::this_thread::sleep_for(std::chrono::milliseconds(arguments.sleepTime)); + sleep(std::chrono::milliseconds(arguments.sleepTime)); } // Cleanup diff --git a/source/framework/test_case/test_case.h b/source/framework/test_case/test_case.h index fc91bb55..6ac5d281 100644 --- a/source/framework/test_case/test_case.h +++ b/source/framework/test_case/test_case.h @@ -15,6 +15,7 @@ #include "framework/test_map.h" #include "framework/utility/common_help_message.h" #include "framework/utility/error.h" +#include "framework/utility/sleep.h" #include "framework/utility/string_utils.h" #include @@ -100,7 +101,7 @@ class TestCase : public TestCaseBase { DEVELOPER_WARNING_IF(!statistics.isFull(), "test did not generate as many values as expected"); statistics.printStatistics(testCaseNameWithConfig); if (Configuration::get().sleepFor > 0) { - std::this_thread::sleep_for(std::chrono::milliseconds(Configuration::get().sleepFor)); + sleep(std::chrono::milliseconds(Configuration::get().sleepFor)); } } else if (testResult == TestResult::Nooped) { statistics.printStatistics(testCaseNameWithConfig); diff --git a/source/framework/utility/linux/sleep_linux.h b/source/framework/utility/linux/sleep_linux.h new file mode 100644 index 00000000..a046f975 --- /dev/null +++ b/source/framework/utility/linux/sleep_linux.h @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once + +#include + +template +void sleep(const Duration &duration) { + std::this_thread::sleep_for(duration); +} + diff --git a/source/framework/utility/sleep.h b/source/framework/utility/sleep.h new file mode 100644 index 00000000..12b3d6ed --- /dev/null +++ b/source/framework/utility/sleep.h @@ -0,0 +1,13 @@ +/* + * Copyright (C) 2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#ifdef WIN32 +#include "framework/utility/windows/sleep_windows.h" +#else // !WIN32 +#include "framework/utility/linux/sleep_linux.h" +#endif // !WIN32 + diff --git a/source/framework/utility/windows/sleep_windows.h b/source/framework/utility/windows/sleep_windows.h new file mode 100644 index 00000000..8fbec32e --- /dev/null +++ b/source/framework/utility/windows/sleep_windows.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once + +#define NOMINMAX +#include + +#include +#include + +template +void sleep(const Duration &duration) { + timeBeginPeriod(1u); + std::this_thread::sleep_for(duration); + timeEndPeriod(1u); +}