diff --git a/level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics.cpp b/level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics.cpp index b894881882..388558f81d 100644 --- a/level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics.cpp +++ b/level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics.cpp @@ -84,15 +84,9 @@ bool SingleDeviceTestRunner::run() { executionCtxt->run(); } - EXPECT(status == true); - for (auto collector : collectorList) { - status &= collector->isDataAvailable(); - LOG(zmu::LogLevel::DEBUG) << "Data Available : " << std::boolalpha << status << std::endl; - } - EXPECT(status == true); for (auto workload : workloadList) { - status &= workload->validate(); + workload->validate(); } EXPECT(status == true); @@ -100,6 +94,16 @@ bool SingleDeviceTestRunner::run() { collector->showResults(); } + EXPECT(status == true); + for (auto collector : collectorList) { + auto status = collector->isDataAvailable(); + if (!status) { + LOG(zmu::LogLevel::INFO) << "[W]Event was not generated !!" << std::endl; + } else { + LOG(zmu::LogLevel::DEBUG) << "Data Available : " << std::boolalpha << status << std::endl; + } + } + for (auto collector : collectorList) { status &= collector->stop(); } diff --git a/level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics.h b/level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics.h index e97ace9ae8..4ea8854ca8 100644 --- a/level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics.h +++ b/level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics.h @@ -115,6 +115,7 @@ class SingleDeviceSingleQueueExecutionCtxt : public ExecutionContext { SingleDeviceSingleQueueExecutionCtxt(uint32_t deviceIndex, int32_t subDeviceIndex = -1) { initialize(deviceIndex, subDeviceIndex); } ~SingleDeviceSingleQueueExecutionCtxt() override { finalize(); } bool run() override; + void reset(); ze_driver_handle_t getDriverHandle(uint32_t index) override { return driverHandle; } ze_context_handle_t getContextHandle(uint32_t index) override { return contextHandle; } @@ -170,7 +171,7 @@ class AppendMemoryCopyFromHeapToDeviceAndBackToHost : public Workload { void finalize(); private: - static constexpr size_t allocSize = 4096 + 7; // +7 to break alignment and make it harder + static constexpr size_t allocSize = 4096; char *heapBuffer1 = nullptr; char *heapBuffer2 = nullptr; void *zeBuffer = nullptr; @@ -224,6 +225,8 @@ class SingleMetricStreamerCollector : public SingleMetricCollector { public: SingleMetricStreamerCollector(ExecutionContext *executionCtxt, const char *metricGroupName); + SingleMetricStreamerCollector(ExecutionContext *executionCtxt, + zet_metric_group_handle_t metricGroup); ~SingleMetricStreamerCollector() override = default; @@ -244,8 +247,8 @@ class SingleMetricStreamerCollector : public SingleMetricCollector { zet_metric_streamer_handle_t metricStreamer = {}; ze_event_pool_handle_t eventPool = {}; ze_event_handle_t notificationEvent = {}; - uint32_t notifyReportCount = 1; - uint32_t samplingPeriod = 10000; + uint32_t notifyReportCount = 20000; + uint32_t samplingPeriod = 10000000; uint32_t maxRequestRawReportCount = 5; }; @@ -254,6 +257,8 @@ class SingleMetricQueryCollector : public SingleMetricCollector { public: SingleMetricQueryCollector(ExecutionContext *executionCtxt, const char *metricGroupName); + SingleMetricQueryCollector(ExecutionContext *executionCtxt, + zet_metric_group_handle_t metricGroup); ~SingleMetricQueryCollector() override = default; diff --git a/level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics_collector.cpp b/level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics_collector.cpp index c2963bc6eb..074eb87576 100644 --- a/level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics_collector.cpp +++ b/level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics_collector.cpp @@ -44,6 +44,13 @@ SingleMetricStreamerCollector::SingleMetricStreamerCollector(ExecutionContext *e executionCtxt->addActiveMetricGroup(metricGroup); } +SingleMetricStreamerCollector::SingleMetricStreamerCollector(ExecutionContext *executionCtxt, + zet_metric_group_handle_t metricGroup) : SingleMetricCollector(executionCtxt, metricGroup, + ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_TIME_BASED) { + + executionCtxt->addActiveMetricGroup(metricGroup); +} + bool SingleMetricStreamerCollector::start() { eventPool = zmu::createHostVisibleEventPool(executionCtxt->getContextHandle(0), executionCtxt->getDeviceHandle(0)); @@ -59,7 +66,7 @@ bool SingleMetricStreamerCollector::start() { notificationEvent, &metricStreamer)); // Initial pause - std::this_thread::sleep_for(std::chrono::milliseconds(100)); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); return true; } @@ -80,6 +87,7 @@ bool SingleMetricStreamerCollector::suffixCommands() { } bool SingleMetricStreamerCollector::isDataAvailable() { + auto eventStatus = zeEventQueryStatus(notificationEvent); zeEventHostReset(notificationEvent); return eventStatus == ZE_RESULT_SUCCESS; @@ -100,6 +108,11 @@ void SingleMetricStreamerCollector::showResults() { VALIDATECALL(zetMetricStreamerReadData(metricStreamer, maxRawReportCount, &rawDataSize, rawData.data())); LOG(zmu::LogLevel::DEBUG) << "Streamer read raw bytes: " << rawDataSize << std::endl; + if (rawDataSize == 0) { + rawDataSize = (uint32_t)rawData.size(); + VALIDATECALL(zetMetricStreamerReadData(metricStreamer, maxRawReportCount, &rawDataSize, rawData.data())); + LOG(zmu::LogLevel::DEBUG) << "Streamer read raw bytes: " << rawDataSize << std::endl; + } zmu::obtainCalculatedMetrics(metricGroup, rawData.data(), static_cast(rawDataSize)); } @@ -113,6 +126,12 @@ SingleMetricQueryCollector::SingleMetricQueryCollector(ExecutionContext *executi executionCtxt->addActiveMetricGroup(metricGroup); } +SingleMetricQueryCollector::SingleMetricQueryCollector(ExecutionContext *executionCtxt, + zet_metric_group_handle_t metricGroup) : SingleMetricCollector(executionCtxt, metricGroup, + ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_EVENT_BASED) { + executionCtxt->addActiveMetricGroup(metricGroup); +} + bool SingleMetricQueryCollector::start() { eventPool = zmu::createHostVisibleEventPool(executionCtxt->getContextHandle(0), executionCtxt->getDeviceHandle(0)); diff --git a/level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics_execution_context.cpp b/level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics_execution_context.cpp index 47535e2fc3..f9cce0f501 100644 --- a/level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics_execution_context.cpp +++ b/level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics_execution_context.cpp @@ -90,6 +90,10 @@ bool SingleDeviceSingleQueueExecutionCtxt::finalize() { return true; } +void SingleDeviceSingleQueueExecutionCtxt::reset() { + VALIDATECALL(zeCommandListReset(commandList)); +} + bool SingleDeviceSingleQueueExecutionCtxt::run() { // Close command list. diff --git a/level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics_workload.cpp b/level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics_workload.cpp index a4bdeecac0..1cea93c7ca 100644 --- a/level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics_workload.cpp +++ b/level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics_workload.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Intel Corporation + * Copyright (C) 2022-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -30,7 +30,8 @@ void AppendMemoryCopyFromHeapToDeviceAndBackToHost::initialize() { deviceDesc.flags = 0; deviceDesc.pNext = nullptr; - VALIDATECALL(zeMemAllocDevice(executionCtxt->getContextHandle(0), &deviceDesc, allocSize, allocSize, executionCtxt->getDeviceHandle(0), &zeBuffer)); + VALIDATECALL(zeMemAllocDevice(executionCtxt->getContextHandle(0), &deviceDesc, allocSize, 1, executionCtxt->getDeviceHandle(0), &zeBuffer)); + VALIDATECALL(zeContextMakeMemoryResident(executionCtxt->getContextHandle(0), executionCtxt->getDeviceHandle(0), zeBuffer, allocSize)); } bool AppendMemoryCopyFromHeapToDeviceAndBackToHost::appendCommands() { @@ -42,11 +43,13 @@ bool AppendMemoryCopyFromHeapToDeviceAndBackToHost::appendCommands() { // Copy from heap to device-allocated memory VALIDATECALL(zeCommandListAppendMemoryCopy(executionCtxt->getCommandList(0), zeBuffer, heapBuffer1, allocSize, nullptr, 0, nullptr)); + VALIDATECALL(zeCommandListAppendBarrier(executionCtxt->getCommandList(0), nullptr, 0, nullptr)); // Copy from device-allocated memory to heap2 VALIDATECALL(zeCommandListAppendMemoryCopy(executionCtxt->getCommandList(0), heapBuffer2, zeBuffer, allocSize, nullptr, 0, nullptr)); } + return true; } @@ -57,6 +60,7 @@ bool AppendMemoryCopyFromHeapToDeviceAndBackToHost::validate() { void AppendMemoryCopyFromHeapToDeviceAndBackToHost::finalize() { + VALIDATECALL(zeContextEvictMemory(executionCtxt->getContextHandle(0), executionCtxt->getDeviceHandle(0), zeBuffer, allocSize)); VALIDATECALL(zeMemFree(executionCtxt->getContextHandle(0), zeBuffer)); delete[] heapBuffer1; delete[] heapBuffer2; @@ -156,7 +160,6 @@ bool CopyBufferToBuffer::appendCommands() { } bool CopyBufferToBuffer::validate() { - // Validate. const bool outputValidationSuccessful = (memcmp(destinationBuffer, sourceBuffer, allocationSize) == 0);