Improve zello Metrics
1. Added command line handling 1.1 Replaced device/sub-device specific test with single test with input argument 2. Added verbose levels 3. Added support to run all tests sequentially 4. Replace zetMetricGroupCalculateMetricValues with zetMetricGroupCalculateMetricValuesExp Related-To: LOCI-3078 Signed-off-by: Joshua Santosh Ranjan <joshua.santosh.ranjan@intel.com>
This commit is contained in:
parent
d935815d74
commit
a38a3ce730
File diff suppressed because it is too large
Load Diff
|
@ -147,9 +147,6 @@ class CopyBufferToBuffer : public Workload {
|
||||||
|
|
||||||
class SingleMetricCollector : public Collector {
|
class SingleMetricCollector : public Collector {
|
||||||
|
|
||||||
public:
|
|
||||||
void setVerboseLevel(uint32_t level) { verboseLevel = level; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SingleMetricCollector(ExecutionContext *executionCtxt,
|
SingleMetricCollector(ExecutionContext *executionCtxt,
|
||||||
const char *metricGroupName,
|
const char *metricGroupName,
|
||||||
|
@ -165,8 +162,6 @@ class SingleMetricCollector : public Collector {
|
||||||
|
|
||||||
zet_metric_group_handle_t metricGroup = {};
|
zet_metric_group_handle_t metricGroup = {};
|
||||||
zet_metric_group_sampling_type_flag_t samplingType = {};
|
zet_metric_group_sampling_type_flag_t samplingType = {};
|
||||||
|
|
||||||
uint32_t verboseLevel = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SingleMetricStreamerCollector : public SingleMetricCollector {
|
class SingleMetricStreamerCollector : public SingleMetricCollector {
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace zmu = ZelloMetricsUtility;
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
/////SingleMetricCollector
|
/////SingleMetricCollector
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
|
@ -20,13 +22,13 @@ SingleMetricCollector::SingleMetricCollector(ExecutionContext *executionCtxt,
|
||||||
const zet_metric_group_sampling_type_flag_t samplingType)
|
const zet_metric_group_sampling_type_flag_t samplingType)
|
||||||
: Collector(executionCtxt), samplingType(samplingType) {
|
: Collector(executionCtxt), samplingType(samplingType) {
|
||||||
|
|
||||||
metricGroup = ZelloMetricsUtility::findMetricGroup(metricGroupName, samplingType, executionCtxt->getDeviceHandle(0));
|
metricGroup = zmu::findMetricGroup(metricGroupName, samplingType, executionCtxt->getDeviceHandle(0));
|
||||||
|
|
||||||
if (verboseLevel >= 1) {
|
if (zmu::TestSettings::get()->verboseLevel >= zmu::LogLevel::DEBUG) {
|
||||||
zet_metric_group_properties_t metricGroupProperties = {};
|
zet_metric_group_properties_t metricGroupProperties = {};
|
||||||
// Obtain metric group properties to check the group name and sampling type.
|
// Obtain metric group properties to check the group name and sampling type.
|
||||||
VALIDATECALL(zetMetricGroupGetProperties(metricGroup, &metricGroupProperties));
|
VALIDATECALL(zetMetricGroupGetProperties(metricGroup, &metricGroupProperties));
|
||||||
ZelloMetricsUtility::printMetricGroupProperties(metricGroupProperties);
|
zmu::printMetricGroupProperties(metricGroupProperties);
|
||||||
|
|
||||||
// Print metrics from metric group.
|
// Print metrics from metric group.
|
||||||
uint32_t metricCount = 0;
|
uint32_t metricCount = 0;
|
||||||
|
@ -45,7 +47,7 @@ SingleMetricCollector::SingleMetricCollector(ExecutionContext *executionCtxt,
|
||||||
const zet_metric_handle_t metric = metrics[j];
|
const zet_metric_handle_t metric = metrics[j];
|
||||||
zet_metric_properties_t metricProperties = {};
|
zet_metric_properties_t metricProperties = {};
|
||||||
VALIDATECALL(zetMetricGetProperties(metric, &metricProperties));
|
VALIDATECALL(zetMetricGetProperties(metric, &metricProperties));
|
||||||
ZelloMetricsUtility::printMetricProperties(metricProperties);
|
zmu::printMetricProperties(metricProperties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,8 +64,8 @@ SingleMetricStreamerCollector::SingleMetricStreamerCollector(ExecutionContext *e
|
||||||
|
|
||||||
bool SingleMetricStreamerCollector::start() {
|
bool SingleMetricStreamerCollector::start() {
|
||||||
|
|
||||||
eventPool = ZelloMetricsUtility::createHostVisibleEventPool(executionCtxt->getContextHandle(0), executionCtxt->getDeviceHandle(0));
|
eventPool = zmu::createHostVisibleEventPool(executionCtxt->getContextHandle(0), executionCtxt->getDeviceHandle(0));
|
||||||
notificationEvent = ZelloMetricsUtility::createHostVisibleEvent(eventPool);
|
notificationEvent = zmu::createHostVisibleEvent(eventPool);
|
||||||
|
|
||||||
zet_metric_streamer_desc_t streamerProperties = {};
|
zet_metric_streamer_desc_t streamerProperties = {};
|
||||||
streamerProperties.notifyEveryNReports = notifyReportCount;
|
streamerProperties.notifyEveryNReports = notifyReportCount;
|
||||||
|
@ -107,14 +109,14 @@ void SingleMetricStreamerCollector::showResults() {
|
||||||
std::vector<uint8_t> rawData{};
|
std::vector<uint8_t> rawData{};
|
||||||
|
|
||||||
VALIDATECALL(zetMetricStreamerReadData(metricStreamer, maxRawReportCount, &rawDataSize, nullptr));
|
VALIDATECALL(zetMetricStreamerReadData(metricStreamer, maxRawReportCount, &rawDataSize, nullptr));
|
||||||
std::cout << "Streamer read requires: " << rawDataSize << " bytes buffer" << std::endl;
|
LOG(zmu::LogLevel::DEBUG) << "Streamer read requires: " << rawDataSize << " bytes buffer" << std::endl;
|
||||||
|
|
||||||
// Read raw data.
|
// Read raw data.
|
||||||
rawData.resize(rawDataSize, 0);
|
rawData.resize(rawDataSize, 0);
|
||||||
VALIDATECALL(zetMetricStreamerReadData(metricStreamer, maxRawReportCount, &rawDataSize, rawData.data()));
|
VALIDATECALL(zetMetricStreamerReadData(metricStreamer, maxRawReportCount, &rawDataSize, rawData.data()));
|
||||||
std::cout << "Streamer read raw bytes: " << rawDataSize << std::endl;
|
LOG(zmu::LogLevel::DEBUG) << "Streamer read raw bytes: " << rawDataSize << std::endl;
|
||||||
|
|
||||||
ZelloMetricsUtility::obtainCalculatedMetrics(metricGroup, rawData.data(), static_cast<uint32_t>(rawDataSize));
|
zmu::obtainCalculatedMetrics(metricGroup, rawData.data(), static_cast<uint32_t>(rawDataSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
@ -129,8 +131,8 @@ SingleMetricQueryCollector::SingleMetricQueryCollector(ExecutionContext *executi
|
||||||
|
|
||||||
bool SingleMetricQueryCollector::start() {
|
bool SingleMetricQueryCollector::start() {
|
||||||
|
|
||||||
eventPool = ZelloMetricsUtility::createHostVisibleEventPool(executionCtxt->getContextHandle(0), executionCtxt->getDeviceHandle(0));
|
eventPool = zmu::createHostVisibleEventPool(executionCtxt->getContextHandle(0), executionCtxt->getDeviceHandle(0));
|
||||||
notificationEvent = ZelloMetricsUtility::createHostVisibleEvent(eventPool);
|
notificationEvent = zmu::createHostVisibleEvent(eventPool);
|
||||||
queryPoolDesc.count = queryPoolCount;
|
queryPoolDesc.count = queryPoolCount;
|
||||||
queryPoolDesc.type = ZET_METRIC_QUERY_POOL_TYPE_PERFORMANCE;
|
queryPoolDesc.type = ZET_METRIC_QUERY_POOL_TYPE_PERFORMANCE;
|
||||||
|
|
||||||
|
@ -186,5 +188,5 @@ void SingleMetricQueryCollector::showResults() {
|
||||||
rawData.resize(rawDataSize);
|
rawData.resize(rawDataSize);
|
||||||
VALIDATECALL(zetMetricQueryGetData(queryHandle, &rawDataSize, rawData.data()));
|
VALIDATECALL(zetMetricQueryGetData(queryHandle, &rawDataSize, rawData.data()));
|
||||||
|
|
||||||
ZelloMetricsUtility::obtainCalculatedMetrics(metricGroup, rawData.data(), static_cast<uint32_t>(rawDataSize));
|
zmu::obtainCalculatedMetrics(metricGroup, rawData.data(), static_cast<uint32_t>(rawDataSize));
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace zmu = ZelloMetricsUtility;
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
/////ExecutionContext
|
/////ExecutionContext
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
|
@ -57,21 +59,21 @@ bool ExecutionContext::deactivateMetricGroups() {
|
||||||
//////////////////////////////////////////
|
//////////////////////////////////////////
|
||||||
bool SingleDeviceSingleQueueExecutionCtxt::initialize(uint32_t deviceIndex, int32_t subDeviceIndex) {
|
bool SingleDeviceSingleQueueExecutionCtxt::initialize(uint32_t deviceIndex, int32_t subDeviceIndex) {
|
||||||
|
|
||||||
ZelloMetricsUtility::createL0();
|
zmu::createL0();
|
||||||
driverHandle = ZelloMetricsUtility::getDriver();
|
driverHandle = zmu::getDriver();
|
||||||
EXPECT(driverHandle != nullptr);
|
EXPECT(driverHandle != nullptr);
|
||||||
contextHandle = ZelloMetricsUtility::createContext(driverHandle);
|
contextHandle = zmu::createContext(driverHandle);
|
||||||
EXPECT(contextHandle != nullptr);
|
EXPECT(contextHandle != nullptr);
|
||||||
|
|
||||||
deviceHandle = ZelloMetricsUtility::getDevice(driverHandle, deviceIndex);
|
deviceHandle = zmu::getDevice(driverHandle, deviceIndex);
|
||||||
EXPECT(deviceHandle != nullptr);
|
EXPECT(deviceHandle != nullptr);
|
||||||
if (subDeviceIndex != -1) {
|
if (subDeviceIndex != -1) {
|
||||||
deviceHandle = ZelloMetricsUtility::getSubDevice(deviceHandle, subDeviceIndex);
|
deviceHandle = zmu::getSubDevice(deviceHandle, subDeviceIndex);
|
||||||
EXPECT(deviceHandle != nullptr);
|
EXPECT(deviceHandle != nullptr);
|
||||||
}
|
}
|
||||||
commandQueue = ZelloMetricsUtility::createCommandQueue(contextHandle, deviceHandle);
|
commandQueue = zmu::createCommandQueue(contextHandle, deviceHandle);
|
||||||
EXPECT(commandQueue != nullptr);
|
EXPECT(commandQueue != nullptr);
|
||||||
commandList = ZelloMetricsUtility::createCommandList(contextHandle, deviceHandle);
|
commandList = zmu::createCommandList(contextHandle, deviceHandle);
|
||||||
EXPECT(commandList != nullptr);
|
EXPECT(commandList != nullptr);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +111,7 @@ bool SingleDeviceSingleQueueExecutionCtxt::run() {
|
||||||
runCount++;
|
runCount++;
|
||||||
} while (diff < executionTimeInMilliSeconds);
|
} while (diff < executionTimeInMilliSeconds);
|
||||||
|
|
||||||
std::cout << "CommandList Run count : " << runCount << "\n";
|
LOG(zmu::LogLevel::DEBUG) << "CommandList Run count : " << runCount << "\n";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics.h"
|
#include "level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <getopt.h>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
@ -19,7 +20,6 @@ namespace ZelloMetricsUtility {
|
||||||
/// createL0
|
/// createL0
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
void createL0() {
|
void createL0() {
|
||||||
|
|
||||||
VALIDATECALL(zeInit(ZE_INIT_FLAG_GPU_ONLY));
|
VALIDATECALL(zeInit(ZE_INIT_FLAG_GPU_ONLY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,9 +63,30 @@ bool getTestMachineConfiguration(TestMachineConfiguration &machineConfig) {
|
||||||
VALIDATECALL(zeDeviceGetSubDevices(devices[deviceId], &subDevicesCount, nullptr));
|
VALIDATECALL(zeDeviceGetSubDevices(devices[deviceId], &subDevicesCount, nullptr));
|
||||||
machineConfig.devices[deviceId].subDeviceCount = subDevicesCount;
|
machineConfig.devices[deviceId].subDeviceCount = subDevicesCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ze_device_properties_t deviceProperties;
|
||||||
|
VALIDATECALL(zeDeviceGetProperties(devices[0], &deviceProperties));
|
||||||
|
machineConfig.deviceId = deviceProperties.deviceId;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isDeviceAvailable(uint32_t deviceIndex, int32_t subDeviceIndex) {
|
||||||
|
bool checkStatus = false;
|
||||||
|
|
||||||
|
TestMachineConfiguration config;
|
||||||
|
getTestMachineConfiguration(config);
|
||||||
|
if (deviceIndex < config.deviceCount) {
|
||||||
|
if (subDeviceIndex < static_cast<int32_t>(config.devices[deviceIndex].subDeviceCount)) {
|
||||||
|
checkStatus = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkStatus == false) {
|
||||||
|
LOG(LogLevel::WARNING) << "Warning:: Unsupported Configuration: Device :" << deviceIndex << " Sub Device :" << subDeviceIndex << "\n";
|
||||||
|
}
|
||||||
|
return checkStatus;
|
||||||
|
}
|
||||||
|
|
||||||
ze_device_handle_t getDevice(ze_driver_handle_t &driverHandle, uint32_t deviceIndex) {
|
ze_device_handle_t getDevice(ze_driver_handle_t &driverHandle, uint32_t deviceIndex) {
|
||||||
|
|
||||||
uint32_t deviceCount = 0;
|
uint32_t deviceCount = 0;
|
||||||
|
@ -103,7 +124,7 @@ ze_command_queue_handle_t createCommandQueue(ze_context_handle_t &contextHandle,
|
||||||
VALIDATECALL(zeDeviceGetCommandQueueGroupProperties(deviceHandle, &queueGroupsCount, nullptr));
|
VALIDATECALL(zeDeviceGetCommandQueueGroupProperties(deviceHandle, &queueGroupsCount, nullptr));
|
||||||
|
|
||||||
if (queueGroupsCount == 0) {
|
if (queueGroupsCount == 0) {
|
||||||
std::cout << "No queue groups found!\n";
|
LOG(LogLevel::ERROR) << "No queue groups found!\n";
|
||||||
std::terminate();
|
std::terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,31 +169,31 @@ ze_command_list_handle_t createCommandList(ze_context_handle_t &contextHandle, z
|
||||||
}
|
}
|
||||||
|
|
||||||
void printMetricGroupProperties(const zet_metric_group_properties_t &properties) {
|
void printMetricGroupProperties(const zet_metric_group_properties_t &properties) {
|
||||||
std::cout << "METRIC GROUP: "
|
LOG(LogLevel::DEBUG) << "METRIC GROUP: "
|
||||||
<< "name: " << properties.name << ", "
|
<< "name: " << properties.name << ", "
|
||||||
<< "desc: " << properties.description << ", "
|
<< "desc: " << properties.description << ", "
|
||||||
<< "samplingType: " << properties.samplingType << ", "
|
<< "samplingType: " << properties.samplingType << ", "
|
||||||
<< "domain: " << properties.domain << ", "
|
<< "domain: " << properties.domain << ", "
|
||||||
<< "metricCount: " << properties.metricCount << std::endl;
|
<< "metricCount: " << properties.metricCount << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
/// printMetricProperties
|
/// printMetricProperties
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
void printMetricProperties(const zet_metric_properties_t &properties) {
|
void printMetricProperties(const zet_metric_properties_t &properties) {
|
||||||
std::cout << "\tMETRIC: "
|
LOG(LogLevel::DEBUG) << "\tMETRIC: "
|
||||||
<< "name: " << properties.name << ", "
|
<< "name: " << properties.name << ", "
|
||||||
<< "desc: " << properties.description << ", "
|
<< "desc: " << properties.description << ", "
|
||||||
<< "component: " << properties.component << ", "
|
<< "component: " << properties.component << ", "
|
||||||
<< "tier: " << properties.tierNumber << ", "
|
<< "tier: " << properties.tierNumber << ", "
|
||||||
<< "metricType: " << properties.metricType << ", "
|
<< "metricType: " << properties.metricType << ", "
|
||||||
<< "resultType: " << properties.resultType << ", "
|
<< "resultType: " << properties.resultType << ", "
|
||||||
<< "units: " << properties.resultUnits << std::endl;
|
<< "units: " << properties.resultUnits << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////
|
/////////
|
||||||
/// wait
|
/// wait
|
||||||
///////////////////////////
|
/////////
|
||||||
void sleep(uint32_t milliseconds) {
|
void sleep(uint32_t milliseconds) {
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
|
std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
|
||||||
}
|
}
|
||||||
|
@ -214,6 +235,8 @@ zet_metric_group_handle_t findMetricGroup(const char *groupName,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG(LogLevel::ERROR) << "Warning : Metric Group " << groupName << " with sampling type " << samplingType << " could not be found !\n";
|
||||||
|
|
||||||
// Unable to find metric group.
|
// Unable to find metric group.
|
||||||
VALIDATECALL(ZE_RESULT_ERROR_UNKNOWN);
|
VALIDATECALL(ZE_RESULT_ERROR_UNKNOWN);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -251,53 +274,26 @@ void obtainCalculatedMetrics(zet_metric_group_handle_t metricGroup, uint8_t *raw
|
||||||
std::vector<uint32_t> metricCounts = {};
|
std::vector<uint32_t> metricCounts = {};
|
||||||
std::vector<zet_typed_value_t> results = {};
|
std::vector<zet_typed_value_t> results = {};
|
||||||
std::vector<zet_metric_handle_t> metrics = {};
|
std::vector<zet_metric_handle_t> metrics = {};
|
||||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
|
||||||
|
|
||||||
// Obtain maximum space for calculated metrics.
|
// Try to use calculate for multiple metric values.
|
||||||
result = zetMetricGroupCalculateMetricValues(
|
VALIDATECALL(zetMetricGroupCalculateMultipleMetricValuesExp(
|
||||||
metricGroup,
|
metricGroup,
|
||||||
ZET_METRIC_GROUP_CALCULATION_TYPE_METRIC_VALUES,
|
ZET_METRIC_GROUP_CALCULATION_TYPE_METRIC_VALUES,
|
||||||
rawDataSize, rawData,
|
rawDataSize, rawData,
|
||||||
&totalCalculatedMetricCount,
|
&setCount, &totalCalculatedMetricCount,
|
||||||
nullptr);
|
nullptr, nullptr));
|
||||||
|
|
||||||
if (result == ZE_RESULT_ERROR_UNKNOWN) {
|
// Allocate space for calculated reports.
|
||||||
|
metricCounts.resize(setCount);
|
||||||
|
results.resize(totalCalculatedMetricCount);
|
||||||
|
|
||||||
// Try to use calculate for multiple metric values.
|
// Obtain calculated metrics and their count.
|
||||||
VALIDATECALL(zetMetricGroupCalculateMultipleMetricValuesExp(
|
VALIDATECALL(zetMetricGroupCalculateMultipleMetricValuesExp(
|
||||||
metricGroup,
|
metricGroup,
|
||||||
ZET_METRIC_GROUP_CALCULATION_TYPE_METRIC_VALUES,
|
ZET_METRIC_GROUP_CALCULATION_TYPE_METRIC_VALUES,
|
||||||
rawDataSize, rawData,
|
rawDataSize, rawData,
|
||||||
&setCount, &totalCalculatedMetricCount,
|
&setCount, &totalCalculatedMetricCount,
|
||||||
nullptr, nullptr));
|
metricCounts.data(), results.data()));
|
||||||
|
|
||||||
// Allocate space for calculated reports.
|
|
||||||
metricCounts.resize(setCount);
|
|
||||||
results.resize(totalCalculatedMetricCount);
|
|
||||||
|
|
||||||
// Obtain calculated metrics and their count.
|
|
||||||
VALIDATECALL(zetMetricGroupCalculateMultipleMetricValuesExp(
|
|
||||||
metricGroup,
|
|
||||||
ZET_METRIC_GROUP_CALCULATION_TYPE_METRIC_VALUES,
|
|
||||||
rawDataSize, rawData,
|
|
||||||
&setCount, &totalCalculatedMetricCount,
|
|
||||||
metricCounts.data(), results.data()));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// Allocate space for calculated reports.
|
|
||||||
setCount = 1;
|
|
||||||
metricCounts.resize(setCount);
|
|
||||||
results.resize(totalCalculatedMetricCount);
|
|
||||||
|
|
||||||
// Obtain calculated metrics and their count.
|
|
||||||
VALIDATECALL(zetMetricGroupCalculateMetricValues(
|
|
||||||
metricGroup,
|
|
||||||
ZET_METRIC_GROUP_CALCULATION_TYPE_METRIC_VALUES,
|
|
||||||
rawDataSize, rawData,
|
|
||||||
&totalCalculatedMetricCount, results.data()));
|
|
||||||
|
|
||||||
metricCounts[0] = totalCalculatedMetricCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtain metric group properties to show each metric.
|
// Obtain metric group properties to show each metric.
|
||||||
VALIDATECALL(zetMetricGroupGetProperties(metricGroup, &properties));
|
VALIDATECALL(zetMetricGroupGetProperties(metricGroup, &properties));
|
||||||
|
@ -310,7 +306,7 @@ void obtainCalculatedMetrics(zet_metric_group_handle_t metricGroup, uint8_t *raw
|
||||||
|
|
||||||
for (uint32_t i = 0; i < setCount; ++i) {
|
for (uint32_t i = 0; i < setCount; ++i) {
|
||||||
|
|
||||||
std::cout << "\r\nSet " << i;
|
LOG(LogLevel::DEBUG) << "\r\nSet " << i;
|
||||||
|
|
||||||
const uint32_t metricCount = properties.metricCount;
|
const uint32_t metricCount = properties.metricCount;
|
||||||
const uint32_t metricCountForSet = metricCounts[i];
|
const uint32_t metricCountForSet = metricCounts[i];
|
||||||
|
@ -329,36 +325,36 @@ void obtainCalculatedMetrics(zet_metric_group_handle_t metricGroup, uint8_t *raw
|
||||||
VALIDATECALL((results[resultIndex].type == metricProperties.resultType) ? ZE_RESULT_SUCCESS : ZE_RESULT_ERROR_UNKNOWN)
|
VALIDATECALL((results[resultIndex].type == metricProperties.resultType) ? ZE_RESULT_SUCCESS : ZE_RESULT_ERROR_UNKNOWN)
|
||||||
|
|
||||||
if (metricIndex == 0) {
|
if (metricIndex == 0) {
|
||||||
std::cout << "\r\n";
|
LOG(LogLevel::DEBUG) << "\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "\r\n";
|
LOG(LogLevel::DEBUG) << "\r\n";
|
||||||
std::cout << std::setw(25) << metricProperties.name << ": ";
|
LOG(LogLevel::DEBUG) << std::setw(25) << metricProperties.name << ": ";
|
||||||
|
|
||||||
switch (results[resultIndex].type) {
|
switch (results[resultIndex].type) {
|
||||||
case zet_value_type_t::ZET_VALUE_TYPE_BOOL8:
|
case zet_value_type_t::ZET_VALUE_TYPE_BOOL8:
|
||||||
std::cout << std::setw(12);
|
LOG(LogLevel::DEBUG) << std::setw(12);
|
||||||
std::cout << (results[resultIndex].value.b8 ? "true" : "false");
|
LOG(LogLevel::DEBUG) << (results[resultIndex].value.b8 ? "true" : "false");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case zet_value_type_t::ZET_VALUE_TYPE_FLOAT32:
|
case zet_value_type_t::ZET_VALUE_TYPE_FLOAT32:
|
||||||
std::cout << std::setw(12);
|
LOG(LogLevel::DEBUG) << std::setw(12);
|
||||||
std::cout << results[resultIndex].value.fp32;
|
LOG(LogLevel::DEBUG) << results[resultIndex].value.fp32;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case zet_value_type_t::ZET_VALUE_TYPE_FLOAT64:
|
case zet_value_type_t::ZET_VALUE_TYPE_FLOAT64:
|
||||||
std::cout << std::setw(12);
|
LOG(LogLevel::DEBUG) << std::setw(12);
|
||||||
std::cout << results[resultIndex].value.fp64;
|
LOG(LogLevel::DEBUG) << results[resultIndex].value.fp64;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case zet_value_type_t::ZET_VALUE_TYPE_UINT32:
|
case zet_value_type_t::ZET_VALUE_TYPE_UINT32:
|
||||||
std::cout << std::setw(12);
|
LOG(LogLevel::DEBUG) << std::setw(12);
|
||||||
std::cout << results[resultIndex].value.ui32;
|
LOG(LogLevel::DEBUG) << results[resultIndex].value.ui32;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case zet_value_type_t::ZET_VALUE_TYPE_UINT64:
|
case zet_value_type_t::ZET_VALUE_TYPE_UINT64:
|
||||||
std::cout << std::setw(12);
|
LOG(LogLevel::DEBUG) << std::setw(12);
|
||||||
std::cout << results[resultIndex].value.ui64;
|
LOG(LogLevel::DEBUG) << results[resultIndex].value.ui64;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -366,8 +362,92 @@ void obtainCalculatedMetrics(zet_metric_group_handle_t metricGroup, uint8_t *raw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "\r\n";
|
LOG(LogLevel::DEBUG) << "\r\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////
|
||||||
|
// Test Settings
|
||||||
|
////////////////
|
||||||
|
void TestSettings::parseArguments(int argc, char *argv[]) {
|
||||||
|
int opt;
|
||||||
|
|
||||||
|
struct option long_opts[] = {
|
||||||
|
{"help", no_argument, nullptr, 'h'},
|
||||||
|
{"test", required_argument, nullptr, 't'},
|
||||||
|
{"device", required_argument, nullptr, 'd'},
|
||||||
|
{"subdevice", required_argument, nullptr, 's'},
|
||||||
|
{"verboseLevel", required_argument, nullptr, 'v'},
|
||||||
|
{"metricGroupName", required_argument, nullptr, 'm'},
|
||||||
|
{0, 0, 0, 0},
|
||||||
|
};
|
||||||
|
|
||||||
|
auto printUsage = []() {
|
||||||
|
std::cout << "\n set Environment variable ZET_ENABLE_METRICS=1"
|
||||||
|
"\n"
|
||||||
|
"\n zello_metrics [OPTIONS]"
|
||||||
|
"\n"
|
||||||
|
"\n OPTIONS:"
|
||||||
|
"\n -t, --test <test name> run the specific test(\"all\" runs all tests)"
|
||||||
|
"\n -d, --device <deviceId> device ID to run the test"
|
||||||
|
"\n -s, --subdevice <subdeviceId> sub-device ID to run the test"
|
||||||
|
"\n -v, --verboseLevel <verboseLevel> verbosity level(-2:error|-1:warning|(default)0:info|1:debug"
|
||||||
|
"\n -m, --metricGroupName <name> metric group name"
|
||||||
|
"\n -h, --help display help message"
|
||||||
|
"\n";
|
||||||
|
};
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
printUsage();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((opt = getopt_long(argc, argv, "ht:d:s:v:m:", long_opts, nullptr)) != -1) {
|
||||||
|
switch (opt) {
|
||||||
|
case 't':
|
||||||
|
testName = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'd':
|
||||||
|
deviceId = std::atoi(optarg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 's':
|
||||||
|
subDeviceId = std::atoi(optarg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'v':
|
||||||
|
verboseLevel = std::atoi(optarg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'm':
|
||||||
|
metricGroupName = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'h':
|
||||||
|
printUsage();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Do not run tests in case of invalid option
|
||||||
|
testName.clear();
|
||||||
|
printUsage();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TestSettings *TestSettings::get() {
|
||||||
|
if (!settings) {
|
||||||
|
settings = new TestSettings;
|
||||||
|
}
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
TestSettings *TestSettings::settings = nullptr;
|
||||||
|
|
||||||
|
class DummyStreamBuf : public std::streambuf {};
|
||||||
|
DummyStreamBuf emptyStreamBuf;
|
||||||
|
std::ostream emptyCout(&emptyStreamBuf);
|
||||||
|
|
||||||
} // namespace ZelloMetricsUtility
|
} // namespace ZelloMetricsUtility
|
||||||
|
|
|
@ -7,9 +7,14 @@
|
||||||
|
|
||||||
#include "level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics.h"
|
#include "level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define MAX_DEVICES_IN_MACHINE (64u)
|
#define MAX_DEVICES_IN_MACHINE (64u)
|
||||||
|
#define LOG(level) (((level) <= (ZelloMetricsUtility::TestSettings::get())->verboseLevel) \
|
||||||
|
? (std::cout) \
|
||||||
|
: (ZelloMetricsUtility::emptyCout))
|
||||||
|
|
||||||
namespace ZelloMetricsUtility {
|
namespace ZelloMetricsUtility {
|
||||||
|
|
||||||
|
@ -20,11 +25,40 @@ struct TestMachineConfiguration {
|
||||||
uint32_t subDeviceCount;
|
uint32_t subDeviceCount;
|
||||||
} devices[MAX_DEVICES_IN_MACHINE];
|
} devices[MAX_DEVICES_IN_MACHINE];
|
||||||
uint32_t deviceCount = 0;
|
uint32_t deviceCount = 0;
|
||||||
|
uint32_t deviceId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TestSettings {
|
||||||
|
public:
|
||||||
|
static TestSettings *get();
|
||||||
|
void parseArguments(int argc, char *argv[]);
|
||||||
|
|
||||||
|
std::string testName = {};
|
||||||
|
int32_t deviceId = -1;
|
||||||
|
int32_t subDeviceId = -1;
|
||||||
|
int32_t verboseLevel = 0;
|
||||||
|
std::string metricGroupName = "TestOa";
|
||||||
|
|
||||||
|
private:
|
||||||
|
TestSettings() = default;
|
||||||
|
~TestSettings() = default;
|
||||||
|
static TestSettings *settings;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LogLevel {
|
||||||
|
enum {
|
||||||
|
ERROR = -2,
|
||||||
|
WARNING = -1,
|
||||||
|
INFO = 0,
|
||||||
|
DEBUG = 1
|
||||||
|
};
|
||||||
|
};
|
||||||
|
extern std::ostream emptyCout;
|
||||||
|
|
||||||
void createL0();
|
void createL0();
|
||||||
ze_driver_handle_t getDriver();
|
ze_driver_handle_t getDriver();
|
||||||
ze_context_handle_t createContext(ze_driver_handle_t &driverHandle);
|
ze_context_handle_t createContext(ze_driver_handle_t &driverHandle);
|
||||||
|
bool isDeviceAvailable(uint32_t deviceIndex, int32_t subDeviceIndex);
|
||||||
ze_device_handle_t getDevice(ze_driver_handle_t &driverHandle, uint32_t deviceIndex);
|
ze_device_handle_t getDevice(ze_driver_handle_t &driverHandle, uint32_t deviceIndex);
|
||||||
ze_device_handle_t getSubDevice(ze_device_handle_t &deviceHandle, uint32_t subDeviceIndex);
|
ze_device_handle_t getSubDevice(ze_device_handle_t &deviceHandle, uint32_t subDeviceIndex);
|
||||||
ze_command_queue_handle_t createCommandQueue(ze_context_handle_t &contextHandle,
|
ze_command_queue_handle_t createCommandQueue(ze_context_handle_t &contextHandle,
|
||||||
|
@ -40,4 +74,5 @@ zet_metric_group_handle_t findMetricGroup(const char *groupName,
|
||||||
ze_event_pool_handle_t createHostVisibleEventPool(ze_context_handle_t contextHandle, ze_device_handle_t deviceHandle);
|
ze_event_pool_handle_t createHostVisibleEventPool(ze_context_handle_t contextHandle, ze_device_handle_t deviceHandle);
|
||||||
ze_event_handle_t createHostVisibleEvent(ze_event_pool_handle_t hostVisibleEventPool);
|
ze_event_handle_t createHostVisibleEvent(ze_event_pool_handle_t hostVisibleEventPool);
|
||||||
void obtainCalculatedMetrics(zet_metric_group_handle_t metricGroup, uint8_t *rawData, uint32_t rawDataSize);
|
void obtainCalculatedMetrics(zet_metric_group_handle_t metricGroup, uint8_t *rawData, uint32_t rawDataSize);
|
||||||
|
|
||||||
} // namespace ZelloMetricsUtility
|
} // namespace ZelloMetricsUtility
|
||||||
|
|
|
@ -6,11 +6,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics.h"
|
#include "level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics.h"
|
||||||
|
#include "level_zero/tools/test/black_box_tests/zello_metrics/zello_metrics_util.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
namespace zmu = ZelloMetricsUtility;
|
||||||
|
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
/////AppendMemoryCopyFromHeapToDeviceAndBackToHost
|
/////AppendMemoryCopyFromHeapToDeviceAndBackToHost
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
|
@ -89,7 +92,7 @@ void CopyBufferToBuffer::initialize() {
|
||||||
auto length = file.tellg();
|
auto length = file.tellg();
|
||||||
file.seekg(0, file.beg);
|
file.seekg(0, file.beg);
|
||||||
|
|
||||||
std::cout << "Using copy_buffer_to_buffer.spv" << std::endl;
|
LOG(zmu::LogLevel::DEBUG) << "Using copy_buffer_to_buffer.spv" << std::endl;
|
||||||
|
|
||||||
std::unique_ptr<char[]> spirvInput(new char[length]);
|
std::unique_ptr<char[]> spirvInput(new char[length]);
|
||||||
file.read(spirvInput.get(), length);
|
file.read(spirvInput.get(), length);
|
||||||
|
@ -107,8 +110,7 @@ void CopyBufferToBuffer::initialize() {
|
||||||
|
|
||||||
char *strLog = (char *)malloc(szLog);
|
char *strLog = (char *)malloc(szLog);
|
||||||
zeModuleBuildLogGetString(buildlog, &szLog, strLog);
|
zeModuleBuildLogGetString(buildlog, &szLog, strLog);
|
||||||
std::cout << "Build log:" << strLog << std::endl;
|
LOG(zmu::LogLevel::DEBUG) << "Build log:" << strLog << std::endl;
|
||||||
|
|
||||||
free(strLog);
|
free(strLog);
|
||||||
}
|
}
|
||||||
VALIDATECALL(zeModuleBuildLogDestroy(buildlog));
|
VALIDATECALL(zeModuleBuildLogDestroy(buildlog));
|
||||||
|
@ -145,9 +147,7 @@ bool CopyBufferToBuffer::appendCommands() {
|
||||||
VALIDATECALL(zeCommandListAppendLaunchKernel(executionCtxt->getCommandList(0), kernel, &dispatchTraits,
|
VALIDATECALL(zeCommandListAppendLaunchKernel(executionCtxt->getCommandList(0), kernel, &dispatchTraits,
|
||||||
nullptr, 0, nullptr));
|
nullptr, 0, nullptr));
|
||||||
} else {
|
} else {
|
||||||
|
LOG(zmu::LogLevel::DEBUG) << "Using zeCommandListAppendMemoryCopy" << std::endl;
|
||||||
std::cout << "Using zeCommandListAppendMemoryCopy" << std::endl;
|
|
||||||
|
|
||||||
VALIDATECALL(zeCommandListAppendMemoryCopy(executionCtxt->getCommandList(0), destinationBuffer,
|
VALIDATECALL(zeCommandListAppendMemoryCopy(executionCtxt->getCommandList(0), destinationBuffer,
|
||||||
sourceBuffer, allocationSize, nullptr, 0, nullptr));
|
sourceBuffer, allocationSize, nullptr, 0, nullptr));
|
||||||
}
|
}
|
||||||
|
@ -166,16 +166,16 @@ bool CopyBufferToBuffer::validate() {
|
||||||
uint8_t *dstCharBuffer = static_cast<uint8_t *>(destinationBuffer);
|
uint8_t *dstCharBuffer = static_cast<uint8_t *>(destinationBuffer);
|
||||||
for (size_t i = 0; i < allocationSize; i++) {
|
for (size_t i = 0; i < allocationSize; i++) {
|
||||||
if (srcCharBuffer[i] != dstCharBuffer[i]) {
|
if (srcCharBuffer[i] != dstCharBuffer[i]) {
|
||||||
std::cout << "srcBuffer[" << i << "] = " << static_cast<unsigned int>(srcCharBuffer[i]) << " not equal to "
|
LOG(zmu::LogLevel::ERROR) << "srcBuffer[" << i << "] = " << static_cast<unsigned int>(srcCharBuffer[i]) << " not equal to "
|
||||||
<< "dstBuffer[" << i << "] = " << static_cast<unsigned int>(dstCharBuffer[i]) << "\n";
|
<< "dstBuffer[" << i << "] = " << static_cast<unsigned int>(dstCharBuffer[i]) << "\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "\nResults validation "
|
LOG(zmu::LogLevel::DEBUG) << "\nResults validation "
|
||||||
<< (outputValidationSuccessful ? "PASSED" : "FAILED")
|
<< (outputValidationSuccessful ? "PASSED" : "FAILED")
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
return outputValidationSuccessful;
|
return outputValidationSuccessful;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue