From 87e544093afdfb938ae3661610d7281381a9916b Mon Sep 17 00:00:00 2001 From: Ben Ashbaugh Date: Sun, 1 Dec 2024 12:05:38 -0800 Subject: [PATCH] Mdapi multi adapter (#394) * update to latest MDAPI headers * update metric printing to support multiple adapters * add the ability to enumerate MDAPI adapters from adapter groups * whitespace fix * fix typo * add a bit more debug output * add a cliloader option to print metric devices and exit * cleanup and add a command line option for mdapi device index * final updates and documentation * disable MD_DEBUG by default again --- cliloader/cliloader.cpp | 15 + cliloader/printmetrics.h | 331 +++- docs/controls.md | 4 + docs/mdapi.md | 13 + intercept/mdapi/MetricsDiscoveryHelper.cpp | 326 +++- intercept/mdapi/MetricsDiscoveryHelper.h | 56 +- intercept/mdapi/intercept_mdapi.cpp | 5 +- intercept/mdapi/metrics_discovery_api.h | 1890 ++++++++++++-------- intercept/src/controls.h | 1 + 9 files changed, 1728 insertions(+), 913 deletions(-) diff --git a/cliloader/cliloader.cpp b/cliloader/cliloader.cpp index 02507d5d..9fa0e4b0 100644 --- a/cliloader/cliloader.cpp +++ b/cliloader/cliloader.cpp @@ -381,6 +381,11 @@ static bool parseArguments(int argc, char *argv[]) printMetrics(); return false; } + else if (!strcmp(argv[i], "--mdapi-devices")) + { + printMetricDevices(); + return false; + } #if defined(_WIN32) else if( !strcmp(argv[i], "--no-DLL-load") ) { @@ -496,6 +501,14 @@ static bool parseArguments(int argc, char *argv[]) mdapiGroup = argv[i]; } } + else if( !strcmp(argv[i], "--mdapi-device") ) + { + ++i; + if( i < argc ) + { + checkSetEnv("CLI_DevicePerfCounterAdapterIndex", argv[i]); + } + } else if( !strcmp(argv[i], "-h") || !strcmp(argv[i], "--host-timing") ) { checkSetEnv("CLI_HostPerformanceTiming", "1"); @@ -591,6 +604,7 @@ static bool parseArguments(int argc, char *argv[]) " --debug Enable cliloader Debug Messages\n" " --controls Print All Controls and Exit\n" " --metrics Print All MDAPI Metrics and Exit\n" + " --mdapi-devices Print All MDAPI Devices and Exit\n" #if defined(_WIN32) " --no-DLL-load Do not load the Intercept DLL into the child process\n" #else // not Windows @@ -618,6 +632,7 @@ static bool parseArguments(int argc, char *argv[]) " --mdapi-ebs Report Event-Based MDAPI Metrics (Intel GPU Only)\n" " --mdapi-tbs Report Time-Based MDAPI Metrics (Intel GPU Only)\n" " --mdapi-group Choose MDAPI Metrics to Collect (Intel GPU Only)\n" + " --mdapi-device Choose MDAPI Device for Metrics (Intel GPU Only)\n" " --host-timing [-h] Report Host API Execution Time\n" " --capture-enqueue Capture the Specified Kernel Enqueue\n" " --capture-kernel Capture the Specified Kernel Name\n" diff --git a/cliloader/printmetrics.h b/cliloader/printmetrics.h index 71244a45..26264113 100644 --- a/cliloader/printmetrics.h +++ b/cliloader/printmetrics.h @@ -63,71 +63,243 @@ static void* OpenLibrary() namespace MetricsDiscovery { -static bool printMetricsHelper(const std::string& metricsFileName) +static const char* adapterTypeToString(TAdapterType type) { - OpenMetricsDevice_fn OpenMetricsDevice; - CloseMetricsDevice_fn CloseMetricsDevice; - OpenMetricsDeviceFromFile_fn OpenMetricsDeviceFromFile; - - TCompletionCode res = CC_OK; - - IMetricsDevice_1_5* metricsDevice; + switch (type) { + case ADAPTER_TYPE_UNDEFINED: return "UNDEFINED"; + case ADAPTER_TYPE_INTEGRATED: return "INTEGRATED"; + case ADAPTER_TYPE_DISCRETE: return "DISCRETE"; + default: break; + } + return "Unknown"; +} - void* pLibrary = OpenLibrary(); - if (pLibrary == NULL) +static bool printMetricsForDevice(IMetricsDeviceLatest* pMetricsDevice) +{ + TMetricsDeviceParamsLatest* pDeviceParams = pMetricsDevice->GetParams(); + if (NULL == pDeviceParams) { - fprintf(stderr, "Couldn't load metrics discovery library!\n"); + fprintf(stderr, "MetricsDevice->GetParams() returned NULL\n"); return false; } - CloseMetricsDevice = (CloseMetricsDevice_fn)GetFunctionAddress(pLibrary, "CloseMetricsDevice"); - if (CloseMetricsDevice == NULL) + for (uint32_t cg = 0; cg < pDeviceParams->ConcurrentGroupsCount; cg++) { - fprintf(stderr, "Couldn't get pointer to CloseMetricsDevice!\n"); + IConcurrentGroupLatest* pGroup = pMetricsDevice->GetConcurrentGroup(cg); + TConcurrentGroupParamsLatest* pGroupParams = pGroup->GetParams(); + + if (NULL == pGroupParams) + { + continue; + } + + fprintf(stderr, "\nMetric Group: %s (%d Metric Set%s)\n", + pGroupParams->Description, + pGroupParams->MetricSetsCount, + pGroupParams->MetricSetsCount > 1 ? "s" : ""); + fprintf(stderr, "========================================\n\n"); + + for (uint32_t ms = 0; ms < pGroupParams->MetricSetsCount; ms++) + { + IMetricSetLatest* pMetricSet = pGroup->GetMetricSet(ms); + TMetricSetParamsLatest* pSetParams = pMetricSet->GetParams(); + + if (NULL == pSetParams) + { + continue; + } + + fprintf(stderr, "Metric Set: %s (%d Metric%s)\n", + pSetParams->ShortName, + pSetParams->MetricsCount, + pSetParams->MetricsCount > 1 ? "s" : ""); + fprintf(stderr, "----------------------------------------\n\n"); + + for (uint32_t m = 0; m < pSetParams->MetricsCount; m++) + { + TMetricParamsLatest* pMetricParams = pMetricSet->GetMetric(m)->GetParams(); + + if (NULL == pMetricParams) + { + continue; + } + + fprintf(stderr, + "%s\\%s (%s):\n" + "%s\n\n", + pSetParams->SymbolName, + pMetricParams->SymbolName, + pMetricParams->ShortName, + pMetricParams->LongName); + } + } + } + + return true; +} + +static bool printMetricsForAdapterGroup(void* pLibrary, bool devicesOnly) +{ + TCompletionCode res = CC_OK; + + OpenAdapterGroup_fn OpenAdapterGroup; + OpenAdapterGroup = (OpenAdapterGroup_fn)GetFunctionAddress(pLibrary, "OpenAdapterGroup"); + if (OpenAdapterGroup == NULL) + { + fprintf(stderr, "Couldn't get pointer to OpenAdapterGroup!\n"); return false; } - OpenMetricsDevice = (OpenMetricsDevice_fn)GetFunctionAddress(pLibrary, "OpenMetricsDevice"); - if (OpenMetricsDevice == NULL) + IAdapterGroupLatest* pAdapterGroup = NULL; + res = OpenAdapterGroup(&pAdapterGroup); + if (res != CC_OK) { - fprintf(stderr, "Couldn't get pointer to OpenMetricsDevice!\n"); + fprintf(stderr, "OpenAdapterGroup failed, res: %d\n", res); return false; } - OpenMetricsDeviceFromFile = (OpenMetricsDeviceFromFile_fn)GetFunctionAddress(pLibrary, "OpenMetricsDeviceFromFile"); - if (OpenMetricsDeviceFromFile == NULL) + const TAdapterGroupParamsLatest* pAdapterGroupParams = pAdapterGroup->GetParams(); + if (NULL == pAdapterGroupParams) { - fprintf(stderr, "Couldn't get pointer to OpenMetricsDeviceFromFile!\n"); + fprintf(stderr, "AdapterGroup->GetParams() returned NULL\n"); return false; } - if (!metricsFileName.empty()) + fprintf(stderr, "MDAPI Headers: v%d.%d.%d, MDAPI Lib: v%d.%d.%d\n", + MD_API_MAJOR_NUMBER_CURRENT, + MD_API_MINOR_NUMBER_CURRENT, + MD_API_BUILD_NUMBER_CURRENT, + pAdapterGroupParams->Version.MajorNumber, + pAdapterGroupParams->Version.MinorNumber, + pAdapterGroupParams->Version.BuildNumber); + if (pAdapterGroupParams->Version.MajorNumber < 1 || + (pAdapterGroupParams->Version.MajorNumber == 1 && pAdapterGroupParams->Version.MinorNumber < 1)) { - res = OpenMetricsDeviceFromFile(metricsFileName.c_str(), (void*)"", &metricsDevice); - if (res != CC_OK) + fprintf(stderr, "MDAPI Lib version must be at least v1.1!\n"); + } + else + { + fprintf(stderr, "Found %u MDAPI Adapter%s:\n", + pAdapterGroupParams->AdapterCount, + pAdapterGroupParams->AdapterCount > 1 ? "s" : ""); + for (uint32_t a = 0; a < pAdapterGroupParams->AdapterCount; a++) { - res = OpenMetricsDeviceFromFile(metricsFileName.c_str(), (void*)"abcdefghijklmnop", &metricsDevice); + IAdapterLatest* pAdapter = pAdapterGroup->GetAdapter(a); + if (NULL == pAdapter) + { + fprintf(stderr, "AdapterGroup->GetAdapter() returned NULL, skipping adapter.\n"); + continue; + } + + const TAdapterParamsLatest* pAdapterParams = pAdapter->GetParams(); + if (NULL == pAdapterParams) + { + fprintf(stderr, "Adapter->GetParams() returned NULL, skipping adapter.\n"); + continue; + } + + fprintf(stderr, "Adapter %u: %s (%s)\n", + a, + pAdapterParams->ShortName, + adapterTypeToString(pAdapterParams->Type)); + fprintf(stderr, "\tPCI Vendor Id: %04X, Device Id: %04X, Bus Info: %02X:%02X.%02X\n", + pAdapterParams->VendorId, + pAdapterParams->DeviceId, + pAdapterParams->BusNumber, + pAdapterParams->DeviceNumber, + pAdapterParams->FunctionNumber); } - if (res != CC_OK) + if (!devicesOnly) { - fprintf(stderr, "OpenMetricsDeviceFromFile failed, res: %d\n", res); - return false; + for (uint32_t a = 0; a < pAdapterGroupParams->AdapterCount; a++) + { + IAdapterLatest* pAdapter = pAdapterGroup->GetAdapter(a); + if (NULL == pAdapter) + { + fprintf(stderr, "AdapterGroup->GetAdapter() returned NULL, skipping adapter.\n"); + continue; + } + + const TAdapterParamsLatest* pAdapterParams = pAdapter->GetParams(); + if (NULL == pAdapterParams) + { + fprintf(stderr, "Adapter->GetParams() returned NULL, skipping adapter.\n"); + continue; + } + + fprintf(stderr, "\nAdapter %u: %s (%s)\n", + a, + pAdapterParams->ShortName, + adapterTypeToString(pAdapterParams->Type)); + fprintf(stderr, "\tPCI Vendor Id: %04X, Device Id: %04X, Bus Info: %02X:%02X.%02X\n", + pAdapterParams->VendorId, + pAdapterParams->DeviceId, + pAdapterParams->BusNumber, + pAdapterParams->DeviceNumber, + pAdapterParams->FunctionNumber); + fprintf(stderr, "########################################\n\n"); + + IMetricsDeviceLatest* pMetricsDevice = NULL; + res = pAdapter->OpenMetricsDevice(&pMetricsDevice); + if (res != CC_OK) + { + fprintf(stderr, "OpenMetricsDevice failed, res: %d, skipping adapter.\n", res); + continue; + } + + printMetricsForDevice(pMetricsDevice); + + res = pAdapter->CloseMetricsDevice(pMetricsDevice); + if (res != CC_OK) + { + fprintf(stderr, "CloseMetricsDevice failed, res: %d\n", res); + } + } } } - else + + res = pAdapterGroup->Close(); + if (res != CC_OK) { - res = OpenMetricsDevice(&metricsDevice); - if (res != CC_OK) - { - fprintf(stderr, "OpenMetricsDevice failed, res: %d\n", res); - return false; - } + fprintf(stderr, "AdapterGroup->Close() failed, res: %d\n", res); + } + + return true; +} + +static bool printMetricsForLegacyDevice(void* pLibrary) +{ + TCompletionCode res = CC_OK; + + OpenMetricsDevice_fn OpenMetricsDevice; + CloseMetricsDevice_fn CloseMetricsDevice; + + OpenMetricsDevice = (OpenMetricsDevice_fn)GetFunctionAddress(pLibrary, "OpenMetricsDevice"); + if (OpenMetricsDevice == NULL) + { + fprintf(stderr, "Couldn't get pointer to OpenMetricsDevice!\n"); + return false; } - TMetricsDeviceParams_1_0* deviceParams = metricsDevice->GetParams(); - if (NULL == deviceParams) + CloseMetricsDevice = (CloseMetricsDevice_fn)GetFunctionAddress(pLibrary, "CloseMetricsDevice"); + if (CloseMetricsDevice == NULL) { - fprintf(stderr, "DeviceParams null\n"); + fprintf(stderr, "Couldn't get pointer to CloseMetricsDevice!\n"); + return false; + } + + IMetricsDeviceLatest* pMetricsDevice; + res = OpenMetricsDevice(&pMetricsDevice); + if (res != CC_OK) + { + fprintf(stderr, "OpenMetricsDevice failed, res: %d\n", res); + return false; + } + + TMetricsDeviceParams_1_0* pDeviceParams = pMetricsDevice->GetParams(); + if (NULL == pDeviceParams) + { + fprintf(stderr, "MetricsDevice->GetParams() returned NULL\n"); return false; } @@ -135,76 +307,55 @@ static bool printMetricsHelper(const std::string& metricsFileName) MD_API_MAJOR_NUMBER_CURRENT, MD_API_MINOR_NUMBER_CURRENT, MD_API_BUILD_NUMBER_CURRENT, - deviceParams->Version.MajorNumber, - deviceParams->Version.MinorNumber, - deviceParams->Version.BuildNumber); - if (deviceParams->Version.MajorNumber < 1 || - (deviceParams->Version.MajorNumber == 1 && deviceParams->Version.MinorNumber < 1)) + pDeviceParams->Version.MajorNumber, + pDeviceParams->Version.MinorNumber, + pDeviceParams->Version.BuildNumber); + if (pDeviceParams->Version.MajorNumber < 1 || + (pDeviceParams->Version.MajorNumber == 1 && pDeviceParams->Version.MinorNumber < 1)) { fprintf(stderr, "MDAPI Lib version must be at least v1.1!\n"); return false; } - - bool found = false; - for (uint32_t cg = 0; !found && cg < deviceParams->ConcurrentGroupsCount; cg++) + else { - IConcurrentGroup_1_1* group = metricsDevice->GetConcurrentGroup(cg); - TConcurrentGroupParams_1_0* groupParams = group->GetParams(); - - if (groupParams) - { - fprintf(stderr, "\nMetric Group: %s (%d Metric Set%s)\n", - groupParams->Description, - groupParams->MetricSetsCount, - groupParams->MetricSetsCount > 1 ? "s" : ""); - fprintf(stderr, "========================================\n\n"); - - for (uint32_t ms = 0; ms < groupParams->MetricSetsCount; ms++) - { - IMetricSet_1_1* metricSet = group->GetMetricSet(ms); - TMetricSetParams_1_0* setParams = metricSet->GetParams(); - - if (setParams) - { - fprintf(stderr, "Metric Set: %s (%d Metric%s)\n", - setParams->ShortName, - setParams->MetricsCount, - setParams->MetricsCount > 1 ? "s" : ""); - fprintf(stderr, "----------------------------------------\n\n"); - - for (uint32_t m = 0; m < setParams->MetricsCount; m++) - { - TMetricParams_1_0* metricParams = metricSet->GetMetric(m)->GetParams(); - - if (metricParams) - { - fprintf(stderr, - "%s\\%s (%s):\n" - "%s\n\n", - setParams->SymbolName, - metricParams->SymbolName, - metricParams->ShortName, - metricParams->LongName); - } - } - } - } - } + printMetricsForDevice(pMetricsDevice); } - res = CloseMetricsDevice(metricsDevice); + res = CloseMetricsDevice(pMetricsDevice); if (res != CC_OK) { fprintf(stderr, "CloseMetricsDevice failed, res: %d\n", res); - return false; } return true; } +static bool printMetricsHelper(bool devicesOnly) +{ + void* pLibrary = OpenLibrary(); + if (pLibrary == NULL) + { + fprintf(stderr, "Couldn't load metrics discovery library!\n"); + return false; + } + + bool success = printMetricsForAdapterGroup(pLibrary, devicesOnly); + if (!success && !devicesOnly) + { + success = printMetricsForLegacyDevice(pLibrary); + } + + return success; +} + }; static void printMetrics() { - MetricsDiscovery::printMetricsHelper(""); + MetricsDiscovery::printMetricsHelper(false); +} + +static void printMetricDevices() +{ + MetricsDiscovery::printMetricsHelper(true); } diff --git a/docs/controls.md b/docs/controls.md index 94a8157b..a1934ca8 100644 --- a/docs/controls.md +++ b/docs/controls.md @@ -367,6 +367,10 @@ If set to a nonzero value and DevicePerfCounterCustom is set, the Intercept Laye If set to a nonzero value and DevicePerfCounterCustom is set, the Intercept Layer for OpenCL Applications will enable Intel GPU Performance Counters to track performance counter deltas at regular time intervals. This operation may be fairly intrusive and may have side effects. This feature will only function if the Intercept Layer for OpenCL Applications is built with MDAPI support. +##### `DevicePerfCounterAdapterIndex` (uint32_t) + +Select which MDAPI device to report performance counters. + ##### `DevicePerfCounterCustom` (string) If set, the Intercept Layer for OpenCL Applications will collect MDAPI metrics for the Metric Set corresponding to this value for each OpenCL command. Frequently used Metric Sets include: ComputeBasic, ComputeExtended, L3\_1, Sampler. The output file has the potential to be very big depending on the work load. This operation may be fairly intrusive and may have side effects; in particular it forces all command queues to be created with PROFILING\_ENABLED and may increment the reference count for application events. When the process exits, this information will be included in the file "clintercept\_perfcounter\_dump\_\.txt". This feature will only function if the Intercept Layer for OpenCL Applications is built with MDAPI support. diff --git a/docs/mdapi.md b/docs/mdapi.md index 163faa25..57d97339 100644 --- a/docs/mdapi.md +++ b/docs/mdapi.md @@ -89,12 +89,25 @@ These controls can be enabled via `cliloader`, by specifying the `--mdapi-tbs` o * https://github.com/intel/metrics-library +* On Linux, some GPUs (specifically the "Gen11" and "Gen12"-based GPUs, +including the Arc A-series "Alchemist" discrete GPUs) require the out-of-tree +i915 kernel mode driver. +Please refer to the [installation docs](https://dgpu-docs.intel.com/) for +instructions how to install the out-of-tree kernel mode driver. * On OSX, the path to the MDAPI library should be set manually with `DevicePerfCounterLibName` control. The library is named `libigdmd.dylib` and it usually resides under `/System/Library/Extensions/AppleIntelGraphicsMTLDriver.bundle/Contents/MacOS/libigdmd.dylib`, where `` is a short name of your CPU generation. For example, on Kaby Lake machines `` is `KBL`. You can also add path to `libigdmd.dylib` library to `DYLD_LIBRARY_PATH` environment library, so that it can be found system-wide. +* On systems with multiple GPUs, metrics may only be collected for one GPU at a +time. Use the control **DevicePerfCounterAdapterIndex** to choose which GPU to +collect metrics for. This control may also be set via `cliloader`, by passing +the `--mdapi-device` option. +* To enumerate the available GPUs for metric collection and their adapter +indices, use `cliloader` and pass the `--mdapi-devices` option. +* To enumerate available metrics, use `cliloader` and pass the `--metrics` +option. * Collecting MDAPI metrics currently requires elevated privileges because metrics are collected system-wide. * On Linux, MDAPI metrics may be enabled for non-root users diff --git a/intercept/mdapi/MetricsDiscoveryHelper.cpp b/intercept/mdapi/MetricsDiscoveryHelper.cpp index fd35d175..4ead7094 100644 --- a/intercept/mdapi/MetricsDiscoveryHelper.cpp +++ b/intercept/mdapi/MetricsDiscoveryHelper.cpp @@ -116,6 +116,7 @@ MDHelper::MDHelper(uint32_t apiMask) : m_Activated( false ), m_APIMask( apiMask ), m_CategoryMask( GPU_RENDER | GPU_COMPUTE | GPU_MEDIA | GPU_GENERIC ), + m_AdapterGroup( NULL ), m_MetricsDevice( NULL ), m_ConcurrentGroup( NULL ), m_MetricSet( NULL ), @@ -133,7 +134,19 @@ MDHelper::~MDHelper() DeactivateMetricSet(); } - if( CloseMetricsDevice != NULL && m_MetricsDevice ) + if( m_AdapterGroup != NULL ) + { + if( m_Adapter && m_MetricsDevice ) + { + m_Adapter->CloseMetricsDevice( m_MetricsDevice ); + m_MetricsDevice = NULL; + } + + m_AdapterGroup->Close(); + m_AdapterGroup = NULL; + m_Adapter = NULL; + } + else if( CloseMetricsDevice != NULL && m_MetricsDevice ) { CloseMetricsDevice( m_MetricsDevice ); m_MetricsDevice = NULL; @@ -149,7 +162,8 @@ MDHelper* MDHelper::CreateEBS( const std::string& metricsLibraryName, const std::string& metricSetSymbolName, const std::string& metricsFileName, - const bool includeMaxValues ) + uint32_t adapterIndex, + bool includeMaxValues ) { #if defined(__linux__) || defined(__FreeBSD__) // This is a temporary workaround until the Linux MDAPI is updated @@ -164,6 +178,7 @@ MDHelper* MDHelper::CreateEBS( metricsLibraryName, metricSetSymbolName, metricsFileName, + adapterIndex, includeMaxValues ) == false ) { Delete( pMDHelper ); @@ -179,7 +194,8 @@ MDHelper* MDHelper::CreateTBS( const std::string& metricsLibraryName, const std::string& metricSetSymbolName, const std::string& metricsFileName, - const bool includeMaxValues ) + uint32_t adapterIndex, + bool includeMaxValues ) { MDHelper* pMDHelper = new MDHelper(API_TYPE_IOSTREAM); if( pMDHelper ) @@ -188,6 +204,7 @@ MDHelper* MDHelper::CreateTBS( metricsLibraryName, metricSetSymbolName, metricsFileName, + adapterIndex, includeMaxValues ) == false ) { Delete( pMDHelper ); @@ -212,16 +229,16 @@ bool MDHelper::InitMetricsDiscovery( const std::string& metricsLibraryName, const std::string& metricSetSymbolName, const std::string& metricsFileName, - const bool includeMaxValues ) + uint32_t adapterIndex, + bool includeMaxValues ) { m_Initialized = false; m_IncludeMaxValues = includeMaxValues; - CloseMetricsDevice = NULL; + OpenAdapterGroup = NULL; OpenMetricsDevice = NULL; OpenMetricsDeviceFromFile = NULL; - - TCompletionCode res = CC_OK; + CloseMetricsDevice = NULL; if (m_APIMask & API_TYPE_IOSTREAM && m_APIMask != API_TYPE_IOSTREAM) { @@ -238,11 +255,11 @@ bool MDHelper::InitMetricsDiscovery( return false; } - CloseMetricsDevice = (CloseMetricsDevice_fn)GetFunctionAddress(pLibrary, "CloseMetricsDevice"); - if (CloseMetricsDevice == NULL) + OpenAdapterGroup = (OpenAdapterGroup_fn)GetFunctionAddress(pLibrary, "OpenAdapterGroup"); + if (OpenAdapterGroup == NULL) { - DebugPrint("Couldn't get pointer to CloseMetricsDevice!\n"); - return false; + DebugPrint("Couldn't get pointer to OpenAdapterGroup!\n"); + // OpenAdapterGroup is a newer function that is not supported by older MDAPI. } OpenMetricsDevice = (OpenMetricsDevice_fn)GetFunctionAddress(pLibrary, "OpenMetricsDevice"); @@ -259,6 +276,148 @@ bool MDHelper::InitMetricsDiscovery( return false; } + CloseMetricsDevice = (CloseMetricsDevice_fn)GetFunctionAddress(pLibrary, "CloseMetricsDevice"); + if (CloseMetricsDevice == NULL) + { + DebugPrint("Couldn't get pointer to CloseMetricsDevice!\n"); + return false; + } + + DebugPrint("InitMetricsDiscoveryAdapterGroup for adapter index %u...\n", adapterIndex); + bool success = InitMetricsDiscoveryAdapterGroup( + metricSetSymbolName, + metricsFileName, + adapterIndex ); + if (!success) + { + DebugPrint("InitMetricsDiscoveryLegacy...\n", adapterIndex); + success = InitMetricsDiscoveryLegacy( + metricSetSymbolName, + metricsFileName ); + } + + if (success) + { + m_MetricSet->SetApiFiltering( m_APIMask ); + m_Initialized = true; + } + + DebugPrint("MetricsDiscoveryInit End\n"); + return m_Initialized; +} + +/************************************************************************/ +/* InitMetricsDiscoveryAdapterGroup */ +/************************************************************************/ +bool MDHelper::InitMetricsDiscoveryAdapterGroup( + const std::string& metricSetSymbolName, + const std::string& metricsFileName, + uint32_t adapterIndex ) +{ + TCompletionCode res = CC_OK; + + res = OpenAdapterGroup(&m_AdapterGroup); + if (res != CC_OK) + { + DebugPrint("OpenAdapterGroup failed, res: %d\n", res); + return false; + } + + const TAdapterGroupParamsLatest* pAdapterGroupParams = m_AdapterGroup->GetParams(); + if (NULL == pAdapterGroupParams) + { + DebugPrint("AdapterGroup->GetParams() returned NULL\n"); + return false; + } + + DebugPrint("MDAPI Headers: v%d.%d.%d, MDAPI Lib: v%d.%d.%d\n", + MD_API_MAJOR_NUMBER_CURRENT, + MD_API_MINOR_NUMBER_CURRENT, + MD_API_BUILD_NUMBER_CURRENT, + pAdapterGroupParams->Version.MajorNumber, + pAdapterGroupParams->Version.MinorNumber, + pAdapterGroupParams->Version.BuildNumber); + if (pAdapterGroupParams->Version.MajorNumber < 1 || + (pAdapterGroupParams->Version.MajorNumber == 1 && pAdapterGroupParams->Version.MinorNumber < 1)) + { + DebugPrint("MDAPI Lib version must be at least v1.1!\n"); + return false; + } + if( pAdapterGroupParams->Version.MajorNumber < 1 || + ( pAdapterGroupParams->Version.MajorNumber == 1 && pAdapterGroupParams->Version.MinorNumber < 5 ) ) + { + if( m_IncludeMaxValues ) + { + DebugPrint("MDAPI Lib version must be at least v1.5 for maximum value tracking - disabling.\n"); + m_IncludeMaxValues = false; + } + } + + if (adapterIndex >= pAdapterGroupParams->AdapterCount) + { + DebugPrint("Requested adapter index is %u but only %u adapters were found. Using adapter 0.\n"); + adapterIndex = 0; + } + + m_Adapter = m_AdapterGroup->GetAdapter(adapterIndex); + if (NULL == m_Adapter) + { + DebugPrint("AdapterGroup->GetAdapter() returned NULL\n"); + return false; + } + + const TAdapterParamsLatest* pAdapterParams = m_Adapter->GetParams(); + if (pAdapterParams) + { + DebugPrint("Adapter: %s\n", + pAdapterParams->ShortName); + DebugPrint("PCI Vendor Id: %04X, Device Id: %04X, Bus Info: %02X:%02X.%02X\n", + pAdapterParams->VendorId, + pAdapterParams->DeviceId, + pAdapterParams->BusNumber, + pAdapterParams->DeviceNumber, + pAdapterParams->FunctionNumber); + } + + if (!metricsFileName.empty()) + { + res = m_Adapter->OpenMetricsDeviceFromFile(metricsFileName.c_str(), (void*)"", &m_MetricsDevice); + if (res != CC_OK) + { + res = m_Adapter->OpenMetricsDeviceFromFile(metricsFileName.c_str(), (void*)"abcdefghijklmnop", &m_MetricsDevice); + } + if (res != CC_OK) + { + DebugPrint("OpenMetricsDeviceFromFile failed, res: %d\n", res); + return false; + } + } + else + { + res = m_Adapter->OpenMetricsDevice(&m_MetricsDevice); + if (res != CC_OK) + { + DebugPrint("OpenMetricsDevice failed, res: %d\n", res); + return false; + } + } + + bool found = FindMetricSetForDevice( + m_MetricsDevice, + metricSetSymbolName ); + + return found; +} + +/************************************************************************/ +/* InitMetricsDiscoveryLegacy */ +/************************************************************************/ +bool MDHelper::InitMetricsDiscoveryLegacy( + const std::string& metricSetSymbolName, + const std::string& metricsFileName ) +{ + TCompletionCode res = CC_OK; + if (!metricsFileName.empty()) { res = OpenMetricsDeviceFromFile(metricsFileName.c_str(), (void*)"", &m_MetricsDevice); @@ -282,10 +441,10 @@ bool MDHelper::InitMetricsDiscovery( } } - TMetricsDeviceParams_1_0* deviceParams = m_MetricsDevice->GetParams(); + TMetricsDeviceParamsLatest* deviceParams = m_MetricsDevice->GetParams(); if (NULL == deviceParams) { - DebugPrint("DeviceParams null\n"); + DebugPrint("MetricsDevice->GetParams() returned NULL\n"); return false; } @@ -312,66 +471,85 @@ bool MDHelper::InitMetricsDiscovery( } } + bool found = FindMetricSetForDevice( + m_MetricsDevice, + metricSetSymbolName ); + + return found; +} + +/************************************************************************/ +/* FindMetricSetForDevice */ +/************************************************************************/ +bool MDHelper::FindMetricSetForDevice( + IMetricsDeviceLatest* pMetricsDevice, + const std::string& metricSetSymbolName ) +{ DebugPrint("Looking for MetricSet: %s, API: %X, Category: %X\n", metricSetSymbolName.c_str(), m_APIMask, m_CategoryMask ); + TMetricsDeviceParamsLatest* pDeviceParams = pMetricsDevice->GetParams(); + if (NULL == pDeviceParams) + { + DebugPrint("MetricsDevice->GetParams returned NULL\n"); + return false; + } + bool found = false; - for( uint32_t cg = 0; !found && cg < deviceParams->ConcurrentGroupsCount; cg++ ) + for( uint32_t cg = 0; !found && cg < pDeviceParams->ConcurrentGroupsCount; cg++ ) { - IConcurrentGroup_1_1 *group = m_MetricsDevice->GetConcurrentGroup(cg); - TConcurrentGroupParams_1_0* groupParams = group->GetParams(); - if( groupParams ) + IConcurrentGroupLatest *pGroup = pMetricsDevice->GetConcurrentGroup(cg); + TConcurrentGroupParamsLatest* pGroupParams = pGroup->GetParams(); + + if (NULL == pGroupParams) + { + continue; + } + + for( uint32_t ms = 0; !found && ms < pGroupParams->MetricSetsCount; ms++) { - for( uint32_t ms = 0; !found && ms < groupParams->MetricSetsCount; ms++) + IMetricSetLatest* pMetricSet = pGroup->GetMetricSet(ms); + TMetricSetParamsLatest* pSetParams = pMetricSet->GetParams(); + + if( pSetParams && + ( pSetParams->ApiMask & m_APIMask ) && + ( pSetParams->CategoryMask & m_CategoryMask ) && + ( metricSetSymbolName == pSetParams->SymbolName ) ) + { + DebugPrint("Matched Group: %s MetricSet: %s MetricCount: %d API: %X, Category: %X\n", + pGroupParams->SymbolName, + pSetParams->SymbolName, + pSetParams->MetricsCount, + pSetParams->ApiMask, + pSetParams->CategoryMask ); + + found = true; + m_ConcurrentGroup = pGroup; + m_MetricSet = pMetricSet; + } + else if( pSetParams ) { - IMetricSet_1_1* metricSet = group->GetMetricSet(ms); - TMetricSetParams_1_0* setParams = metricSet->GetParams(); - - if( setParams && - ( setParams->ApiMask & m_APIMask ) && - ( setParams->CategoryMask & m_CategoryMask ) && - ( metricSetSymbolName == setParams->SymbolName ) ) - { - DebugPrint("Matched Group: %s MetricSet: %s MetricCount: %d API: %X, Category: %X\n", - groupParams->SymbolName, - setParams->SymbolName, - setParams->MetricsCount, - setParams->ApiMask, - setParams->CategoryMask ); - - found = true; - m_ConcurrentGroup = group; - m_MetricSet = metricSet; - } - else if( setParams ) - { - DebugPrint("Skipped Group: %s MetricSet: %s MetricCount: %d API: %X, Category: %X\n", - groupParams->SymbolName, - setParams->SymbolName, - setParams->MetricsCount, - setParams->ApiMask, - setParams->CategoryMask ); - } + DebugPrint("Skipped Group: %s MetricSet: %s MetricCount: %d API: %X, Category: %X\n", + pGroupParams->SymbolName, + pSetParams->SymbolName, + pSetParams->MetricsCount, + pSetParams->ApiMask, + pSetParams->CategoryMask ); } } } if (m_MetricSet == NULL) { - DebugPrint("MetricSet is null\n"); - return false; + DebugPrint("MetricSet not found.\n"); } - m_MetricSet->SetApiFiltering( m_APIMask ); - - m_Initialized = true; - - DebugPrint("MetricsDiscoveryInit End\n"); - return m_Initialized; + return found; } + /************************************************************************/ /* ActivateMetricSet */ /************************************************************************/ @@ -435,8 +613,8 @@ void MDHelper::SetMetricSetFiltering( TMetricApiType apiMask ) uint32_t MDHelper::GetMetricsFromReports( const uint32_t numReports, const char* pReportData, - std::vector& results, - std::vector& maxValues ) + std::vector& results, + std::vector& maxValues ) { if( !m_Initialized || !m_MetricSet ) { @@ -459,14 +637,14 @@ uint32_t MDHelper::GetMetricsFromReports( if( m_IncludeMaxValues ) { maxValues.resize( metricsCount * (size_t)numReports ); - res = ((MetricsDiscovery::IMetricSet_1_5*)m_MetricSet)->CalculateMetrics( + res = m_MetricSet->CalculateMetrics( (const unsigned char*)pReportData, reportSize, results.data(), - (uint32_t)(results.size() * sizeof(TTypedValue_1_0)), + (uint32_t)(results.size() * sizeof(TTypedValueLatest)), &outReportCount, maxValues.data(), - (uint32_t)(maxValues.size() * sizeof(TTypedValue_1_0)) ); + (uint32_t)(maxValues.size() * sizeof(TTypedValueLatest)) ); } else { @@ -474,7 +652,7 @@ uint32_t MDHelper::GetMetricsFromReports( (const unsigned char*)pReportData, reportSize, results.data(), - (uint32_t)(results.size() * sizeof(TTypedValue_1_0)), + (uint32_t)(results.size() * sizeof(TTypedValueLatest)), &outReportCount, false ); } @@ -495,7 +673,7 @@ uint32_t MDHelper::GetMetricsFromReports( /* GetIOMeasurementInformation */ /************************************************************************/ void MDHelper::GetIOMeasurementInformation( - std::vector& ioInfoValues ) + std::vector& ioInfoValues ) { if (!m_Initialized || !m_ConcurrentGroup || !m_MetricSet ) { @@ -515,7 +693,7 @@ void MDHelper::GetIOMeasurementInformation( ioInfoValues.resize(ioInformationCount); TCompletionCode res = m_MetricSet->CalculateIoMeasurementInformation( ioInfoValues.data(), - (uint32_t)(ioInfoValues.size() * sizeof(TTypedValue_1_0)) ); + (uint32_t)(ioInfoValues.size() * sizeof(TTypedValueLatest)) ); if( res != CC_OK ) { DebugPrint("CalculateIoMeasurementInformation failed!\n"); @@ -542,7 +720,7 @@ void MDHelper::OpenStream( uint32_t timerPeriod, uint32_t bufferSize, uint32_t p if( bufferSize == 0 ) { - TTypedValue_1_0* oaBufferSize = m_MetricsDevice-> + TTypedValueLatest* oaBufferSize = m_MetricsDevice-> GetGlobalSymbolValueByName( "OABufferMaxSize" ); if( oaBufferSize ) { @@ -653,8 +831,8 @@ bool MDHelper::SaveReportsFromStream( void ) /* GetMetricsFromSavedReports */ /************************************************************************/ uint32_t MDHelper::GetMetricsFromSavedReports( - std::vector& results, - std::vector& maxValues ) + std::vector& results, + std::vector& maxValues ) { DebugPrint("Getting metrics from %d saved reports...\n", m_NumSavedReports); @@ -792,9 +970,9 @@ void MDHelper::PrintMetricValues( std::ostream& os, const std::string& name, const uint32_t numResults, - const std::vector& results, - const std::vector& maxValues, - const std::vector& ioInfoValues ) + const std::vector& results, + const std::vector& maxValues, + const std::vector& ioInfoValues ) { if( !m_Initialized || !m_ConcurrentGroup || !m_MetricSet || !os.good() ) { @@ -849,7 +1027,7 @@ void MDHelper::PrintMetricValues( void MDHelper::AggregateMetrics( CMetricAggregations& aggregations, const std::string& name, - const std::vector& results ) + const std::vector& results ) { if( !m_Initialized || !m_MetricSet ) { @@ -862,7 +1040,7 @@ void MDHelper::AggregateMetrics( uint32_t metricsCount = m_MetricSet->GetParams()->MetricsCount; for( uint32_t i = 0; i < metricsCount; i++ ) { - TMetricParams_1_0* metricParams = m_MetricSet->GetMetric( i )->GetParams(); + TMetricParamsLatest* metricParams = m_MetricSet->GetMetric( i )->GetParams(); // Find profile data for metric const char* metricName = metricParams->SymbolName; @@ -882,7 +1060,7 @@ void MDHelper::AggregateMetrics( /************************************************************************/ /* PrintValue */ /************************************************************************/ -void MDHelper::PrintValue( std::ostream& os, const TTypedValue_1_0& value ) +void MDHelper::PrintValue( std::ostream& os, const TTypedValueLatest& value ) { switch( value.ValueType ) { @@ -910,12 +1088,12 @@ void MDHelper::PrintValue( std::ostream& os, const TTypedValue_1_0& value ) /************************************************************************/ /* GetGlobalSymbolValue */ /************************************************************************/ -TTypedValue_1_0* MDHelper::GetGlobalSymbolValue( +TTypedValueLatest* MDHelper::GetGlobalSymbolValue( const char* SymbolName ) { for( uint32_t i = 0; i < m_MetricsDevice->GetParams()->GlobalSymbolsCount; i++ ) { - TGlobalSymbol_1_0* symbol = m_MetricsDevice->GetGlobalSymbol( i ); + TGlobalSymbolLatest* symbol = m_MetricsDevice->GetGlobalSymbol( i ); if( strcmp( symbol->SymbolName, SymbolName ) == 0 ) { return &( symbol->SymbolTypedValue ); @@ -927,7 +1105,7 @@ TTypedValue_1_0* MDHelper::GetGlobalSymbolValue( /************************************************************************/ /* CastToUInt64 */ /************************************************************************/ -uint64_t MDHelper::CastToUInt64(TTypedValue_1_0 value) +uint64_t MDHelper::CastToUInt64(TTypedValueLatest value) { switch( value.ValueType ) { diff --git a/intercept/mdapi/MetricsDiscoveryHelper.h b/intercept/mdapi/MetricsDiscoveryHelper.h index ac4a2fc3..eec9f206 100644 --- a/intercept/mdapi/MetricsDiscoveryHelper.h +++ b/intercept/mdapi/MetricsDiscoveryHelper.h @@ -45,12 +45,14 @@ class MDHelper const std::string& metricsLibraryName, const std::string& metricSetSymbolName, const std::string& metricsFileName, - const bool includeMaxValues ); + uint32_t adapterIndex, + bool includeMaxValues ); static MDHelper* CreateTBS( const std::string& metricsLibraryName, const std::string& metricSetSymbolName, const std::string& metricsFileName, - const bool includeMaxValues ); + uint32_t adapterIndex, + bool includeMaxValues ); static void Delete( MDHelper*& pMDHelper ); uint32_t GetMetricsConfiguration(); @@ -65,10 +67,10 @@ class MDHelper uint32_t GetMetricsFromReports( const uint32_t numReports, const char* pData, - std::vector& results, - std::vector& maxValues ); + std::vector& results, + std::vector& maxValues ); void GetIOMeasurementInformation( - std::vector& ioInfoValues ); + std::vector& ioInfoValues ); void OpenStream( uint32_t timerPeriod, @@ -76,8 +78,8 @@ class MDHelper uint32_t pid ); bool SaveReportsFromStream( void ); uint32_t GetMetricsFromSavedReports( - std::vector& results, - std::vector& maxValues ); + std::vector& results, + std::vector& maxValues ); void ResetSavedReports( void ); void CloseStream( void ); @@ -90,14 +92,14 @@ class MDHelper std::ostream& os, const std::string& name, const uint32_t numResults, - const std::vector& results, - const std::vector& maxValues, - const std::vector& ioInfoValues ); + const std::vector& results, + const std::vector& maxValues, + const std::vector& ioInfoValues ); void AggregateMetrics( CMetricAggregations& aggregations, const std::string& name, - const std::vector& results ); + const std::vector& results ); private: MDHelper(uint32_t apiMask); @@ -107,20 +109,34 @@ class MDHelper const std::string& metricsLibraryName, const std::string& metricSetSymbolName, const std::string& metricsFileName, - const bool includeMaxValues ); + uint32_t adapterIndex, + bool includeMaxValues ); + + bool InitMetricsDiscoveryAdapterGroup( + const std::string& metricSetSymbolName, + const std::string& metricsFileName, + uint32_t adapterIndex ); + bool InitMetricsDiscoveryLegacy( + const std::string& metricSetSymbolName, + const std::string& metricsFileName ); + + bool FindMetricSetForDevice( + IMetricsDeviceLatest* pMetricsDevice, + const std::string& metricSetSymbolName ); void PrintValue( std::ostream& os, - const TTypedValue_1_0& value ); + const TTypedValueLatest& value ); - TTypedValue_1_0* GetGlobalSymbolValue( + TTypedValueLatest* GetGlobalSymbolValue( const char* symbolName ); - static uint64_t CastToUInt64(TTypedValue_1_0 value ); + static uint64_t CastToUInt64(TTypedValueLatest value ); + OpenAdapterGroup_fn OpenAdapterGroup; OpenMetricsDevice_fn OpenMetricsDevice; - CloseMetricsDevice_fn CloseMetricsDevice; OpenMetricsDeviceFromFile_fn OpenMetricsDeviceFromFile; + CloseMetricsDevice_fn CloseMetricsDevice; bool m_Initialized; bool m_Activated; @@ -128,9 +144,11 @@ class MDHelper uint32_t m_APIMask; uint32_t m_CategoryMask; - IMetricsDevice_1_5* m_MetricsDevice; - IConcurrentGroup_1_1* m_ConcurrentGroup; - IMetricSet_1_1* m_MetricSet; + IAdapterGroupLatest* m_AdapterGroup; + IAdapterLatest* m_Adapter; + IMetricsDeviceLatest* m_MetricsDevice; + IConcurrentGroupLatest* m_ConcurrentGroup; + IMetricSetLatest* m_MetricSet; // Report data for time based sampling: std::vector m_SavedReportData; diff --git a/intercept/mdapi/intercept_mdapi.cpp b/intercept/mdapi/intercept_mdapi.cpp index 2b9c4c6f..bb7f0b4d 100644 --- a/intercept/mdapi/intercept_mdapi.cpp +++ b/intercept/mdapi/intercept_mdapi.cpp @@ -142,7 +142,8 @@ void CLIntercept::initCustomPerfCounters() { const std::string& metricSetSymbolName = config().DevicePerfCounterCustom; const std::string& metricsFileName = config().DevicePerfCounterFile; - const bool includeMaxValues = config().DevicePerfCounterReportMax; + uint32_t adapterIndex = config().DevicePerfCounterAdapterIndex; + bool includeMaxValues = config().DevicePerfCounterReportMax; if( m_pMDHelper == NULL ) { @@ -157,6 +158,7 @@ void CLIntercept::initCustomPerfCounters() config().DevicePerfCounterLibName, metricSetSymbolName, metricsFileName, + adapterIndex, includeMaxValues ); } else if( config().DevicePerfCounterTimeBasedSampling ) @@ -165,6 +167,7 @@ void CLIntercept::initCustomPerfCounters() config().DevicePerfCounterLibName, metricSetSymbolName, metricsFileName, + adapterIndex, includeMaxValues ); } else diff --git a/intercept/mdapi/metrics_discovery_api.h b/intercept/mdapi/metrics_discovery_api.h index 195b9265..2bebb3bc 100644 --- a/intercept/mdapi/metrics_discovery_api.h +++ b/intercept/mdapi/metrics_discovery_api.h @@ -1,80 +1,81 @@ -/*****************************************************************************\ +/*========================== begin_copyright_notice ============================ - Copyright © 2018, Intel Corporation +Copyright (C) 2019-2022 Intel Corporation - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the "Software"), - to deal in the Software without restriction, including without limitation - the rights to use, copy, modify, merge, publish, distribute, sublicense, - and/or sell copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following conditions: +SPDX-License-Identifier: MIT - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. +============================= end_copyright_notice ===========================*/ - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - IN THE SOFTWARE. +// File Name: metrics_discovery_api.h - File Name: metrics_discovery_api.h +// Abstract: Interface for metrics discovery DLL - Abstract: Interface for metrics discovery DLL +#pragma once - Notes: - -\*****************************************************************************/ #include -#ifndef __METRICS_DISCOVERY_H_ -#define __METRICS_DISCOVERY_H_ - #ifdef _MSC_VER - #define MD_STDCALL __stdcall + #define MD_STDCALL __stdcall #else - #define MD_STDCALL + #define MD_STDCALL #endif // _MSC_VER +////////////////////////////////////////////////////////////////////////////////// +// Helper macro to check required API version. +// Combines major and minor into one, comparable 64bit value. +////////////////////////////////////////////////////////////////////////////////// +#define MD_API_VERSION_COMBINE_MAJOR_MINOR( version ) \ + ( (uint64_t) ( version ).MajorNumber << 32 | (uint64_t) ( version ).MinorNumber ) + +////////////////////////////////////////////////////////////////////////////////// +// Macro to check required API version. +// Uses TApiVersion_1_0 struct. +////////////////////////////////////////////////////////////////////////////////// +#define MD_API_VERSION_AT_LEAST( requiredVersion, currentVersion ) \ + ( MD_API_VERSION_COMBINE_MAJOR_MINOR( ( currentVersion ) ) > MD_API_VERSION_COMBINE_MAJOR_MINOR( ( requiredVersion ) ) || MD_API_VERSION_COMBINE_MAJOR_MINOR( ( currentVersion ) ) == MD_API_VERSION_COMBINE_MAJOR_MINOR( ( requiredVersion ) ) && ( currentVersion ).BuildNumber >= ( requiredVersion ).BuildNumber ) + +////////////////////////////////////////////////////////////////////////////////// +// API build number: +////////////////////////////////////////////////////////////////////////////////// +#define MD_API_BUILD_NUMBER_CURRENT 170 + namespace MetricsDiscovery { -//*****************************************************************************/ -// API major version number: -//*****************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // API major version number: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EMD_API_MAJOR_VERSION { MD_API_MAJOR_NUMBER_1 = 1, MD_API_MAJOR_NUMBER_CURRENT = MD_API_MAJOR_NUMBER_1, MD_API_MAJOR_NUMBER_CEIL = 0xFFFFFFFF - } MD_API_MAJOR_VERSION; -//*****************************************************************************/ -// API minor version number: -//*****************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // API minor version number: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EMD_API_MINOR_VERSION { MD_API_MINOR_NUMBER_0 = 0, - MD_API_MINOR_NUMBER_1 = 1, // CalculationAPI - MD_API_MINOR_NUMBER_2 = 2, // OverridesAPI - MD_API_MINOR_NUMBER_3 = 3, // BatchBuffer Sampling (aka DMA Sampling) - MD_API_MINOR_NUMBER_4 = 4, // GT dependent MetricSets - MD_API_MINOR_NUMBER_5 = 5, // MaxValue calculation for CalculationAPI - MD_API_MINOR_NUMBER_CURRENT = MD_API_MINOR_NUMBER_5, + MD_API_MINOR_NUMBER_1 = 1, // CalculationAPI + MD_API_MINOR_NUMBER_2 = 2, // OverridesAPI + MD_API_MINOR_NUMBER_3 = 3, // BatchBuffer Sampling (aka DMA Sampling) + MD_API_MINOR_NUMBER_4 = 4, // GT dependent MetricSets + MD_API_MINOR_NUMBER_5 = 5, // MaxValue calculation for CalculationAPI + MD_API_MINOR_NUMBER_6 = 6, // Multi adapter support + MD_API_MINOR_NUMBER_7 = 7, // Compile time equations calculation approach + MD_API_MINOR_NUMBER_8 = 8, // TAdapterParams update + MD_API_MINOR_NUMBER_9 = 9, // Sub device support. + MD_API_MINOR_NUMBER_10 = 10, // GetGpuCpuTimestamps API function extended by a correlation indicator param + MD_API_MINOR_NUMBER_11 = 11, // Add availability equations for metric sets + MD_API_MINOR_NUMBER_12 = 12, // Add support for Information Set in concurrent group + MD_API_MINOR_NUMBER_CURRENT = MD_API_MINOR_NUMBER_12, MD_API_MINOR_NUMBER_CEIL = 0xFFFFFFFF - } MD_API_MINOR_VERSION; -//*****************************************************************************/ -// API build number: -//*****************************************************************************/ - #define MD_API_BUILD_NUMBER_CURRENT 96 - -//*****************************************************************************/ -// Completion codes: -//*****************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Completion codes: + ////////////////////////////////////////////////////////////////////////////////// typedef enum ECompletionCode { CC_OK = 0, @@ -85,70 +86,69 @@ namespace MetricsDiscovery CC_WAIT_TIMEOUT = 5, CC_TRY_AGAIN = 6, CC_INTERRUPTED = 7, - // ... CC_ERROR_INVALID_PARAMETER = 40, CC_ERROR_NO_MEMORY = 41, CC_ERROR_GENERAL = 42, CC_ERROR_FILE_NOT_FOUND = 43, CC_ERROR_NOT_SUPPORTED = 44, - // ... CC_LAST_1_0 = 45 - } TCompletionCode; + /* Forward declarations */ -/* Forward declarations */ - -//*******************************************************************************/ -// Abstract interface for the GPU metrics root object. -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Abstract interface for the GPU metrics root object. + ////////////////////////////////////////////////////////////////////////////////// class IMetricsDevice_1_0; class IMetricsDevice_1_1; class IMetricsDevice_1_2; class IMetricsDevice_1_5; + class IMetricsDevice_1_10; + class IMetricsDevice_1_11; -//*******************************************************************************/ -// Abstract interface for Metrics Device overrides. -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Abstract interface for Metrics Device overrides. + ////////////////////////////////////////////////////////////////////////////////// class IOverride_1_2; -//*******************************************************************************/ -// Abstract interface for the metrics groups that can be collected concurrently -// to another group. -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Abstract interface for the metrics groups that can be collected concurrently + // to another group. + ////////////////////////////////////////////////////////////////////////////////// class IConcurrentGroup_1_0; class IConcurrentGroup_1_1; class IConcurrentGroup_1_5; + class IConcurrentGroup_1_11; -//*******************************************************************************/ -// Abstract interface for the metric sets mapping to different HW configuration -// that should be used exclusively to each other metric set in the concurrent -// group. -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Abstract interface for the metric sets mapping to different HW configuration + // that should be used exclusively to each other metric set in the concurrent + // group. + ////////////////////////////////////////////////////////////////////////////////// class IMetricSet_1_0; class IMetricSet_1_1; class IMetricSet_1_4; class IMetricSet_1_5; + class IMetricSet_1_11; -//*******************************************************************************/ -// Abstract interface for the metric that is sampled. -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Abstract interface for the metric that is sampled. + ////////////////////////////////////////////////////////////////////////////////// class IMetric_1_0; -//*******************************************************************************/ -// Abstract interface for the measurement information (report reason, etc.). -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Abstract interface for the measurement information (report reason, etc.). + ////////////////////////////////////////////////////////////////////////////////// class IInformation_1_0; -//*******************************************************************************/ -// Abstract interface for the metric read and normalization equation. -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Abstract interface for the metric read and normalization equation. + ////////////////////////////////////////////////////////////////////////////////// class IEquation_1_0; - -//*******************************************************************************/ -// Value types: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Value types: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EValueType { VALUE_TYPE_UINT32, @@ -156,18 +156,28 @@ namespace MetricsDiscovery VALUE_TYPE_FLOAT, VALUE_TYPE_BOOL, VALUE_TYPE_CSTRING, + VALUE_TYPE_BYTEARRAY, // ... VALUE_TYPE_LAST, - } TValueType; -//*******************************************************************************/ -// Typed value: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Byte Array: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SByteArray_1_0 + { + uint32_t Size; + uint8_t* Data; + } TByteArray_1_0; + + ////////////////////////////////////////////////////////////////////////////////// + // Typed value: + ////////////////////////////////////////////////////////////////////////////////// typedef struct STypedValue_1_0 { TValueType ValueType; - union { + union + { uint32_t ValueUInt32; uint64_t ValueUInt64; struct @@ -175,306 +185,430 @@ namespace MetricsDiscovery uint32_t Low; uint32_t High; } ValueUInt64Fields; - float ValueFloat; - bool ValueBool; - char* ValueCString; + float ValueFloat; + bool ValueBool; + char* ValueCString; + TByteArray_1_0* ValueByteArray; // Dynamically allocated }; - } TTypedValue_1_0; -//*******************************************************************************/ -// Global symbol: -// Global symbols will be available to describe SKU specific information. -// Example global symbols: -// "EuCoresTotalCount", "EuThreadsCount", "EuSlicesTotalCount", "EuSubslicesTotalCount", -// "SamplersTotalCount", "PciDeviceId", "NumberOfShadingUnits", "GpuTimestampFrequency", -// "MaxTimestamp", "GpuMinFrequencyMHz", "GpuMaxFrequencyMHz" -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Global symbol: + // Global symbols will be available to describe SKU specific information. + // Example global symbols: + // "EuCoresTotalCount", "EuThreadsCount", "EuSlicesTotalCount", "EuSubslicesTotalCount", + // "SamplersTotalCount", "PciDeviceId", "NumberOfShadingUnits", "GpuTimestampFrequency", + // "MaxTimestamp", "GpuMinFrequencyMHz", "GpuMaxFrequencyMHz" + ////////////////////////////////////////////////////////////////////////////////// typedef struct SGlobalSymbol_1_0 { const char* SymbolName; TTypedValue_1_0 SymbolTypedValue; - } TGlobalSymbol_1_0; -//*******************************************************************************/ -// Global parameters of Metrics Device: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // API version: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SApiVersion_1_0 + { + uint32_t MajorNumber; + uint32_t MinorNumber; + uint32_t BuildNumber; + } TApiVersion_1_0; + + ////////////////////////////////////////////////////////////////////////////////// + // Global parameters of Metrics Device: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SMetricsDeviceParams_1_0 { // API version - struct SApiVersion - { - uint32_t MajorNumber; - uint32_t MinorNumber; - uint32_t BuildNumber; - } Version; - - uint32_t ConcurrentGroupsCount; - - uint32_t GlobalSymbolsCount; - uint32_t DeltaFunctionsCount; - uint32_t EquationElementTypesCount; - uint32_t EquationOperationsCount; - - const char* DeviceName; - + TApiVersion_1_0 Version; + uint32_t ConcurrentGroupsCount; + uint32_t GlobalSymbolsCount; + uint32_t DeltaFunctionsCount; + uint32_t EquationElementTypesCount; + uint32_t EquationOperationsCount; + const char* DeviceName; } TMetricsDeviceParams_1_0; -//*******************************************************************************/ -// Global parameters of Metrics Device 1.2: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Global parameters of Metrics Device 1.2: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SMetricsDeviceParams_1_2 : public SMetricsDeviceParams_1_0 { uint32_t OverrideCount; - } TMetricsDeviceParams_1_2; -//*******************************************************************************/ -// Metric API types: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Metric API types: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EMetricApiType { - API_TYPE_IOSTREAM = 0x00000001, // API independent method - API_TYPE_DX9 = 0x00000002, - API_TYPE_DX10 = 0x00000004, - API_TYPE_DX11 = 0x00000008, - API_TYPE_OGL = 0x00000010, - API_TYPE_OGL4_X = 0x00000020, - API_TYPE_OCL = 0x00000040, - API_TYPE_MEDIA = 0x00000080, // Only option would be using DmaBuffer sampling - API_TYPE_DX12 = 0x00000100, - API_TYPE_BBSTREAM = 0x00000200, - API_TYPE_VULKAN = 0x00000400, - API_TYPE_RESERVED = 0x00000800, - API_TYPE_ALL = 0xffffffff - + API_TYPE_IOSTREAM = 0x00000001, // API independent method + API_TYPE_DX9 = 0x00000002, + API_TYPE_DX10 = 0x00000004, + API_TYPE_DX11 = 0x00000008, + API_TYPE_OGL = 0x00000010, + API_TYPE_OGL4_X = 0x00000020, + API_TYPE_OCL = 0x00000040, + API_TYPE_MEDIA = 0x00000080, // Obsolete + API_TYPE_DX12 = 0x00000100, + API_TYPE_BBSTREAM = 0x00000200, // Obsolete + API_TYPE_VULKAN = 0x00000400, + API_TYPE_RESERVED = 0x00000800, + API_TYPE_ALL = 0xFFFFFFFF } TMetricApiType; -//*******************************************************************************/ -// Measurement types: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Measurement types: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EMeasurementType { MEASUREMENT_TYPE_SNAPSHOT_IO = 0x00000001, MEASUREMENT_TYPE_SNAPSHOT_QUERY = 0x00000002, MEASUREMENT_TYPE_DELTA_QUERY = 0x00000004, - MEASUREMENT_TYPE_ALL = 0x0000ffff, - + MEASUREMENT_TYPE_ALL = 0x0000FFFF, } TMeasurementType; -//*******************************************************************************/ -// Usage flags: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Usage flags: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EMetricUsageFlag { - USAGE_FLAG_OVERVIEW = 0x00000001, // GPU system overview metric - // Useful for high level workload characterization - USAGE_FLAG_INDICATE = 0x00000002, // Metric indicating a performance problem - // Useful when comparing with threshold - USAGE_FLAG_CORRELATE = 0x00000004, // Metric correlating with performance problem - // Useful for proving to false only - //... - USAGE_FLAG_SYSTEM = 0x00000020, // Metric useful at system level - USAGE_FLAG_FRAME = 0x00000040, // Metric useful at frame level - USAGE_FLAG_BATCH = 0x00000080, // Metric useful at batch level - USAGE_FLAG_DRAW = 0x00000100, // Metric useful at draw level - - // ... - USAGE_FLAG_TIER_1 = 0x00000400, - USAGE_FLAG_TIER_2 = 0x00000800, - USAGE_FLAG_TIER_3 = 0x00001000, - USAGE_FLAG_TIER_4 = 0x00002000, - USAGE_FLAG_GLASS_JAW = 0x00004000, - - USAGE_FLAG_ALL = 0x0000ffff, - + USAGE_FLAG_OVERVIEW = 0x00000001, // GPU system overview metric, useful for high level workload characterization + USAGE_FLAG_INDICATE = 0x00000002, // Metric indicating a performance problem, useful when comparing with threshold + USAGE_FLAG_CORRELATE = 0x00000004, // Metric correlating with performance problem, useful for proving to false only + USAGE_FLAG_SYSTEM = 0x00000020, // Metric useful at system level + USAGE_FLAG_FRAME = 0x00000040, // Metric useful at frame level + USAGE_FLAG_BATCH = 0x00000080, // Metric useful at batch level + USAGE_FLAG_DRAW = 0x00000100, // Metric useful at draw level + USAGE_FLAG_TIER_1 = 0x00000400, + USAGE_FLAG_TIER_2 = 0x00000800, + USAGE_FLAG_TIER_3 = 0x00001000, + USAGE_FLAG_TIER_4 = 0x00002000, + USAGE_FLAG_GLASS_JAW = 0x00004000, + USAGE_FLAG_ALL = 0x0000FFFF, } TMetricUsageFlag; -//*******************************************************************************/ -// Sampling types: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Sampling types: + ////////////////////////////////////////////////////////////////////////////////// typedef enum ESamplingType { - SAMPLING_TYPE_OA_TIMER = 0x00000001, - SAMPLING_TYPE_OA_EVENT = 0x00000002, - SAMPLING_TYPE_GPU_QUERY = 0x00000004, - SAMPLING_TYPE_DMA_BUFFER = 0x00000008,// Possible future extension for media - SAMPLING_TYPE_ALL = 0x0000ffff, - + SAMPLING_TYPE_OA_TIMER = 0x00000001, + SAMPLING_TYPE_OA_EVENT = 0x00000002, + SAMPLING_TYPE_GPU_QUERY = 0x00000004, + SAMPLING_TYPE_DMA_BUFFER = 0x00000008, // Possible future extension for media + SAMPLING_TYPE_OAM_TIMER = 0x00000010, + SAMPLING_TYPE_ALL = 0x0000FFFF, } TSamplingType; -//*******************************************************************************/ -// Metric categories: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Metric categories: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EMetricCategory { GPU_RENDER = 0x0001, GPU_COMPUTE = 0x0002, GPU_MEDIA = 0x0004, - GPU_GENERIC = 0x0008, // Does not belong to any specific category like memory traffic - + GPU_GENERIC = 0x0008, // Does not belong to any specific category like memory traffic } TMetricCategory; -//*******************************************************************************/ -// IoStream read flags: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // IoStream read flags: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EIoReadFlag { IO_READ_FLAG_DROP_OLD_REPORTS = 0x00000001, IO_READ_FLAG_GET_CONTEXT_ID_TAGS = 0x00000002, - } TIoReadFlag; -//*******************************************************************************/ -// Override modes: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Override modes: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EOverrideMode { OVERRIDE_MODE_GLOBAL = 0x0001, OVERRIDE_MODE_LOCAL = 0x0002, - } TOverrideMode; -//*******************************************************************************/ -// Global parameters of Concurrent Group: -//*******************************************************************************/ - typedef struct SConcurrentGroupParams_1_0 + ////////////////////////////////////////////////////////////////////////////////// + // Adapter capability flags: + ////////////////////////////////////////////////////////////////////////////////// + typedef enum EAdapterCapability + { + ADAPTER_CAPABILITY_UNDEFINED = 0, + ADAPTER_CAPABILITY_RENDER_SUPPORTED = 1 << 0, + } TAdapterCapability; + + ////////////////////////////////////////////////////////////////////////////////// + // Adapter types: + ////////////////////////////////////////////////////////////////////////////////// + typedef enum EAdapterType + { + ADAPTER_TYPE_UNDEFINED = 0, + ADAPTER_TYPE_INTEGRATED, + ADAPTER_TYPE_DISCRETE, + } TAdapterType; + + ////////////////////////////////////////////////////////////////////////////////// + // Adapter ID types: + ////////////////////////////////////////////////////////////////////////////////// + typedef enum EAdapterIdType { - const char* SymbolName; // For example "PerfMon" or "OA" or "PipeStats" - const char* Description; // For example "PerfMon and ODLAT Uncore ring counters" + ADAPTER_ID_TYPE_UNDEFINED = 0, + ADAPTER_ID_TYPE_LUID, + ADAPTER_ID_TYPE_MAJOR_MINOR, + } TAdapterIdType; + + ////////////////////////////////////////////////////////////////////////////////// + // LUID (locally unique identifier) adapter ID: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SAdapterIdLuid_1_6 + { + uint32_t LowPart; + int32_t HighPart; + } TAdapterIdLuid_1_6; + + ////////////////////////////////////////////////////////////////////////////////// + // Major / minor pair adapter ID: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SAdapterIdMajorMinor_1_6 + { + int32_t Major; + int32_t Minor; + } TAdapterIdMajorMinor_1_6; + + ////////////////////////////////////////////////////////////////////////////////// + // Adapter ID: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SAdapterId_1_6 + { + TAdapterIdType Type; + union + { + TAdapterIdLuid_1_6 Luid; + TAdapterIdMajorMinor_1_6 MajorMinor; + }; + } TAdapterId_1_6; - uint32_t MeasurementTypeMask; + ////////////////////////////////////////////////////////////////////////////////// + // Global parameters of GPU adapter: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SAdapterParams_1_6 + { + const char* ShortName; + TAdapterId_1_6 SystemId; // Operating system specific adapter id + uint32_t VendorId; + uint32_t SubVendorId; + uint32_t DeviceId; + uint32_t Platform; + uint32_t BusNumber; + uint32_t DeviceNumber; + uint32_t FunctionNumber; + TAdapterType Type; // Adapter type, e.g. integrated, discrete + uint32_t CapabilityMask; // Consists of TAdapterCapability flags, e.g. RENDER_SUPPORTED + } TAdapterParams_1_6; + + ////////////////////////////////////////////////////////////////////////////////// + // Global parameters of GPU adapter: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SAdapterParams_1_8 : public SAdapterParams_1_6 + { + uint32_t DomainNumber; + } TAdapterParams_1_8; - uint32_t MetricSetsCount; - uint32_t IoMeasurementInformationCount; - uint32_t IoGpuContextInformationCount; + ////////////////////////////////////////////////////////////////////////////////// + // Global parameters of GPU adapter: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SAdapterParams_1_9 : public SAdapterParams_1_8 + { + uint32_t SubDevicesCount; + } TAdapterParams_1_9; - } TConcurrentGroupParams_1_0; + ////////////////////////////////////////////////////////////////////////////////// + // Global parameters of GPU sub device: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SSubDeviceParams_1_9 + { + uint32_t EnginesCount; + } TSubDeviceParams_1_9; -//*******************************************************************************/ -// Global parameters of an Override: -//*******************************************************************************/ - typedef struct SOverrideParams_1_2 + ////////////////////////////////////////////////////////////////////////////////// + // Engine ID types: + ////////////////////////////////////////////////////////////////////////////////// + typedef enum EEngineIdType + { + ENGINE_ID_TYPE_CLASS_INSTANCE = 0 + } TEngineIdType; + + ////////////////////////////////////////////////////////////////////////////////// + // Class / instance engine ID: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SEngineIdClassInstance_1_9 + { + uint32_t Class; + uint32_t Instance; + } TEngineIdClassInstance_1_9; + + ////////////////////////////////////////////////////////////////////////////////// + // Engine identification: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SEngineId_1_9 + { + TEngineIdType Type; + + union + { + TEngineIdClassInstance_1_9 ClassInstance; + }; + } TEngineId_1_9; + + ////////////////////////////////////////////////////////////////////////////////// + // Global parameters of GPU engine: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SEngineParams_1_9 + { + TEngineId_1_9 EngineId; + } TEngineParams_1_9; + + ////////////////////////////////////////////////////////////////////////////////// + // Global parameters of Adapter Group: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SAdapterGroupParams_1_6 { - const char* SymbolName; // For example "FrequencyOverride" - const char* Description; // For example "Overrides device GPU frequency with a static value." + // API version + TApiVersion_1_0 Version; + uint32_t AdapterCount; + } TAdapterGroupParams_1_6; + + ////////////////////////////////////////////////////////////////////////////////// + // Global parameters of Concurrent Group: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SConcurrentGroupParams_1_0 + { + const char* SymbolName; // For example "OA" or "OAM0" or "PipeStats" + const char* Description; // For example "OA Unit Metrics" + uint32_t MeasurementTypeMask; + uint32_t MetricSetsCount; + uint32_t IoMeasurementInformationCount; + uint32_t IoGpuContextInformationCount; - uint32_t ApiMask; - uint32_t PlatformMask; + } TConcurrentGroupParams_1_0; - uint32_t OverrideModeMask; + ////////////////////////////////////////////////////////////////////////////////// + // Global parameters of an Override: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SOverrideParams_1_2 + { + const char* SymbolName; // For example "FrequencyOverride" + const char* Description; // For example "Overrides device GPU frequency with a static value." + uint32_t ApiMask; + uint32_t PlatformMask; + uint32_t OverrideModeMask; } TOverrideParams_1_2; -//*******************************************************************************/ -// Base params of SetOverride method: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Base params of SetOverride method: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SSetOverrideParams_1_2 { bool Enable; - } TSetOverrideParams_1_2; -//*******************************************************************************/ -// Frequency override specific SetOverride params: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Frequency override specific SetOverride params: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SSetFrequencyOverrideParams_1_2 : SSetOverrideParams_1_2 { uint32_t FrequencyMhz; uint32_t Pid; - } TSetFrequencyOverrideParams_1_2; - -//*******************************************************************************/ -// Query override specific SetOverride params: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Query override specific SetOverride params: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SSetQueryOverrideParams_1_2 : SSetOverrideParams_1_2 { - uint32_t Period; // Nanoseconds - + uint32_t Period; // Nanoseconds } TSetQueryOverrideParams_1_2; -//*******************************************************************************/ -// Driver override params: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Driver override params: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SSetDriverOverrideParams_1_2 : SSetOverrideParams_1_2 { uint32_t Value; + } TSetDriverOverrideParams_1_2; - } SSetDriverOverrideParams_1_2; - -//*******************************************************************************/ -// API specific id: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // API specific id: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SApiSpecificId_1_0 { - uint32_t D3D9QueryId; // D3D9 Query ID - uint32_t D3D9Fourcc; // D3D9 FourCC - uint32_t D3D1XQueryId; // D3D1X Query ID - uint32_t D3D1XDevDependentId; // D3D1X device dependent counter ID - const char* D3D1XDevDependentName; // Device dependent counter name - uint32_t OGLQueryIntelId; // Intel OGL query extension ID - const char* OGLQueryIntelName; // Intel OGL query extension name - uint32_t OGLQueryARBTargetId; // ARB OGL Query Target ID - uint32_t OCL; // OCL configuration ID - uint32_t HwConfigId; // Config ID for IO stream - uint32_t placeholder[1]; - + uint32_t D3D9QueryId; // D3D9 Query ID + uint32_t D3D9Fourcc; // D3D9 FourCC + uint32_t D3D1XQueryId; // D3D1X Query ID + uint32_t D3D1XDevDependentId; // D3D1X device dependent counter ID + const char* D3D1XDevDependentName; // Device dependent counter name + uint32_t OGLQueryIntelId; // Intel OGL query extension ID + const char* OGLQueryIntelName; // Intel OGL query extension name + uint32_t OGLQueryARBTargetId; // ARB OGL Query Target ID + uint32_t OCL; // OCL configuration ID + uint32_t HwConfigId; // Config ID for IO stream + uint32_t placeholder[1]; } TApiSpecificId_1_0; -//*******************************************************************************/ -// Global parameters of Metric set: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Global parameters of Metric set: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SMetricSetParams_1_0 { - const char* SymbolName; // For example "Dx11Tessellation" - const char* ShortName; // For example "DX11 Tessellation Metrics Set" - - uint32_t ApiMask; - uint32_t CategoryMask; - - uint32_t RawReportSize; // As in HW - uint32_t QueryReportSize; // As in Query API - - uint32_t MetricsCount; - uint32_t InformationCount; - uint32_t ComplementarySetsCount; - - TApiSpecificId_1_0 ApiSpecificId; - - uint32_t PlatformMask; - //... - + const char* SymbolName; // For example "Dx11Tessellation" + const char* ShortName; // For example "DX11 Tessellation Metrics Set" + uint32_t ApiMask; + uint32_t CategoryMask; + uint32_t RawReportSize; // As in HW + uint32_t QueryReportSize; // As in Query API + uint32_t MetricsCount; + uint32_t InformationCount; + uint32_t ComplementarySetsCount; + TApiSpecificId_1_0 ApiSpecificId; + uint32_t PlatformMask; } TMetricSetParams_1_0; -//*******************************************************************************/ -// GT differenced MetricSet params: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // GT differenced MetricSet params: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SMetricSetParams_1_4 : SMetricSetParams_1_0 { uint32_t GtMask; - } TMetricSetParams_1_4; -//*******************************************************************************/ -// Metric result types: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // AvailabilityEquation differenced MetricSet params: + ////////////////////////////////////////////////////////////////////////////////// + typedef struct SMetricSetParams_1_11 : SMetricSetParams_1_4 + { + const char* AvailabilityEquation; + } TMetricSetParams_1_11; + + ////////////////////////////////////////////////////////////////////////////////// + // Metric result types: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EMetricResultType { RESULT_UINT32, RESULT_UINT64, RESULT_BOOL, RESULT_FLOAT, - // ... RESULT_LAST - } TMetricResultType; -//*******************************************************************************/ -// Metric types: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Metric types: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EMetricType { METRIC_TYPE_DURATION, @@ -485,14 +619,12 @@ namespace MetricsDiscovery METRIC_TYPE_FLAG, METRIC_TYPE_RATIO, METRIC_TYPE_RAW, - // ... METRIC_TYPE_LAST - } TMetricType; -//*******************************************************************************/ -// Information types: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Information types: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EInformationType { INFORMATION_TYPE_REPORT_REASON, @@ -502,14 +634,12 @@ namespace MetricsDiscovery INFORMATION_TYPE_CONTEXT_ID_TAG, INFORMATION_TYPE_SAMPLE_PHASE, INFORMATION_TYPE_GPU_NODE, - // ... INFORMATION_TYPE_LAST - } TInformationType; -//*******************************************************************************/ -// Report reasons: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Report reasons: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EReportReason { REPORT_REASON_UNDEFINED = 0x0000, @@ -519,43 +649,39 @@ namespace MetricsDiscovery REPORT_REASON_INTERNAL_CONTEXT_SWITCH = 0x0008, REPORT_REASON_INTERNAL_GO = 0x0010, REPORT_REASON_INTERNAL_FREQUENCY_CHANGE = 0x0020, + REPORT_REASON_INTERNAL_MMIO_TRIGGER = 0x0040, REPORT_REASON_QUERY_DEFAULT = 0x0100, REPORT_REASON_QUERY_INTERNAL_RESOLVE = 0x0200, REPORT_REASON_QUERY_INTERNAL_CLEAR = 0x0400, - } TReportReason; -//*******************************************************************************/ -// Sample phase: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Sample phase: + ////////////////////////////////////////////////////////////////////////////////// typedef enum ESamplePhase { SAMPLE_PHASE_END, SAMPLE_PHASE_BEGIN, - // ... SAMPLE_PHASE_LAST - } TSamplePhase; -//*******************************************************************************/ -// Gpu Node: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Gpu Node: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EInformationGpuNode { - INFORMATION_GPUNODE_3D = 0, // Available by default on all platform - INFORMATION_GPUNODE_VIDEO = 1, // Available on CTG+ - INFORMATION_GPUNODE_BLT = 2, // Available on GT - INFORMATION_GPUNODE_VE = 3, // Available on HSW+ (VideoEnhancement) - INFORMATION_GPUNODE_VCS2 = 4, // Available on BDW+ GT3+ - INFORMATION_GPUNODE_REAL_MAX = 5, // All nodes beyond this are virtual nodes - they don't have an actual GPU engine - // ... + INFORMATION_GPUNODE_3D = 0, // Available by default on all platform + INFORMATION_GPUNODE_VIDEO = 1, // Available on CTG+ + INFORMATION_GPUNODE_BLT = 2, // Available on GT + INFORMATION_GPUNODE_VE = 3, // Available on HSW+ (VideoEnhancement) + INFORMATION_GPUNODE_VCS2 = 4, // Available on BDW+ GT3+ + INFORMATION_GPUNODE_REAL_MAX = 5, // All nodes beyond this are virtual nodes - they don't have an actual GPU engine INFORMATION_GPUNODE_LAST - } TInformationGpuNode; -//*******************************************************************************/ -// Hardware unit types: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Hardware unit types: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EHwUnitType { HW_UNIT_GPU, @@ -564,605 +690,911 @@ namespace MetricsDiscovery HW_UNIT_SUBSLICE_BANK, HW_UNIT_EU_UNIT, HW_UNIT_UNCORE, - // ... + HW_UNIT_DUALSUBSLICE, HW_UNIT_LAST - } THwUnitType; -//*******************************************************************************/ -// Delta function types: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Delta function types: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EDeltaFunctionType { DELTA_FUNCTION_NULL = 0, DELTA_N_BITS, - DELTA_BOOL_OR, // Logic OR - good for exceptions - DELTA_BOOL_XOR, // Logic XOR - good to check if bits were changed - DELTA_GET_PREVIOUS, // Preserve previous value - DELTA_GET_LAST, // Preserve last value - DELTA_NS_TIME, // Delta for nanosecond timestamps (GPU timestamp wraps at 32 bits but was value multiplied by 80) + DELTA_BOOL_OR, // Logic OR - good for exceptions + DELTA_BOOL_XOR, // Logic XOR - good to check if bits were changed + DELTA_GET_PREVIOUS, // Preserve previous value + DELTA_GET_LAST, // Preserve last value + DELTA_NS_TIME, // Delta for nanosecond timestamps (GPU timestamp wraps at 32 bits but was value multiplied by 80) DELTA_FUNCTION_LAST_1_0 - } TDeltaFunctionType; -//*******************************************************************************/ -// Delta function: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Delta function: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SDeltaFunction_1_0 { - TDeltaFunctionType FunctionType; - union { - uint32_t BitsCount; // Used for DELTA_N_BITS to specify bits count + TDeltaFunctionType FunctionType; + union + { + uint32_t BitsCount; // Used for DELTA_N_BITS to specify bits count }; - } TDeltaFunction_1_0; -//*******************************************************************************/ -// Equation element types: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Equation element types: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EEquationElementType { EQUATION_ELEM_OPERATION, // See TEquationOperation enumeration - - EQUATION_ELEM_RD_BITFIELD, - EQUATION_ELEM_RD_UINT8, - EQUATION_ELEM_RD_UINT16, - EQUATION_ELEM_RD_UINT32, - EQUATION_ELEM_RD_UINT64, - EQUATION_ELEM_RD_FLOAT, - - // Extended RD operation + EQUATION_ELEM_RD_BITFIELD, // + EQUATION_ELEM_RD_UINT8, // + EQUATION_ELEM_RD_UINT16, // + EQUATION_ELEM_RD_UINT32, // + EQUATION_ELEM_RD_UINT64, // + EQUATION_ELEM_RD_FLOAT, // EQUATION_ELEM_RD_40BIT_CNTR, // Assemble 40 bit counter that is in two locations, result in unsigned integer 64b - - EQUATION_ELEM_IMM_UINT64, - EQUATION_ELEM_IMM_FLOAT, + EQUATION_ELEM_IMM_UINT64, // + EQUATION_ELEM_IMM_FLOAT, // EQUATION_ELEM_SELF_COUNTER_VALUE, // Defined by $Self token, the UINT64 result of DeltaFunction for IO or QueryReadEquation EQUATION_ELEM_GLOBAL_SYMBOL, // Defined by $"SymbolName", available in MetricsDevice SymbolTable EQUATION_ELEM_LOCAL_COUNTER_SYMBOL, // Defined by $"SymbolName", refers to counter delta value in the local set EQUATION_ELEM_OTHER_SET_COUNTER_SYMBOL, // Defined by concatenated string of $"setSymbolName/SymbolName", refers to counter // Delta value in the other set - EQUATION_ELEM_LOCAL_METRIC_SYMBOL, // Defined by $$"SymbolName", refers to metric normalized value in the local set EQUATION_ELEM_OTHER_SET_METRIC_SYMBOL, // Defined by concatenated string of $$"setSymbolName/SymbolName", refers to metric // Normalized value in the other set - EQUATION_ELEM_INFORMATION_SYMBOL, // Defined by i$"SymbolName", refers to information value type only - - // Extended types - standard normalization functions EQUATION_ELEM_STD_NORM_GPU_DURATION, // Action is $Self $GpuCoreClocks FDIV 100 FMUL EQUATION_ELEM_STD_NORM_EU_AGGR_DURATION, // Action is $Self $GpuCoreClocks $EuCoresTotalCount UMUL FDIV 100 FMUL - + EQUATION_ELEM_MASK, // EQUATION_ELEM_LAST_1_0 } TEquationElementType; -//*******************************************************************************/ -// Equation operations: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Equation operations: + ////////////////////////////////////////////////////////////////////////////////// typedef enum EEquationOperation { - EQUATION_OPER_RSHIFT, // 64b unsigned integer right shift - EQUATION_OPER_LSHIFT, // 64b unsigned integer left shift - EQUATION_OPER_AND, // Bitwise AND of two unsigned integers, 64b each - EQUATION_OPER_OR, // Bitwise OR of two unsigned integers, 64b each - EQUATION_OPER_XOR, // Bitwise XOR of two unsigned integers, 64b each - EQUATION_OPER_XNOR, // Bitwise XNOR of two unsigned integers, 64b each - EQUATION_OPER_AND_L, // Logical AND (C-like "&&") of two unsigned integers, 64b each, result is true(1) if both values are true(greater than 0) - EQUATION_OPER_EQUALS, // Equality (C-like "==") of two unsigned integers, 64b each, result is true(1) or false(0) - EQUATION_OPER_UADD, // Unsigned integer add, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b - EQUATION_OPER_USUB, // Unsigned integer subtract, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b - EQUATION_OPER_UMUL, // Unsigned integer mul, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b - EQUATION_OPER_UDIV, // Unsigned integer div, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b - EQUATION_OPER_FADD, // Floating point add, arguments are casted to be 32b floating points, result is a 32b float - EQUATION_OPER_FSUB, // Floating point subtract, arguments are casted to be 32b floating points, result is a 32b float - EQUATION_OPER_FMUL, // Floating point multiply, arguments are casted to be 32b floating points, result is a 32b float - EQUATION_OPER_FDIV, // Floating point divide, arguments are casted to be 32b floating points, result is a 32b float - - EQUATION_OPER_UGT, // 64b unsigned integers comparison of is greater than, result is bool true(1) or false(0) - EQUATION_OPER_ULT, // 64b unsigned integers comparison of is less than, result is bool true(1) or false(0) - EQUATION_OPER_UGTE, // 64b unsigned integers comparison of is greater than or equal, result is bool true(1) or false(0) - EQUATION_OPER_ULTE, // 64b unsigned integers comparison of is less than or equal, result is bool true(1) or false(0) - - EQUATION_OPER_FGT, // 32b floating point numbers comparison of is greater than, result is bool true(1) or false(0) - EQUATION_OPER_FLT, // 32b floating point numbers comparison of is less than, result is bool true(1) or false(0) - EQUATION_OPER_FGTE, // 32b floating point numbers comparison of is greater than or equal, result is bool true(1) or false(0) - EQUATION_OPER_FLTE, // 32b floating point numbers comparison of is less than or equal, result is bool true(1) or false(0) - - EQUATION_OPER_UMIN, // Unsigned integer MIN function, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b - EQUATION_OPER_UMAX, // Unsigned integer MAX function, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b - - EQUATION_OPER_FMIN, // Floating point MIN function, arguments are casted to be 32b floating points, result is a 32b float - EQUATION_OPER_FMAX, // Floating point MAX function, arguments are casted to be 32b floating points, result is a 32b float - + EQUATION_OPER_RSHIFT, // 64b unsigned integer right shift + EQUATION_OPER_LSHIFT, // 64b unsigned integer left shift + EQUATION_OPER_AND, // Bitwise AND of two unsigned integers, 64b each + EQUATION_OPER_OR, // Bitwise OR of two unsigned integers, 64b each + EQUATION_OPER_XOR, // Bitwise XOR of two unsigned integers, 64b each + EQUATION_OPER_XNOR, // Bitwise XNOR of two unsigned integers, 64b each + EQUATION_OPER_AND_L, // Logical AND (C-like "&&") of two unsigned integers, 64b each, result is true(1) if both values are true(greater than 0) + EQUATION_OPER_EQUALS, // Equality (C-like "==") of two unsigned integers, 64b each, result is true(1) or false(0) + EQUATION_OPER_UADD, // Unsigned integer add, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b + EQUATION_OPER_USUB, // Unsigned integer subtract, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b + EQUATION_OPER_UMUL, // Unsigned integer mul, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b + EQUATION_OPER_UDIV, // Unsigned integer div, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b + EQUATION_OPER_FADD, // Floating point add, arguments are casted to be 32b floating points, result is a 32b float + EQUATION_OPER_FSUB, // Floating point subtract, arguments are casted to be 32b floating points, result is a 32b float + EQUATION_OPER_FMUL, // Floating point multiply, arguments are casted to be 32b floating points, result is a 32b float + EQUATION_OPER_FDIV, // Floating point divide, arguments are casted to be 32b floating points, result is a 32b float + EQUATION_OPER_UGT, // 64b unsigned integers comparison of is greater than, result is bool true(1) or false(0) + EQUATION_OPER_ULT, // 64b unsigned integers comparison of is less than, result is bool true(1) or false(0) + EQUATION_OPER_UGTE, // 64b unsigned integers comparison of is greater than or equal, result is bool true(1) or false(0) + EQUATION_OPER_ULTE, // 64b unsigned integers comparison of is less than or equal, result is bool true(1) or false(0) + EQUATION_OPER_FGT, // 32b floating point numbers comparison of is greater than, result is bool true(1) or false(0) + EQUATION_OPER_FLT, // 32b floating point numbers comparison of is less than, result is bool true(1) or false(0) + EQUATION_OPER_FGTE, // 32b floating point numbers comparison of is greater than or equal, result is bool true(1) or false(0) + EQUATION_OPER_FLTE, // 32b floating point numbers comparison of is less than or equal, result is bool true(1) or false(0) + EQUATION_OPER_UMIN, // Unsigned integer MIN function, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b + EQUATION_OPER_UMAX, // Unsigned integer MAX function, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b + EQUATION_OPER_FMIN, // Floating point MIN function, arguments are casted to be 32b floating points, result is a 32b float + EQUATION_OPER_FMAX, // Floating point MAX function, arguments are casted to be 32b floating points, result is a 32b float EQUATION_OPER_LAST_1_0 - } TEquationOperation; -//*******************************************************************************/ -// Read params: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Read params: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SReadParams_1_0 { - uint32_t ByteOffset; - uint32_t BitOffset; - uint32_t BitsCount; - uint32_t ByteOffsetExt; - + uint32_t ByteOffset; + uint32_t BitOffset; + uint32_t BitsCount; + uint32_t ByteOffsetExt; } TReadParams_1_0; -//*******************************************************************************/ -// Equation element: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Equation element: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SEquationElement_1_0 { - TEquationElementType Type; + TEquationElementType Type; union { - uint64_t ImmediateUInt64; - float ImmediateFloat; - TEquationOperation Operation; - TReadParams_1_0 ReadParams; + uint64_t ImmediateUInt64; + float ImmediateFloat; + TByteArray_1_0 Mask; + TEquationOperation Operation; + TReadParams_1_0 ReadParams; }; - char* SymbolName; - + char* SymbolName; } TEquationElement_1_0; -/*****************************************************************************\ - -Class: - IEquation_1_0 - -Description: - Abstract interface for the equation object. - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IEquation_1_0 + // + // Description: + // Abstract interface for the equation object. + // + /////////////////////////////////////////////////////////////////////////////// class IEquation_1_0 { public: virtual ~IEquation_1_0(); - virtual uint32_t GetEquationElementsCount( void ); virtual TEquationElement_1_0* GetEquationElement( uint32_t index ); }; -//*******************************************************************************/ -// Global parameters of Metric: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Global parameters of Metric: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SMetricParams_1_0 { - uint32_t IdInSet; // Position in the set - uint32_t GroupId; // Specific metric group id - const char* SymbolName; // Symbol name, used in equations - const char* ShortName; // Consistent metric name, not changed platform to platform - const char* GroupName; // VertexShader for example - const char* LongName; // Hint about the metric shown to users - - const char* DxToOglAlias; // To replace DX pixels with OGL fragments - - uint32_t UsageFlagsMask; - uint32_t ApiMask; - - TMetricResultType ResultType; - const char* MetricResultUnits; - TMetricType MetricType; - - uint64_t LowWatermark; // Low watermark for hotspot indication (USAGE_FLAG_INDICATE only) - uint64_t HighWatermark; // High watermark for hotspot indication (USAGE_FLAG_INDICATE only) - - THwUnitType HwUnitType; - - // Read equation specification for IO stream (accessing raw values potentially spread in report in several locations) - IEquation_1_0* IoReadEquation; - // Read equation specification for query (accessing calculated delta values) - IEquation_1_0* QueryReadEquation; - - TDeltaFunction_1_0 DeltaFunction; - - // Normalization equation to get normalized value to bytes transfered or to a percentage of utilization - IEquation_1_0* NormEquation; - - // To calculate metrics max value as a function of other metrics and device parameters (e.g. 100 for percentage) - IEquation_1_0* MaxValueEquation; - + uint32_t IdInSet; // Position in set (may change after SetApiFiltering) + uint32_t GroupId; // Specific metric group id + const char* SymbolName; // Symbol name, used in equations + const char* ShortName; // Consistent metric name, not changed platform to platform + const char* GroupName; // VertexShader for example + const char* LongName; // Hint about the metric shown to users + const char* DxToOglAlias; // To replace DX pixels with OGL fragments + uint32_t UsageFlagsMask; // + uint32_t ApiMask; // + TMetricResultType ResultType; // + const char* MetricResultUnits; // + TMetricType MetricType; // + uint64_t LowWatermark; // Low watermark for hotspot indication (USAGE_FLAG_INDICATE only) + uint64_t HighWatermark; // High watermark for hotspot indication (USAGE_FLAG_INDICATE only) + THwUnitType HwUnitType; // + IEquation_1_0* IoReadEquation; // Read equation specification for IO stream (accessing raw values potentially spread in report in several locations) + IEquation_1_0* QueryReadEquation; // Read equation specification for query (accessing calculated delta values) + TDeltaFunction_1_0 DeltaFunction; // + IEquation_1_0* NormEquation; // Normalization equation to get normalized value to bytes transfered or to a percentage of utilization + IEquation_1_0* MaxValueEquation; // To calculate metrics max value as a function of other metrics and device parameters (e.g. 100 for percentage) } TMetricParams_1_0; -//*******************************************************************************/ -// Global parameters of Information: -//*******************************************************************************/ + ////////////////////////////////////////////////////////////////////////////////// + // Global parameters of Information: + ////////////////////////////////////////////////////////////////////////////////// typedef struct SInformationParams_1_0 { - uint32_t IdInSet; // Position in the set - const char* SymbolName; // Symbol name, used in equations - const char* ShortName; // Consistent name, not changed platform to platform - const char* GroupName; // Some more global context of the information - const char* LongName; // Hint about the information shown to users - - uint32_t ApiMask; - - TInformationType InfoType; - const char* InfoUnits; - - // Read equation specification for IO stream (accessing raw values potentially spread in report in several locations) - IEquation_1_0* IoReadEquation; - // Read equation specification for query (accessing calculated delta values) - IEquation_1_0* QueryReadEquation; - - TDeltaFunction_1_0 OverflowFunction; - + uint32_t IdInSet; // Position in set (may change after SetApiFiltering) + const char* SymbolName; // Symbol name, used in equations + const char* ShortName; // Consistent name, not changed platform to platform + const char* GroupName; // Some more global context of the information + const char* LongName; // Hint about the information shown to users + uint32_t ApiMask; // + TInformationType InfoType; // + const char* InfoUnits; // + IEquation_1_0* IoReadEquation; // Read equation specification for IO stream (accessing raw values potentially spread in report in several locations) + IEquation_1_0* QueryReadEquation; // Read equation specification for query (accessing calculated delta values) + TDeltaFunction_1_0 OverflowFunction; // } TInformationParams_1_0; -/*****************************************************************************\ - -Class: - IInformation_1_0 - -Description: - Abstract interface for the measurement information parameter. - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IInformation_1_0 + // + // Descriptions: + // Abstract interface for the measurement information parameter. + // + /////////////////////////////////////////////////////////////////////////////// class IInformation_1_0 { public: virtual ~IInformation_1_0(); - virtual TInformationParams_1_0* GetParams(); }; -/*****************************************************************************\ - -Class: - IMetric_1_0 - -Description: - Abstract interface for the metric that is sampled. - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IMetric_1_0 + // + // Description: + // Abstract interface for the metric that is sampled. + // + /////////////////////////////////////////////////////////////////////////////// class IMetric_1_0 { public: virtual ~IMetric_1_0(); - - virtual TMetricParams_1_0* GetParams(); + virtual TMetricParams_1_0* GetParams(); }; -/*****************************************************************************\ - -Class: - IMetricSet_1_0 - -Description: - Abstract interface for the metric sets mapping to different HW configuration that should be used - exclusively to each other metric set in the concurrent group. - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IMetricSet_1_0 + // + // Description: + // Abstract interface for the metric sets mapping to different HW + // configuration that should be used exclusively to each other + // metric set in the concurrent group. + // + // New: + // - GetParams: + // - GetMetric: To get particular metric + // - GetInformation: To get particular information about measurement + // - GetComplementaryMetricSet: Below proposal to address multi-passes at the set level + // - Activate: To enable this configuration before query instance is created + // - Deactivate: To disable this configuration after query instance is created + // - AddCustomMetric: To add an additional custom metric to this set + // + /////////////////////////////////////////////////////////////////////////////// class IMetricSet_1_0 { public: virtual ~IMetricSet_1_0(); virtual TMetricSetParams_1_0* GetParams( void ); - - // To get particular metric virtual IMetric_1_0* GetMetric( uint32_t index ); - - // To get particular information about measurement virtual IInformation_1_0* GetInformation( uint32_t index ); - - // Below proposal to address multi-passes at the set level virtual IMetricSet_1_0* GetComplementaryMetricSet( uint32_t index ); - - // To enable this configuration before query instance is created virtual TCompletionCode Activate( void ); - - // To disable this configuration after query instance is created virtual TCompletionCode Deactivate( void ); - - // To add an additional custom metric to this set virtual IMetric_1_0* AddCustomMetric( - const char* symbolName, const char* shortName, const char* groupName, const char* longName, const char* dxToOglAlias, - uint32_t usageFlagsMask, uint32_t apiMask, TMetricResultType resultType, const char* resultUnits, TMetricType metricType, - int64_t loWatermark, int64_t hiWatermark, THwUnitType hwType, const char* ioReadEquation, const char* deltaFunction, - const char* queryReadEquation, const char* normalizationEquation, const char* maxValueEquation, const char* signalName ); + const char* symbolName, + const char* shortName, + const char* groupName, + const char* longName, + const char* dxToOglAlias, + uint32_t usageFlagsMask, + uint32_t apiMask, + TMetricResultType resultType, + const char* resultUnits, + TMetricType metricType, + int64_t loWatermark, + int64_t hiWatermark, + THwUnitType hwType, + const char* ioReadEquation, + const char* deltaFunction, + const char* queryReadEquation, + const char* normalizationEquation, + const char* maxValueEquation, + const char* signalName ); }; -/*****************************************************************************\ - -Class: - IMetricSet_1_1 - -Description: - Updated 1.0 version to use with 1.1 interface version. - Introduces an ability to calculate metrics from raw data. - - New: - - SetApiFiltering - - CalculateMetrics - - CalculateIoMeasurementInformation - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IMetricSet_1_1 + // + // Description: + // Updated 1.0 version to use with 1.1 interface version. + // Introduces an ability to calculate metrics from raw data. + // + // New: + // - SetApiFiltering: To filter available metrics/information for the given API. Use TMetricApiType to build the mask. + // - CalculateMetrics: To calculate normalized metrics/information from the raw data. + // - CalculateIoMeasurementInformation: To calculate additional information for stream measurements. + // + /////////////////////////////////////////////////////////////////////////////// class IMetricSet_1_1 : public IMetricSet_1_0 { public: virtual ~IMetricSet_1_1(); - - // To filter available metrics/information for the given API. Use TMetricApiType to build the mask. - virtual TCompletionCode SetApiFiltering( uint32_t apiMask ); - - // To calculate normalized metrics/information from the raw data. - virtual TCompletionCode CalculateMetrics( const unsigned char* rawData, uint32_t rawDataSize, TTypedValue_1_0* out, - uint32_t outSize, uint32_t* outReportCount, bool enableContextFiltering ); - - // To calculate additional information for stream measurements. - virtual TCompletionCode CalculateIoMeasurementInformation( TTypedValue_1_0* out, uint32_t outSize ); + virtual TCompletionCode SetApiFiltering( uint32_t apiMask ); + virtual TCompletionCode CalculateMetrics( const uint8_t* rawData, uint32_t rawDataSize, TTypedValue_1_0* out, uint32_t outSize, uint32_t* outReportCount, bool enableContextFiltering ); + virtual TCompletionCode CalculateIoMeasurementInformation( TTypedValue_1_0* out, uint32_t outSize ); }; -/*****************************************************************************\ - -Class: - IMetricSet_1_4 - -Description: - Updated 1.1 version to use with 1.4 interface version. - Extends set params with gtType information. - - Updates: - - GetParams - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IMetricSet_1_4 + // + // Description: + // Updated 1.1 version to use with 1.4 interface version. + // Extends set params with gtType information. + // + // Updates: + // - GetParams + // + /////////////////////////////////////////////////////////////////////////////// class IMetricSet_1_4 : public IMetricSet_1_1 { public: virtual ~IMetricSet_1_4(); - virtual TMetricSetParams_1_4* GetParams( void ); }; -/*****************************************************************************\ - -Class: - IMetricSet_1_5 - -Description: - Updated 1.4 version to use with 1.5 interface version. - Adds an ability to calculate MaxValueEquations (maximal value) for each metric. - Param 'enableContextFiltering' becomes deprecated. - - Updates: - - GetComplementaryMetricSet - - CalculateMetrics - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IMetricSet_1_5 + // + // Description: + // Updated 1.4 version to use with 1.5 interface version. + // Adds an ability to calculate MaxValueEquations (maximal value) for each metric. + // Param 'enableContextFiltering' becomes deprecated. + // + // Updates: + // - GetComplementaryMetricSet: Update to 1.5 interface + // - CalculateMetrics: CalculateMetrics extended with max values calculation. + // optional param 'outMaxValues' should have a memory + // for at least 'MetricCount * RawReportCount' values, can be nullptr. + // + /////////////////////////////////////////////////////////////////////////////// class IMetricSet_1_5 : public IMetricSet_1_4 { public: - // Update to 1.5 interface - virtual IMetricSet_1_5* GetComplementaryMetricSet( uint32_t index ); - - // CalculateMetrics extended with max values calculation. - // Optional param 'outMaxValues' should have a memory for at least 'MetricCount * RawReportCount' values, can be NULL. - using IMetricSet_1_1::CalculateMetrics; - virtual TCompletionCode CalculateMetrics( const unsigned char* rawData, uint32_t rawDataSize, TTypedValue_1_0* out, - uint32_t outSize, uint32_t* outReportCount, TTypedValue_1_0* outMaxValues, uint32_t outMaxValuesSize ); + using IMetricSet_1_1::CalculateMetrics; // To avoid hiding by 1.5 interface function + virtual IMetricSet_1_5* GetComplementaryMetricSet( uint32_t index ); + virtual TCompletionCode CalculateMetrics( + const uint8_t* rawData, + uint32_t rawDataSize, + TTypedValue_1_0* out, + uint32_t outSize, + uint32_t* outReportCount, + TTypedValue_1_0* outMaxValues, + uint32_t outMaxValuesSize ); }; -/*****************************************************************************\ - -Class: - IConcurrentGroup_1_0 - -Description: - Abstract interface for the metrics groups that can be collected concurrently to another group. + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IMetricSet_1_11 + // + // Description: + // Updated 1.5 version to use with 1.11 interface version. + // Extends set params with AvailabilityEquation information. + // + // Updates: + // - GetParams + // + /////////////////////////////////////////////////////////////////////////////// + class IMetricSet_1_11 : public IMetricSet_1_5 + { + public: + virtual ~IMetricSet_1_11(); + virtual TMetricSetParams_1_11* GetParams( void ); + }; -\*****************************************************************************/ + // IConcurrentGroup_1_0 + // + // Description: + // Abstract interface for the metrics groups that can be collected + // concurrently to another group. + // + /////////////////////////////////////////////////////////////////////////////// class IConcurrentGroup_1_0 { public: virtual ~IConcurrentGroup_1_0(); - virtual TConcurrentGroupParams_1_0* GetParams( void ); - virtual IMetricSet_1_0* GetMetricSet( uint32_t index ); - - virtual TCompletionCode OpenIoStream( IMetricSet_1_0* metricSet, uint32_t processId, uint32_t* nsTimerPeriod, uint32_t* oaBufferSize ); - virtual TCompletionCode ReadIoStream( uint32_t* reportsCount, char* reportData, uint32_t readFlags ); - virtual TCompletionCode CloseIoStream( void ); - virtual TCompletionCode WaitForReports( uint32_t milliseconds ); - virtual IInformation_1_0* GetIoMeasurementInformation( uint32_t index ); - virtual IInformation_1_0* GetIoGpuContextInformation( uint32_t index ); + virtual IMetricSet_1_0* GetMetricSet( uint32_t index ); + virtual TCompletionCode OpenIoStream( IMetricSet_1_0* metricSet, uint32_t processId, uint32_t* nsTimerPeriod, uint32_t* oaBufferSize ); + virtual TCompletionCode ReadIoStream( uint32_t* reportsCount, char* reportData, uint32_t readFlags ); + virtual TCompletionCode CloseIoStream( void ); + virtual TCompletionCode WaitForReports( uint32_t milliseconds ); + virtual IInformation_1_0* GetIoMeasurementInformation( uint32_t index ); + virtual IInformation_1_0* GetIoGpuContextInformation( uint32_t index ); }; -/*****************************************************************************\ - -Class: - IConcurrentGroup_1_1 - -Description: - Updated 1.0 version to use with 1.1 interface version. - - Updates: - - GetMetricSet - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IConcurrentGroup_1_1 + // + // Description: + // Updated 1.0 version to use with 1.1 interface version. + // + // Updates: + // - GetMetricSet: Update to 1.1 interface + // + /////////////////////////////////////////////////////////////////////////////// class IConcurrentGroup_1_1 : public IConcurrentGroup_1_0 { public: - // Update to 1.1 interface - virtual IMetricSet_1_1* GetMetricSet( uint32_t index ); + virtual IMetricSet_1_1* GetMetricSet( uint32_t index ); }; -/*****************************************************************************\ - -Class: - IConcurrentGroup_1_3 - -Description: - Updated 1.1 version to use with 1.3 interface version. - Introduces setting Stream Sampling Type. - - New: - - SetIoStreamSamplingType - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IConcurrentGroup_1_3 + // + // Description: + // Updated 1.1 version to use with 1.3 interface version.Introduces setting Stream Sampling Type. + // + // New: + // - SetIoStreamSamplingType: To set sampling type during IoStream measurements + // + /////////////////////////////////////////////////////////////////////////////// class IConcurrentGroup_1_3 : public IConcurrentGroup_1_1 { public: - // To set sampling type during IoStream measurements - virtual TCompletionCode SetIoStreamSamplingType( TSamplingType type ); + virtual TCompletionCode SetIoStreamSamplingType( TSamplingType type ); }; -/*****************************************************************************\ - -Class: - IConcurrentGroup_1_5 - -Description: - Updated 1.3 version to use with 1.5 interface version. - - Updates: - - GetMetricSet - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IConcurrentGroup_1_5 + // + // Description: + // Updated 1.3 version to use with 1.5 interface version. + // + // Updates: + // - GetMetricSet: Update to 1.5 interface + // + /////////////////////////////////////////////////////////////////////////////// class IConcurrentGroup_1_5 : public IConcurrentGroup_1_3 { public: - // Update to 1.5 interface - virtual IMetricSet_1_5* GetMetricSet( uint32_t index ); + virtual IMetricSet_1_5* GetMetricSet( uint32_t index ); }; -/*****************************************************************************\ - -Class: - IOverride_1_2 - -Description: - Abstract interface for Metrics Device overrides. + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IConcurrentGroup_1_11 + // + // Description: + // Updated 1.5 version to use with 1.11 interface version. + // + // Updates: + // - GetMetricSet: Update to 1.11 interface + // + /////////////////////////////////////////////////////////////////////////////// + class IConcurrentGroup_1_11 : public IConcurrentGroup_1_5 + { + public: + virtual IMetricSet_1_11* GetMetricSet( uint32_t index ); + }; -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IOverride_1_2 + // + // Description: + // Abstract interface for Metrics Device overrides. + // + // New: + // - GetParams: To get this Override params + // - SetOverride: To enable/disable this Override + // + /////////////////////////////////////////////////////////////////////////////// class IOverride_1_2 { public: virtual ~IOverride_1_2(); - - // To get this Override params - virtual TOverrideParams_1_2* GetParams( void ); - - // To enable/disable this Override - virtual TCompletionCode SetOverride( TSetOverrideParams_1_2* params, uint32_t paramsSize ); + virtual TOverrideParams_1_2* GetParams( void ); + virtual TCompletionCode SetOverride( TSetOverrideParams_1_2* params, uint32_t paramsSize ); }; -/*****************************************************************************\ - -Class: - IMetricsDevice_1_0 - -Description: - Abstract interface for the GPU metrics root object. - -\*****************************************************************************/ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IMetricsDevice_1_0 + // + // Description: + // Abstract interface for the GPU metrics root object. + // + // New: + // - GetParams: To get MetricsDevice params + // - GetConcurrentGroup: Child objects are of IConcurrentGroup + // - GetGlobalSymbol: To get GlobalSymbol at the given index + // - GetGlobalSymbolValueByName: To get GlobalSymbol with the given name + // - GetLastError: To get last error from TCompletionCode enum + // - GetGpuCpuTimestamps: To get both GPU and CPU timestamp at the same time + // + /////////////////////////////////////////////////////////////////////////////// class IMetricsDevice_1_0 { public: virtual ~IMetricsDevice_1_0(); - - // To get MetricsDevice params virtual TMetricsDeviceParams_1_0* GetParams( void ); - - // Child objects are of IConcurrentGroup - virtual IConcurrentGroup_1_0* GetConcurrentGroup( uint32_t index ); - - // To get GlobalSymbol at the given index - virtual TGlobalSymbol_1_0* GetGlobalSymbol( uint32_t index ); - - // To get GlobalSymbol with the given name - virtual TTypedValue_1_0* GetGlobalSymbolValueByName( const char* name ); - - // To get last error from TCompletionCode enum - virtual TCompletionCode GetLastError( void ); - - // To get both GPU and CPU timestamp at the same time - virtual TCompletionCode GetGpuCpuTimestamps( uint64_t* gpuTimestampNs, uint64_t* cpuTimestampNs, - uint32_t* cpuId ); + virtual IConcurrentGroup_1_0* GetConcurrentGroup( uint32_t index ); + virtual TGlobalSymbol_1_0* GetGlobalSymbol( uint32_t index ); + virtual TTypedValue_1_0* GetGlobalSymbolValueByName( const char* name ); + virtual TCompletionCode GetLastError( void ); + virtual TCompletionCode GetGpuCpuTimestamps( uint64_t* gpuTimestampNs, uint64_t* cpuTimestampNs, uint32_t* cpuId ); }; -/*****************************************************************************\ - -Class: - IMetricsDevice_1_1 + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IMetricsDevice_1_1 + // + // Description: + // Updated 1.0 version to use with 1.1 interface version. + // + // Updates: + // - GetConcurrentGroup: Update to 1.1 interface + // + /////////////////////////////////////////////////////////////////////////////// + class IMetricsDevice_1_1 : public IMetricsDevice_1_0 + { + public: + virtual IConcurrentGroup_1_1* GetConcurrentGroup( uint32_t index ); + }; -Description: - Updated 1.0 version to use with 1.1 interface version. + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IMetricsDevice_1_2 + // + // Description: + // Updated 1.1 version to use with 1.2 interface version. + // Introduces an interface for getting overrides. + // + // Updates: + // - GetParams: Update to 1.2 interface + // + // New: + // - GetOverride: To get override at the given index + // - GetOverrideByName: To get override with the given name + // + /////////////////////////////////////////////////////////////////////////////// + class IMetricsDevice_1_2 : public IMetricsDevice_1_1 + { + public: + // Updates. + virtual TMetricsDeviceParams_1_2* GetParams( void ); - Updates: - - GetConcurrentGroup + // New. + virtual IOverride_1_2* GetOverride( uint32_t index ); + virtual IOverride_1_2* GetOverrideByName( const char* symbolName ); + }; -\*****************************************************************************/ - class IMetricsDevice_1_1 : public IMetricsDevice_1_0 + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IMetricsDevice_1_5 + // + // Description: + // Updated 1.2 version to use with 1.5 interface version. + // + // Updates: + // - GetConcurrentGroup: Update to 1.5 interface + // + /////////////////////////////////////////////////////////////////////////////// + class IMetricsDevice_1_5 : public IMetricsDevice_1_2 { public: - // Update to 1.1 interface - virtual IConcurrentGroup_1_1* GetConcurrentGroup( uint32_t index ); + virtual IConcurrentGroup_1_5* GetConcurrentGroup( uint32_t index ); }; -/*****************************************************************************\ + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IMetricsDevice_1_10 + // + // Description: + // Updated 1.5 version to use with 1.10 interface version. + // + // Updates: + // - GetGpuCpuTimestamps: Update to 1.10 interface + // + /////////////////////////////////////////////////////////////////////////////// + class IMetricsDevice_1_10 : public IMetricsDevice_1_5 + { + public: + using IMetricsDevice_1_0::GetGpuCpuTimestamps; // To avoid hiding by 1.10 interface function + virtual TCompletionCode GetGpuCpuTimestamps( uint64_t* gpuTimestampNs, uint64_t* cpuTimestampNs, uint32_t* cpuId, uint64_t* correlationIndicatorNs ); + }; -Class: - IMetricsDevice_1_2 + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IMetricsDevice_1_11 + // + // Description: + // Updated 1.10 version to use with 1.11 interface version. + // + // Updates: + // - GetConcurrentGroup: Update to 1.11 interface + // + /////////////////////////////////////////////////////////////////////////////// + class IMetricsDevice_1_11 : public IMetricsDevice_1_10 + { + public: + virtual IConcurrentGroup_1_11* GetConcurrentGroup( uint32_t index ); + }; -Description: - Updated 1.1 version to use with 1.2 interface version. - Introduces an interface for getting overrides. + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IAdapter_1_6 + // + // Description: + // Abstract interface for GPU adapter. + // + // New: + // - GetParams: To get this adapter params + // - Reset: To reset this adapter state + // - OpenMetricsDevice + // - OpenMetricsDeviceFromFile + // - CloseMetricsDevice + // - SaveMetricsDeviceToFile + // + /////////////////////////////////////////////////////////////////////////////// + class IAdapter_1_6 + { + public: + virtual ~IAdapter_1_6(); + virtual const TAdapterParams_1_6* GetParams( void ) const; + virtual TCompletionCode Reset(); + virtual TCompletionCode OpenMetricsDevice( IMetricsDevice_1_5** metricsDevice ); + virtual TCompletionCode OpenMetricsDeviceFromFile( const char* fileName, void* openParams, IMetricsDevice_1_5** metricsDevice ); + virtual TCompletionCode CloseMetricsDevice( IMetricsDevice_1_5* metricsDevice ); + virtual TCompletionCode SaveMetricsDeviceToFile( const char* fileName, void* saveParams, IMetricsDevice_1_5* metricsDevice ); + }; - Updates: - - GetParams - New: - - GetOverride - - GetOverrideByName + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IAdapter_1_8 + // + // Description: + // Abstract interface for GPU adapter. + // + // Updates: + // - GetParams: Update to 1.8 interface + // + /////////////////////////////////////////////////////////////////////////////// + class IAdapter_1_8 : public IAdapter_1_6 + { + public: + virtual const TAdapterParams_1_8* GetParams( void ) const; + }; -\*****************************************************************************/ - class IMetricsDevice_1_2 : public IMetricsDevice_1_1 + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IAdapter_1_9 + // + // Description: + // Abstract interface for GPU adapter. + // + // Updates: + // - GetParams: Update to 1.9 interface + // + // New: + // - GetSubDeviceParams: To get sub device parameters + // - GetEngineParams: To get engine parameters + // - OpenMetricsSubDevice: To open metrics device on given sub device + // - OpenMetricsSubDeviceFromFile: To open metrics device from file on given sub device + // + /////////////////////////////////////////////////////////////////////////////// + class IAdapter_1_9 : public IAdapter_1_8 { public: - // Update returned params - virtual TMetricsDeviceParams_1_2* GetParams( void ); + // Updates. + virtual const TAdapterParams_1_9* GetParams( void ) const; + + // New. + virtual const TSubDeviceParams_1_9* GetSubDeviceParams( const uint32_t subDeviceIndex ); + virtual const TEngineParams_1_9* GetEngineParams( const uint32_t subDeviceIndex, const uint32_t engineIndex ); + virtual TCompletionCode OpenMetricsSubDevice( const uint32_t subDeviceIndex, IMetricsDevice_1_5** metricsDevice ); + virtual TCompletionCode OpenMetricsSubDeviceFromFile( const uint32_t subDeviceIndex, const char* fileName, void* openParams, IMetricsDevice_1_5** metricsDevice ); + }; - // To get override at the given index - virtual IOverride_1_2* GetOverride( uint32_t index ); + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IAdapter_1_10 + // + // Description: + // Abstract interface for GPU adapter. + // + // Updates: + // - OpenMetricsDevice: Update to 1.10 interface + // - OpenMetricsDeviceFromFile: Update to 1.10 interface + // - OpenMetricsSubDevice: Update to 1.10 interface + // - OpenMetricsSubDeviceFromFile: Update to 1.10 interface + // + /////////////////////////////////////////////////////////////////////////////// + class IAdapter_1_10 : public IAdapter_1_9 + { + public: + using IAdapter_1_6::OpenMetricsDevice; + using IAdapter_1_6::OpenMetricsDeviceFromFile; + using IAdapter_1_9::OpenMetricsSubDevice; + using IAdapter_1_9::OpenMetricsSubDeviceFromFile; + + virtual TCompletionCode OpenMetricsDevice( IMetricsDevice_1_10** metricsDevice ); + virtual TCompletionCode OpenMetricsDeviceFromFile( const char* fileName, void* openParams, IMetricsDevice_1_10** metricsDevice ); + virtual TCompletionCode OpenMetricsSubDevice( const uint32_t subDeviceIndex, IMetricsDevice_1_10** metricsDevice ); + virtual TCompletionCode OpenMetricsSubDeviceFromFile( const uint32_t subDeviceIndex, const char* fileName, void* openParams, IMetricsDevice_1_10** metricsDevice ); + }; - // To get override with the given name - virtual IOverride_1_2* GetOverrideByName( const char* symbolName ); + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IAdapter_1_11 + // + // Description: + // Abstract interface for GPU adapter. + // + // Updates: + // - OpenMetricsDevice: Update to 1.11 interface + // - OpenMetricsDeviceFromFile: Update to 1.11 interface + // - OpenMetricsSubDevice: Update to 1.11 interface + // - OpenMetricsSubDeviceFromFile: Update to 1.11 interface + // + // New: + // - SaveMetricsDeviceToFile To save metrics device with required minimal api version + // + /////////////////////////////////////////////////////////////////////////////// + class IAdapter_1_11 : public IAdapter_1_10 + { + public: + // Updates. + using IAdapter_1_10::OpenMetricsDevice; + using IAdapter_1_10::OpenMetricsDeviceFromFile; + using IAdapter_1_10::OpenMetricsSubDevice; + using IAdapter_1_10::OpenMetricsSubDeviceFromFile; + + virtual TCompletionCode OpenMetricsDevice( IMetricsDevice_1_11** metricsDevice ); + virtual TCompletionCode OpenMetricsDeviceFromFile( const char* fileName, void* openParams, IMetricsDevice_1_11** metricsDevice ); + virtual TCompletionCode OpenMetricsSubDevice( const uint32_t subDeviceIndex, IMetricsDevice_1_11** metricsDevice ); + virtual TCompletionCode OpenMetricsSubDeviceFromFile( const uint32_t subDeviceIndex, const char* fileName, void* openParams, IMetricsDevice_1_11** metricsDevice ); + + // New. + using IAdapter_1_6::SaveMetricsDeviceToFile; + virtual TCompletionCode SaveMetricsDeviceToFile( const char* fileName, void* saveParams, IMetricsDevice_1_11* metricsDevice, const uint32_t minMajorApiVersion, const uint32_t minMinorApiVersion ); }; -/*****************************************************************************\ + // IAdapterGroup_1_6 + // + // Description: + // Abstract interface for the GPU adapters root object. + // + // New: + // - GetParams: To get this adapter group params + // - GetAdapter: To enumerate available GPU adapters + // - Close: To close this adapter group + // + /////////////////////////////////////////////////////////////////////////////// + class IAdapterGroup_1_6 + { + public: + virtual ~IAdapterGroup_1_6(); + virtual const TAdapterGroupParams_1_6* GetParams( void ) const; + virtual IAdapter_1_6* GetAdapter( uint32_t index ); + virtual TCompletionCode Close(); + }; -Class: - IMetricsDevice_1_5 + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IAdapterGroup_1_8 + // + // Description: + // Abstract interface for the GPU adapters root object. + // + // Updates: + // - GetAdapter: Update to 1.8 interface + // + /////////////////////////////////////////////////////////////////////////////// + class IAdapterGroup_1_8 : public IAdapterGroup_1_6 + { + public: + virtual IAdapter_1_8* GetAdapter( uint32_t index ); + }; -Description: - Updated 1.2 version to use with 1.5 interface version. + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IAdapterGroup_1_9 + // + // Description: + // Abstract interface for the GPU adapters root object. + // + // Updates: + // - GetAdapter: Update to 1.9 interface + // + /////////////////////////////////////////////////////////////////////////////// + class IAdapterGroup_1_9 : public IAdapterGroup_1_8 + { + public: + virtual IAdapter_1_9* GetAdapter( uint32_t index ); + }; - Updates: - - GetConcurrentGroup + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IAdapterGroup_1_10 + // + // Description: + // Abstract interface for the GPU adapters root object. + // + // Updates: + // - GetAdapter: Update to 1.10 interface + // + /////////////////////////////////////////////////////////////////////////////// + class IAdapterGroup_1_10 : public IAdapterGroup_1_9 + { + public: + virtual IAdapter_1_10* GetAdapter( uint32_t index ); + }; -\*****************************************************************************/ - class IMetricsDevice_1_5 : public IMetricsDevice_1_2 + /////////////////////////////////////////////////////////////////////////////// + // + // Class: + // IAdapterGroup_1_11 + // + // Description: + // Abstract interface for the GPU adapters root object. + // + // Updates: + // - GetAdapter: Update to 1.11 interface + // + /////////////////////////////////////////////////////////////////////////////// + class IAdapterGroup_1_11 : public IAdapterGroup_1_10 { public: - // Update to 1.5 interface - virtual IConcurrentGroup_1_5* GetConcurrentGroup( uint32_t index ); + virtual IAdapter_1_11* GetAdapter( uint32_t index ); }; + ////////////////////////////////////////////////////////////////////////////////// + // Latest interfaces and typedef structs versions: + ////////////////////////////////////////////////////////////////////////////////// + using IAdapterGroupLatest = IAdapterGroup_1_11; + using IAdapterLatest = IAdapter_1_11; + using IConcurrentGroupLatest = IConcurrentGroup_1_11; + using IEquationLatest = IEquation_1_0; + using IInformationLatest = IInformation_1_0; + using IMetricLatest = IMetric_1_0; + using IMetricSetLatest = IMetricSet_1_11; + using IMetricsDeviceLatest = IMetricsDevice_1_11; + using IOverrideLatest = IOverride_1_2; + using TAdapterGroupParamsLatest = TAdapterGroupParams_1_6; + using TAdapterIdLatest = TAdapterId_1_6; + using TAdapterIdLuidLatest = TAdapterIdLuid_1_6; + using TAdapterIdMajorMinorLatest = TAdapterIdMajorMinor_1_6; + using TAdapterParamsLatest = TAdapterParams_1_9; + using TApiSpecificIdLatest = TApiSpecificId_1_0; + using TApiVersionLatest = TApiVersion_1_0; + using TByteArrayLatest = TByteArray_1_0; + using TConcurrentGroupParamsLatest = TConcurrentGroupParams_1_0; + using TDeltaFunctionLatest = TDeltaFunction_1_0; + using TEngineIdClassInstanceLatest = TEngineIdClassInstance_1_9; + using TEngineIdLatest = TEngineId_1_9; + using TEngineParamsLatest = TEngineParams_1_9; + using TEquationElementLatest = TEquationElement_1_0; + using TGlobalSymbolLatest = TGlobalSymbol_1_0; + using TInformationParamsLatest = TInformationParams_1_0; + using TMetricParamsLatest = TMetricParams_1_0; + using TMetricSetParamsLatest = TMetricSetParams_1_11; + using TMetricsDeviceParamsLatest = TMetricsDeviceParams_1_2; + using TOverrideParamsLatest = TOverrideParams_1_2; + using TReadParamsLatest = TReadParams_1_0; + using TSetDriverOverrideParamsLatest = TSetDriverOverrideParams_1_2; + using TSetFrequencyOverrideParamsLatest = TSetFrequencyOverrideParams_1_2; + using TSetOverrideParamsLatest = TSetOverrideParams_1_2; + using TSetQueryOverrideParamsLatest = TSetQueryOverrideParams_1_2; + using TSubDeviceParamsLatest = TSubDeviceParams_1_9; + using TTypedValueLatest = TTypedValue_1_0; + #ifdef __cplusplus - extern "C" { + extern "C" + { #endif - // Factory functions - typedef TCompletionCode (MD_STDCALL *OpenMetricsDevice_fn)(IMetricsDevice_1_5** device); - typedef TCompletionCode (MD_STDCALL *OpenMetricsDeviceFromFile_fn)(const char* fileName, void* openParams, IMetricsDevice_1_5** device); - typedef TCompletionCode (MD_STDCALL *CloseMetricsDevice_fn)(IMetricsDevice_1_5* device); - typedef TCompletionCode (MD_STDCALL *SaveMetricsDeviceToFile_fn)(const char* fileName, void* saveParams, IMetricsDevice_1_5* device); + // [Current] Factory functions + typedef TCompletionCode( MD_STDCALL* OpenAdapterGroup_fn )( IAdapterGroupLatest** adapterGroup ); + + // [Legacy] Factory functions + typedef TCompletionCode( MD_STDCALL* OpenMetricsDevice_fn )( IMetricsDeviceLatest** metricsDevice ); + typedef TCompletionCode( MD_STDCALL* OpenMetricsDeviceFromFile_fn )( const char* fileName, void* openParams, IMetricsDeviceLatest** metricsDevice ); + typedef TCompletionCode( MD_STDCALL* CloseMetricsDevice_fn )( IMetricsDeviceLatest* metricsDevice ); + typedef TCompletionCode( MD_STDCALL* SaveMetricsDeviceToFile_fn )( const char* fileName, void* saveParams, IMetricsDeviceLatest* metricsDevice ); #ifdef __cplusplus } #endif -}; -#endif // __METRICS_DISCOVERY_H_ +}; // namespace MetricsDiscovery diff --git a/intercept/src/controls.h b/intercept/src/controls.h index 6bc903a8..cbde3146 100644 --- a/intercept/src/controls.h +++ b/intercept/src/controls.h @@ -75,6 +75,7 @@ CLI_CONTROL( bool, DevicePerformanceTimelineLogging, false, "If s CLI_CONTROL( std::string, DevicePerfCounterLibName, "", "Full path to MDAPI shared library. If not set, the default MDAPI library will be used.") CLI_CONTROL( bool, DevicePerfCounterEventBasedSampling, false, "If set to a nonzero value and DevicePerfCounterCustom is set, the Intercept Layer for OpenCL Applications will enable Intel GPU Performance Counters to track the minimum, maximum, and average performance counter deltas for each OpenCL command. This operation may be fairly intrusive and may have side effects; in particular it forces all command queues to be created with PROFILING_ENABLED and may increment the reference count for application events. This feature will only function if the Intercept Layer for OpenCL Applications is built with MDAPI support." ) CLI_CONTROL( bool, DevicePerfCounterTimeBasedSampling, false, "If set to a nonzero value and DevicePerfCounterCustom is set, the Intercept Layer for OpenCL Applications will enable Intel GPU Performance Counters to track performance counter deltas at regular time intervals. This operation may be fairly intrusive and may have side effects. This feature will only function if the Intercept Layer for OpenCL Applications is built with MDAPI support." ) +CLI_CONTROL( uint32_t, DevicePerfCounterAdapterIndex, 0, "Select which MDAPI device to report performance counters." ) CLI_CONTROL( std::string, DevicePerfCounterCustom, "", "If set, the Intercept Layer for OpenCL Applications will collect MDAPI metrics for the Metric Set corresponding to this value for each OpenCL command. Frequently used Metric Sets include: ComputeBasic, ComputeExtended, L3_1, Sampler. The output file has the potential to be very big depending on the work load. This operation may be fairly intrusive and may have side effects; in particular it forces all command queues to be created with PROFILING_ENABLED and may increment the reference count for application events. When the process exits, this information will be included in the file \"clintercept_perfcounter_dump_.txt\". This feature will only function if the Intercept Layer for OpenCL Applications is built with MDAPI support." ) CLI_CONTROL( std::string, DevicePerfCounterFile, "", "Full path to a custom MDAPI file. This can be used to add custom Metric Sets." ) CLI_CONTROL( bool, DevicePerfCounterTiming, false, "If set to a nonzero value and DevicePerfCounterEventBasedSampling is set, the Intercept Layer for OpenCL Applications will report the average Intel GPU Performance Counters for each OpenCL command. When the process exits, this information will be included in the file \"clIntercept_report.txt\". This feature will only function if the Intercept Layer for OpenCL Applications is built with MDAPI support." )