diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c881e500c..02dbbb5fe5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -211,6 +211,24 @@ if(DISABLE_AUB_STREAM) unset(AUB_STREAM_DIR) endif() +# Metrics Library +get_filename_component(METRICS_LIBRARY_HEADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party${BRANCH_DIR_SUFFIX}/metrics_library" ABSOLUTE) +if(IS_DIRECTORY ${METRICS_LIBRARY_HEADERS_DIR}) + message(STATUS "Metrics Library dir: ${METRICS_LIBRARY_HEADERS_DIR}") + include_directories(${NEO_SOURCE_DIR}/third_party${BRANCH_DIR_SUFFIX}/metrics_library) +else() + message(FATAL_ERROR "Metrics Library headers not available!") +endif() + +# Metrics Discovery +get_filename_component(METRICS_DISCOVERY_HEADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party${BRANCH_DIR_SUFFIX}/metrics_discovery" ABSOLUTE) +if(IS_DIRECTORY ${METRICS_DISCOVERY_HEADERS_DIR}) + message(STATUS "Metrics Discovery dir: ${METRICS_DISCOVERY_HEADERS_DIR}") + include_directories(${NEO_SOURCE_DIR}/third_party${BRANCH_DIR_SUFFIX}/metrics_discovery) +else() + message(FATAL_ERROR "Metrics Discovery headers not available!") +endif() + get_filename_component(I915_INCLUDES_DIR "${NEO_SOURCE_DIR}/third_party${BRANCH_DIR_SUFFIX}/uapi" ABSOLUTE) message(STATUS "i915 includes dir: ${I915_INCLUDES_DIR}") @@ -486,33 +504,6 @@ endmacro() link_directories(${NEO__GMM_LIBRARY_PATH}) -# Instrumentation detection -if(NOT DEFINED INSTRUMENTATION_LIB_NAME) - if(DEFINED INSTRUMENTATION_SOURCE_DIR) - get_filename_component(INSTRUMENTATION_SOURCE_DIR "${INSTRUMENTATION_SOURCE_DIR}" ABSOLUTE) - else() - get_filename_component(INSTRUMENTATION_SOURCE_DIR_tmp "${NEO_SOURCE_DIR}/../instrumentation" ABSOLUTE) - if(IS_DIRECTORY "${INSTRUMENTATION_SOURCE_DIR_tmp}") - set(INSTRUMENTATION_SOURCE_DIR "${INSTRUMENTATION_SOURCE_DIR_tmp}") - endif() - endif() - if(IS_DIRECTORY "${INSTRUMENTATION_SOURCE_DIR}") - message(STATUS "Instrumentation source dir is: ${INSTRUMENTATION_SOURCE_DIR}") - set(INSTRUMENTATION_INCLUDE_PATHS ${INSTRUMENTATION_SOURCE_DIR}/inc) - set(HAVE_INSTRUMENTATION TRUE) - else() - message(STATUS "Instrumentation source dir not found") - set(HAVE_INSTRUMENTATION FALSE) - endif() -else() - if(TARGET ${INSTRUMENTATION_LIB_NAME}) - set(INSTRUMENTATION_INCLUDE_PATHS $) - set(HAVE_INSTRUMENTATION TRUE) - else() - message(STATUS "Instrumentation target not found. ${INSTRUMENTATION_LIB_NAME} is not a valid target") - set(HAVE_INSTRUMENTATION FALSE) - endif() -endif() if(NOT DISABLE_LIBVA) # LibVA detection @@ -822,15 +813,6 @@ if (MSVC) include_directories(${NEO_SOURCE_DIR}/opencl/source/sharings/gl/windows/include) endif() -if(HAVE_INSTRUMENTATION) - set(NEO__INSTRUMENTATION_DIR_SUFFIX ${BRANCH_DIR_SUFFIX}) - message(STATUS "Instrumentation include dirs: ${INSTRUMENTATION_INCLUDE_PATHS}") - include_directories(${INSTRUMENTATION_INCLUDE_PATHS}) -else() - set(NEO__INSTRUMENTATION_DIR_SUFFIX "/") -endif() -include_directories(${NEO_SOURCE_DIR}/opencl/source/instrumentation${NEO__INSTRUMENTATION_DIR_SUFFIX}) - # Define where to put binaries set(TargetDir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) if(MSVC) diff --git a/Jenkinsfile b/Jenkinsfile index e765ad311b..68e27df365 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,5 @@ #!groovy dependenciesRevision='3232e5d67b5c3dd2323f13bede3ab1558b5aa4b9-1401' strategy='EQUAL' -allowedCD=221 +allowedCD=220 allowedF=11 diff --git a/README.md b/README.md index 5b006412fa..db11084b0c 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,10 @@ Directly linking to the runtime library is not supported: * GmmLib - https://github.com/intel/gmmlib * Intel Graphics Compiler - https://github.com/intel/intel-graphics-compiler +In addition, to enable performance counters support, the following packages are needed: +* Intel Metrics Discovery - https://github.com/intel/metrics-discovery +* Intel Metrics Library for MDAPI - https://github.com/intel/metrics-library + ## How to provide feedback By default, please submit an issue using native github.com [interface](https://github.com/intel/compute-runtime/issues). diff --git a/level_zero/CMakeLists.txt b/level_zero/CMakeLists.txt index 09cf11f3c2..380780db77 100644 --- a/level_zero/CMakeLists.txt +++ b/level_zero/CMakeLists.txt @@ -192,7 +192,6 @@ if(BUILD_WITH_L0 AND "${NEO_BITS}" STREQUAL "64") ${COMPUTE_RUNTIME_DIR}/opencl/source/dll/get_devices.cpp ${COMPUTE_RUNTIME_DIR}/opencl/source/dll/source_level_debugger.cpp ${COMPUTE_RUNTIME_DIR}/opencl/source/helpers/built_ins_helper.cpp - ${COMPUTE_RUNTIME_DIR}/opencl/source/instrumentation/instrumentation.cpp ) if(WIN32) @@ -400,14 +399,6 @@ if(UNIX) ) endif() -if(HAVE_INSTRUMENTATION) - target_link_libraries(${TARGET_NAME_L0} - ${INSTRUMENTATION_LIB_NAME}) - target_include_directories(${TARGET_NAME_L0} BEFORE PRIVATE - ${INSTRUMENTATION_INCLUDE_PATH} - ) -endif() - create_source_tree(${TARGET_NAME_L0} ${L0_ROOT_DIR}/..) set_property(TARGET ${TARGET_NAME_L0} APPEND_STRING PROPERTY COMPILE_FLAGS ${ASAN_FLAGS}) diff --git a/level_zero/tools/source/metrics/CMakeLists.txt b/level_zero/tools/source/metrics/CMakeLists.txt index 466a95edb1..17f95f5208 100644 --- a/level_zero/tools/source/metrics/CMakeLists.txt +++ b/level_zero/tools/source/metrics/CMakeLists.txt @@ -7,16 +7,11 @@ set(L0_SRCS_TOOLS_METRICS ) -if(HAVE_INSTRUMENTATION) - list(APPEND L0_SRCS_TOOLS_METRICS - ${CMAKE_CURRENT_SOURCE_DIR}/metric.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/metric_enumeration_imp.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/metric_tracer_imp.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/metric_query_imp.cpp) -else() - list(APPEND L0_SRCS_TOOLS_METRICS - ${CMAKE_CURRENT_SOURCE_DIR}/metric_stubs.cpp) -endif() +list(APPEND L0_SRCS_TOOLS_METRICS + ${CMAKE_CURRENT_SOURCE_DIR}/metric.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/metric_enumeration_imp.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/metric_tracer_imp.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/metric_query_imp.cpp) if(UNIX) add_subdirectory(linux) diff --git a/level_zero/tools/source/metrics/linux/CMakeLists.txt b/level_zero/tools/source/metrics/linux/CMakeLists.txt index 83a473a7da..8fdf50a8d5 100644 --- a/level_zero/tools/source/metrics/linux/CMakeLists.txt +++ b/level_zero/tools/source/metrics/linux/CMakeLists.txt @@ -4,18 +4,16 @@ # SPDX-License-Identifier: MIT # -if(HAVE_INSTRUMENTATION) - set(L0_SRCS_TOOLS_LINUX - ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt - ${CMAKE_CURRENT_SOURCE_DIR}/os_metric_query_imp_linux.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/os_metric_enumeration_imp_linux.cpp) +set(L0_SRCS_TOOLS_LINUX + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/os_metric_query_imp_linux.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/os_metric_enumeration_imp_linux.cpp) - if(UNIX) - target_sources(${L0_STATIC_LIB_NAME} - PRIVATE - ${L0_SRCS_TOOLS_LINUX} - ) -endif() +if(UNIX) +target_sources(${L0_STATIC_LIB_NAME} + PRIVATE + ${L0_SRCS_TOOLS_LINUX} +) # Make our source files visible to parent set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_LINUX ${L0_SRCS_TOOLS_LINUX}) diff --git a/level_zero/tools/source/metrics/metric.cpp b/level_zero/tools/source/metrics/metric.cpp index 5fce4fb163..5847036b47 100644 --- a/level_zero/tools/source/metrics/metric.cpp +++ b/level_zero/tools/source/metrics/metric.cpp @@ -16,8 +16,6 @@ #include "level_zero/tools/source/metrics/metric_enumeration_imp.h" #include "level_zero/tools/source/metrics/metric_query_imp.h" -#include "instrumentation.h" - #include #include diff --git a/level_zero/tools/source/metrics/metric_enumeration_imp.h b/level_zero/tools/source/metrics/metric_enumeration_imp.h index 0564610f17..cc57feef8f 100644 --- a/level_zero/tools/source/metrics/metric_enumeration_imp.h +++ b/level_zero/tools/source/metrics/metric_enumeration_imp.h @@ -7,24 +7,12 @@ #pragma once -#include "level_zero/tools/source/metrics/metric.h" -// Ignore function-overload warning in clang -#if defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Woverloaded-virtual" -#elif defined(__linux__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Woverloaded-virtual" -#endif -#include "common/instrumentation/api/metrics_discovery_api.h" -#if defined(__clang__) -#pragma clang diagnostic pop -#elif defined(__linux__) -#pragma GCC diagnostic pop -#endif - #include "shared/source/os_interface/os_library.h" +#include "level_zero/tools/source/metrics/metric.h" + +#include "metrics_discovery_api.h" + #include namespace L0 { @@ -44,7 +32,7 @@ struct MetricEnumeration { ze_result_t initialize(); virtual ze_result_t openMetricsDiscovery(); - virtual ze_result_t cleanupMetricsDiscovery(); + ze_result_t cleanupMetricsDiscovery(); ze_result_t cacheMetricInformation(); ze_result_t cacheMetricGroup(MetricsDiscovery::IMetricSet_1_5 &metricSet, diff --git a/level_zero/tools/source/metrics/metric_query_imp.h b/level_zero/tools/source/metrics/metric_query_imp.h index 5198ab5eef..686cb0e3cd 100644 --- a/level_zero/tools/source/metrics/metric_query_imp.h +++ b/level_zero/tools/source/metrics/metric_query_imp.h @@ -8,8 +8,6 @@ #pragma once #include "level_zero/tools/source/metrics/metric.h" -#include "instrumentation.h" - #include #include diff --git a/level_zero/tools/source/metrics/metric_stubs.cpp b/level_zero/tools/source/metrics/metric_stubs.cpp deleted file mode 100644 index 1a12b56b73..0000000000 --- a/level_zero/tools/source/metrics/metric_stubs.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2020 Intel Corporation - * - * SPDX-License-Identifier: MIT - * - */ - -#include "shared/source/os_interface/os_library.h" - -#include "level_zero/core/source/device/device.h" -#include "level_zero/core/source/driver/driver.h" -#include "level_zero/core/source/driver/driver_handle_imp.h" -#include "level_zero/source/inc/ze_intel_gpu.h" -#include "level_zero/tools/source/metrics/metric.h" -#include "level_zero/tools/source/metrics/metric_query_imp.h" - -#include "instrumentation.h" - -#include -#include - -namespace L0 { - -MetricQueryPool *MetricQueryPool::create(zet_device_handle_t hDevice, zet_metric_group_handle_t hMetricGroup, const zet_metric_query_pool_desc_t &desc) { return nullptr; } -MetricQueryPool *MetricQueryPool::fromHandle(zet_metric_query_pool_handle_t handle) { return nullptr; } - -ze_result_t metricQueryPoolCreate(zet_device_handle_t hDevice, zet_metric_group_handle_t hMetricGroup, const zet_metric_query_pool_desc_t *pDesc, - zet_metric_query_pool_handle_t *phMetricQueryPool) { - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - -ze_result_t metricQueryPoolDestroy(zet_metric_query_pool_handle_t hMetricQueryPool) { - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - -ze_result_t MetricQuery::appendMemoryBarrier(CommandList &commandList) { - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; -} -ze_result_t MetricQuery::appendTracerMarker(CommandList &commandList, - zet_metric_tracer_handle_t hMetricTracer, uint32_t value) { - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - -MetricQuery *MetricQuery::fromHandle(zet_metric_query_handle_t handle) { return nullptr; } - -void MetricContext::enableMetricApi(ze_result_t &result) { - result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; - return; -} - -std::unique_ptr MetricContext::create(Device &device) { - return nullptr; -} - -bool MetricContext::isMetricApiAvailable() { - return false; -} - -ze_result_t metricGroupGet(zet_device_handle_t hDevice, uint32_t *pCount, zet_metric_group_handle_t *phMetricGroups) { - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - -ze_result_t metricGet(zet_metric_group_handle_t hMetricGroup, uint32_t *pCount, zet_metric_handle_t *phMetrics) { - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - -ze_result_t metricTracerOpen(zet_device_handle_t hDevice, zet_metric_group_handle_t hMetricGroup, - zet_metric_tracer_desc_t *pDesc, ze_event_handle_t hNotificationEvent, - zet_metric_tracer_handle_t *phMetricTracer) { - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - -} // namespace L0 diff --git a/level_zero/tools/source/metrics/windows/CMakeLists.txt b/level_zero/tools/source/metrics/windows/CMakeLists.txt index c7b0226915..a62020b94f 100644 --- a/level_zero/tools/source/metrics/windows/CMakeLists.txt +++ b/level_zero/tools/source/metrics/windows/CMakeLists.txt @@ -4,18 +4,16 @@ # SPDX-License-Identifier: MIT # -if(HAVE_INSTRUMENTATION) - set(L0_SRCS_TOOLS_WINDOWS - ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt - ${CMAKE_CURRENT_SOURCE_DIR}/os_metric_query_imp_windows.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/os_metric_enumeration_imp_windows.cpp) +set(L0_SRCS_TOOLS_WINDOWS + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/os_metric_query_imp_windows.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/os_metric_enumeration_imp_windows.cpp) - if(WIN32) - target_sources(${L0_STATIC_LIB_NAME} - PRIVATE - ${L0_SRCS_TOOLS_WINDOWS} - ) -endif() +if(WIN32) +target_sources(${L0_STATIC_LIB_NAME} + PRIVATE + ${L0_SRCS_TOOLS_WINDOWS} +) # Make our source files visible to parent set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_WINDOWS ${L0_SRCS_TOOLS_WINDOWS}) diff --git a/opencl/source/CMakeLists.txt b/opencl/source/CMakeLists.txt index f651cc4aa3..5d0a9d3182 100644 --- a/opencl/source/CMakeLists.txt +++ b/opencl/source/CMakeLists.txt @@ -22,7 +22,6 @@ endif() hide_subdir(builtin_kernels_simulation) hide_subdir(dll) -hide_subdir(instrumentation) add_library(${NEO_STATIC_LIB_NAME} STATIC EXCLUDE_FROM_ALL ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt @@ -31,7 +30,6 @@ add_library(${NEO_STATIC_LIB_NAME} STATIC EXCLUDE_FROM_ALL ) add_subdirectories() -add_subdirectory(instrumentation${NEO__INSTRUMENTATION_DIR_SUFFIX}) include(enable_gens.cmake) # Enable SSE4/AVX2 options for files that need them diff --git a/opencl/source/gen11/enable_family_full_ocl_gen11.cpp b/opencl/source/gen11/enable_family_full_ocl_gen11.cpp index ec8e7b9427..cc36722e4c 100644 --- a/opencl/source/gen11/enable_family_full_ocl_gen11.cpp +++ b/opencl/source/gen11/enable_family_full_ocl_gen11.cpp @@ -12,9 +12,6 @@ #include "opencl/source/command_stream/tbx_command_stream_receiver_hw.h" #include "opencl/source/device_queue/device_queue_hw.h" -#ifdef HAVE_INSTRUMENTATION -#include "opencl/source/event/perf_counter.h" -#endif #include "opencl/source/mem_obj/buffer.h" #include "opencl/source/mem_obj/image.h" #include "opencl/source/sampler/sampler.h" diff --git a/opencl/source/instrumentation/.clang-tidy b/opencl/source/instrumentation/.clang-tidy deleted file mode 100644 index 7575d9207d..0000000000 --- a/opencl/source/instrumentation/.clang-tidy +++ /dev/null @@ -1,40 +0,0 @@ ---- -Checks: 'clang-diagnostic-*,clang-analyzer-*,google-default-arguments,readability-identifier-naming,modernize-use-override,modernize-use-default-member-init,-clang-analyzer-alpha*' -# WarningsAsErrors: '.*' -HeaderFilterRegex: '/runtime/|/core/|/offline_compiler/' -AnalyzeTemporaryDtors: false -CheckOptions: - - key: google-readability-braces-around-statements.ShortStatementLines - value: '1' - - key: google-readability-function-size.StatementThreshold - value: '800' - - key: google-readability-namespace-comments.ShortNamespaceLines - value: '10' - - key: google-readability-namespace-comments.SpacesBeforeComments - value: '2' - - key: readability-identifier-naming.MethodCase - value: camelBack - - key: readability-identifier-naming.ParameterCase - value: camelBack - - key: readability-identifier-naming.StructMemberCase - value: CamelCase - - key: readability-identifier-naming.ClassMemberCase - value: CamelCase - - key: readability-identifier-naming.ClassMethodCase - value: camelBack - - key: modernize-loop-convert.MaxCopySize - value: '16' - - key: modernize-loop-convert.MinConfidence - value: reasonable - - key: modernize-loop-convert.NamingStyle - value: CamelCase - - key: modernize-pass-by-value.IncludeStyle - value: llvm - - key: modernize-replace-auto-ptr.IncludeStyle - value: llvm - - key: modernize-use-nullptr.NullMacros - value: 'NULL' - - key: modernize-use-default-member-init.UseAssignment - value: '1' -... - diff --git a/opencl/source/instrumentation/CMakeLists.txt b/opencl/source/instrumentation/CMakeLists.txt deleted file mode 100644 index 94ac76fd86..0000000000 --- a/opencl/source/instrumentation/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# -# Copyright (C) 2018-2020 Intel Corporation -# -# SPDX-License-Identifier: MIT -# - -set(RUNTIME_SRCS_INSTRUMENTATION - ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt - ${CMAKE_CURRENT_SOURCE_DIR}/instrumentation.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/instrumentation.h -) -target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_INSTRUMENTATION}) -set_property(GLOBAL PROPERTY RUNTIME_SRCS_INSTRUMENTATION ${RUNTIME_SRCS_INSTRUMENTATION}) diff --git a/opencl/source/instrumentation/instrumentation.cpp b/opencl/source/instrumentation/instrumentation.cpp deleted file mode 100644 index c3af48eab8..0000000000 --- a/opencl/source/instrumentation/instrumentation.cpp +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (C) 2017-2020 Intel Corporation - * - * SPDX-License-Identifier: MIT - * - */ - -#include "instrumentation.h" - -namespace NEO { -const bool haveInstrumentation = false; -} // namespace NEO diff --git a/opencl/source/instrumentation/instrumentation.h b/opencl/source/instrumentation/instrumentation.h deleted file mode 100644 index 81c0e9c284..0000000000 --- a/opencl/source/instrumentation/instrumentation.h +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (C) 2017-2020 Intel Corporation - * - * SPDX-License-Identifier: MIT - * - */ - -#pragma once - -#include - -namespace NEO { -extern const bool haveInstrumentation; -} // namespace NEO - -namespace MetricsLibraryApi { -// Dummy macros. -#define ML_STDCALL -#define METRICS_LIBRARY_CONTEXT_CREATE_1_0 "create" -#define METRICS_LIBRARY_CONTEXT_DELETE_1_0 "delete" - -// Dummy enumerators. -enum class ClientApi : uint32_t { OpenCL }; -enum class ClientGen : uint32_t { Unknown, - Gen9, - Gen11, - Gen12 }; -enum class ValueType : uint32_t { Uint32, - Last }; -enum class GpuConfigurationActivationType : uint32_t { Tbs, - EscapeCode }; -enum class ObjectType : uint32_t { QueryHwCounters, - MarkerStreamUser, - OverrideFlushCaches, - ConfigurationHwCountersUser, - ConfigurationHwCountersOa }; -enum class ParameterType : uint32_t { QueryHwCountersReportApiSize, - QueryHwCountersReportGpuSize }; -enum class StatusCode : uint32_t { Failed, - IncorrectObject, - Success }; -enum class GpuCommandBufferType : uint32_t { Render, - Compute }; - -enum class ClientOptionsType : uint32_t { - Compute -}; - -// Dummy handles. -struct Handle { - void *data; - bool IsValid() const { return data != nullptr; } // NOLINT -}; -struct QueryHandle_1_0 : Handle {}; -struct ConfigurationHandle_1_0 : Handle {}; -struct ContextHandle_1_0 : Handle {}; - -// Dummy structures. -struct ClientCallbacks_1_0 {}; - -struct ClientDataWindows_1_0 { - void *Device; - void *Adapter; - void *Escape; - bool KmdInstrumentationEnabled; -}; - -struct ClientDataLinux_1_0 { - void *Reserved; -}; - -struct ClientOptionsComputeData_1_0 { - bool Asynchronous; -}; - -struct ClientOptionsData_1_0 { - ClientOptionsType Type; - ClientOptionsComputeData_1_0 Compute; -}; - -struct ClientData_1_0 { - union { - ClientDataWindows_1_0 Windows; - ClientDataLinux_1_0 Linux; - }; - ClientOptionsData_1_0 *ClientOptions; - uint32_t ClientOptionsCount; -}; - -struct ConfigurationActivateData_1_0 { - GpuConfigurationActivationType Type; -}; - -struct ClientType_1_0 { - ClientApi Api; - ClientGen Gen; -}; - -struct TypedValue_1_0 { - uint32_t ValueUInt32; - ValueType Type; -}; - -struct GpuMemory_1_0 { - uint64_t GpuAddress; - void *CpuAddress; -}; - -struct CommandBufferQueryHwCounters_1_0 { - QueryHandle_1_0 Handle; - ConfigurationHandle_1_0 HandleUserConfiguration; - bool Begin; - uint32_t Slot; -}; - -struct CommandBufferMarkerStreamUser_1_0 { - uint32_t Value; -}; - -struct CommandBufferOverride_1_0 { - bool Enable; -}; - -struct CommandBufferSize_1_0 { - uint32_t GpuMemorySize; -}; - -struct ConfigurationCreateData_1_0 { - ContextHandle_1_0 HandleContext; - ObjectType Type; -}; - -struct CommandBufferData_1_0 { - ContextHandle_1_0 HandleContext; - ObjectType CommandsType; - GpuCommandBufferType Type; - GpuMemory_1_0 Allocation; - void *Data; - uint32_t Size; - CommandBufferQueryHwCounters_1_0 QueryHwCounters; - CommandBufferMarkerStreamUser_1_0 MarkerStreamUser; - CommandBufferOverride_1_0 Override; -}; - -struct QueryCreateData_1_0 { - ContextHandle_1_0 HandleContext; - ObjectType Type; - uint32_t Slots; -}; - -struct GetReportQuery_1_0 { - QueryHandle_1_0 Handle; - - uint32_t Slot; - uint32_t SlotsCount; - - uint32_t DataSize; - void *Data; -}; - -struct GetReportData_1_0 { - ObjectType Type; - GetReportQuery_1_0 Query; -}; - -struct ContextCreateData_1_0 { - ClientData_1_0 *ClientData; - ClientCallbacks_1_0 *ClientCallbacks; - struct Interface_1_0 *Api; -}; - -// Dummy functions. -using ContextCreateFunction_1_0 = StatusCode(ML_STDCALL *)(ClientType_1_0 clientType, struct ContextCreateData_1_0 *createData, ContextHandle_1_0 *handle); -using ContextDeleteFunction_1_0 = StatusCode(ML_STDCALL *)(const ContextHandle_1_0 handle); -using GetParameterFunction_1_0 = StatusCode(ML_STDCALL *)(const ParameterType parameter, ValueType *type, TypedValue_1_0 *value); -using CommandBufferGetFunction_1_0 = StatusCode(ML_STDCALL *)(const CommandBufferData_1_0 *data); -using CommandBufferGetSizeFunction_1_0 = StatusCode(ML_STDCALL *)(const CommandBufferData_1_0 *data, CommandBufferSize_1_0 *size); -using QueryCreateFunction_1_0 = StatusCode(ML_STDCALL *)(const QueryCreateData_1_0 *createData, QueryHandle_1_0 *handle); -using QueryDeleteFunction_1_0 = StatusCode(ML_STDCALL *)(const QueryHandle_1_0 handle); -using ConfigurationCreateFunction_1_0 = StatusCode(ML_STDCALL *)(const ConfigurationCreateData_1_0 *createData, ConfigurationHandle_1_0 *handle); -using ConfigurationActivateFunction_1_0 = StatusCode(ML_STDCALL *)(const ConfigurationHandle_1_0 handle, const ConfigurationActivateData_1_0 *activateData); -using ConfigurationDeactivateFunction_1_0 = StatusCode(ML_STDCALL *)(const ConfigurationHandle_1_0 handle); -using ConfigurationDeleteFunction_1_0 = StatusCode(ML_STDCALL *)(const ConfigurationHandle_1_0 handle); -using GetDataFunction_1_0 = StatusCode(ML_STDCALL *)(GetReportData_1_0 *data); - -// Dummy interface. -struct Interface_1_0 { - GetParameterFunction_1_0 GetParameter; - - CommandBufferGetFunction_1_0 CommandBufferGet; - CommandBufferGetSizeFunction_1_0 CommandBufferGetSize; - - QueryCreateFunction_1_0 QueryCreate; - QueryDeleteFunction_1_0 QueryDelete; - - ConfigurationCreateFunction_1_0 ConfigurationCreate; - ConfigurationActivateFunction_1_0 ConfigurationActivate; - ConfigurationDeactivateFunction_1_0 ConfigurationDeactivate; - ConfigurationDeleteFunction_1_0 ConfigurationDelete; - - GetDataFunction_1_0 GetData; -}; -}; // namespace MetricsLibraryApi \ No newline at end of file diff --git a/opencl/source/os_interface/metrics_library.h b/opencl/source/os_interface/metrics_library.h index 50cf2250a7..34d8ebde82 100644 --- a/opencl/source/os_interface/metrics_library.h +++ b/opencl/source/os_interface/metrics_library.h @@ -9,7 +9,7 @@ #include "shared/source/os_interface/os_library.h" -#include "instrumentation.h" +#include "metrics_library_api_1_0.h" #include diff --git a/opencl/test/unit_test/os_interface/linux/hw_info_config_linux_tests.cpp b/opencl/test/unit_test/os_interface/linux/hw_info_config_linux_tests.cpp index a4822b061e..1cfb79ce60 100644 --- a/opencl/test/unit_test/os_interface/linux/hw_info_config_linux_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/hw_info_config_linux_tests.cpp @@ -435,7 +435,7 @@ TEST_F(HwInfoConfigTestLinuxDummy, givenInstrumentationForHardwareIsEnabledOrDis pInHwInfo.capabilityTable.instrumentationEnabled = true; ret = hwConfig.configureHwInfo(&pInHwInfo, &outHwInfo, osInterface); ASSERT_EQ(0, ret); - EXPECT_TRUE(outHwInfo.capabilityTable.instrumentationEnabled == haveInstrumentation); + EXPECT_TRUE(outHwInfo.capabilityTable.instrumentationEnabled); } TEST_F(HwInfoConfigTestLinuxDummy, givenGttSizeReturnedWhenInitializingHwInfoThenSetSvmFtr) { diff --git a/opencl/test/unit_test/os_interface/mock_performance_counters.h b/opencl/test/unit_test/os_interface/mock_performance_counters.h index 0b89d16f4d..c5ee2b50a9 100644 --- a/opencl/test/unit_test/os_interface/mock_performance_counters.h +++ b/opencl/test/unit_test/os_interface/mock_performance_counters.h @@ -14,8 +14,6 @@ #include "opencl/test/unit_test/mocks/mock_context.h" #include "opencl/test/unit_test/mocks/mock_device.h" -#include "instrumentation.h" - namespace NEO { ////////////////////////////////////////////////////// diff --git a/opencl/test/unit_test/os_interface/windows/hw_info_config_win_tests.cpp b/opencl/test/unit_test/os_interface/windows/hw_info_config_win_tests.cpp index 317c6455ab..13352a87f0 100644 --- a/opencl/test/unit_test/os_interface/windows/hw_info_config_win_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/hw_info_config_win_tests.cpp @@ -16,8 +16,6 @@ #include "opencl/test/unit_test/mocks/mock_execution_environment.h" #include "test.h" -#include "instrumentation.h" - namespace NEO { template <> @@ -101,7 +99,7 @@ TEST_F(HwInfoConfigTestWindows, givenInstrumentationForHardwareIsEnabledOrDisabl outHwInfo.capabilityTable.instrumentationEnabled = true; ret = hwConfig.configureHwInfo(&pInHwInfo, &outHwInfo, osInterface.get()); ASSERT_EQ(0, ret); - EXPECT_TRUE(outHwInfo.capabilityTable.instrumentationEnabled == haveInstrumentation); + EXPECT_TRUE(outHwInfo.capabilityTable.instrumentationEnabled); } HWTEST_F(HwInfoConfigTestWindows, givenFtrIaCoherencyFlagWhenConfiguringHwInfoThenSetCoherencySupportCorrectly) { diff --git a/shared/source/helpers/hw_helper_base.inl b/shared/source/helpers/hw_helper_base.inl index 43fde761b1..1ab8635a9f 100644 --- a/shared/source/helpers/hw_helper_base.inl +++ b/shared/source/helpers/hw_helper_base.inl @@ -20,8 +20,6 @@ #include "opencl/source/helpers/dispatch_info.h" #include "opencl/source/helpers/hardware_commands_helper.h" -#include "instrumentation.h" - namespace NEO { template diff --git a/shared/source/os_interface/linux/hw_info_config.cpp b/shared/source/os_interface/linux/hw_info_config.cpp index 4bd3c42965..6b37655e88 100644 --- a/shared/source/os_interface/linux/hw_info_config.cpp +++ b/shared/source/os_interface/linux/hw_info_config.cpp @@ -17,8 +17,6 @@ #include "shared/source/os_interface/linux/os_interface.h" #include "shared/source/utilities/cpu_info.h" -#include "instrumentation.h" - #include namespace NEO { @@ -155,9 +153,6 @@ int HwInfoConfig::configureHwInfo(const HardwareInfo *inHwInfo, HardwareInfo *ou hwHelper.adjustDefaultEngineType(outHwInfo); outHwInfo->capabilityTable.defaultEngineType = getChosenEngineType(*outHwInfo); - outHwInfo->capabilityTable.instrumentationEnabled = - (outHwInfo->capabilityTable.instrumentationEnabled && haveInstrumentation); - outHwInfo->capabilityTable.ftrRenderCompressedBuffers = false; outHwInfo->capabilityTable.ftrRenderCompressedImages = false; drm->checkQueueSliceSupport(); diff --git a/shared/source/os_interface/windows/hw_info_config.cpp b/shared/source/os_interface/windows/hw_info_config.cpp index 61a4745fad..6160f9f1b6 100644 --- a/shared/source/os_interface/windows/hw_info_config.cpp +++ b/shared/source/os_interface/windows/hw_info_config.cpp @@ -14,8 +14,6 @@ #include "shared/source/helpers/hw_info.h" #include "shared/source/memory_manager/memory_constants.h" -#include "instrumentation.h" - namespace NEO { HwInfoConfig *hwInfoConfigFactory[IGFX_MAX_PRODUCT] = {}; @@ -37,9 +35,6 @@ int HwInfoConfig::configureHwInfo(const HardwareInfo *inHwInfo, HardwareInfo *ou static_cast(outHwInfo->featureTable.ftrGpGpuMidBatchPreempt)); outHwInfo->capabilityTable.requiredPreemptionSurfaceSize = outHwInfo->gtSystemInfo.CsrSizeInMb * MemoryConstants::megaByte; - outHwInfo->capabilityTable.instrumentationEnabled = - (outHwInfo->capabilityTable.instrumentationEnabled && haveInstrumentation); - auto &kmdNotifyProperties = outHwInfo->capabilityTable.kmdNotifyProperties; KmdNotifyHelper::overrideFromDebugVariable(DebugManager.flags.OverrideEnableKmdNotify.get(), kmdNotifyProperties.enableKmdNotify); KmdNotifyHelper::overrideFromDebugVariable(DebugManager.flags.OverrideKmdNotifyDelayMicroseconds.get(), kmdNotifyProperties.delayKmdNotifyMicroseconds); diff --git a/third_party/metrics_discovery/.revision b/third_party/metrics_discovery/.revision new file mode 100644 index 0000000000..7ba7c122e5 --- /dev/null +++ b/third_party/metrics_discovery/.revision @@ -0,0 +1 @@ +0928b82f6242217637c3a89d01eb630c55a52ce7 \ No newline at end of file diff --git a/third_party/metrics_discovery/LICENSE.md b/third_party/metrics_discovery/LICENSE.md new file mode 100644 index 0000000000..367d7c20ab --- /dev/null +++ b/third_party/metrics_discovery/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019, 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: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +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. \ No newline at end of file diff --git a/third_party/metrics_discovery/README.md b/third_party/metrics_discovery/README.md new file mode 100644 index 0000000000..95836d9453 --- /dev/null +++ b/third_party/metrics_discovery/README.md @@ -0,0 +1,68 @@ +# Intel(R) Metrics Discovery Application Programming Interface + +## Introduction + +This software is a user mode library that provides access to GPU performance data. + +The library has OS abstraction layer that allows for interoperability in different environments. + +## License + +Intel(R) Metrics Discovery Application Programming Interface is distributed under the MIT License. + +You may obtain a copy of the License at: +https://opensource.org/licenses/MIT + +## Supported Platforms + +- Intel(R) Processors with Gen11 graphics devices (formerly Ice Lake, Elkhart Lake), +- Intel(R) Processors with Gen9 graphics devices (formerly Skylake, Kaby Lake, Apollo Lake/Broxton, Gemini Lake, Coffee Lake), +- Intel(R) Processors with Gen8 graphics devices (formerly Broadwell), +- Intel(R) Processors with Gen7.5 graphics devices (formerly Haswell). + +## Supported Operating Systems + +Intel(R) Metrics Discovery Application Programming Interface is supported on Linux family operating systems with minimum kernel version 4.14. +Event based measurements require minimum Mesa version 18.2. + +### Detailed minimum version requirements + +| Platform | Code Name | Minimum Linux Kernel Version | Minimum Mesa Version | +|--|--|--|--| +| Gen11 | Elkhart Lake | 5.3 | 19.1 | +| Gen11 | Ice Lake | 4.18 | 19.1 | +| Gen9, Gen8 | * | 4.14 | 18.2 | +| Gen7.5 | Haswell | 4.17 | 18.2 | + +## Build and Install + +1\. Download sources. + +2\. Run CMake generation: + +```shell +cmake . +``` + +3\. Build: + +```shell +make -j$(nproc) +``` + +4\. Built library will be here (for 64-bit Linux): + +```shell +(project_root)/dump/linux64/release/md/libmd.so +``` + +5\. Install: + +```shell +sudo make install +``` + +*Note: To clear CMake params remove CMakeCache.txt, then regenerate.* + +## +___(*) Other names and brands my be claimed as property of others.___ diff --git a/third_party/metrics_discovery/metrics_discovery_api.h b/third_party/metrics_discovery/metrics_discovery_api.h new file mode 100644 index 0000000000..5c98e290a7 --- /dev/null +++ b/third_party/metrics_discovery/metrics_discovery_api.h @@ -0,0 +1,1171 @@ +/*****************************************************************************\ + + Copyright © 2019, 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: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + 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 + + Abstract: Interface for metrics discovery DLL + + Notes: + +\*****************************************************************************/ +#include + +#ifndef __METRICS_DISCOVERY_H_ +#define __METRICS_DISCOVERY_H_ + +#ifdef _MSC_VER + #define MD_STDCALL __stdcall +#else + #define MD_STDCALL +#endif // _MSC_VER + +namespace MetricsDiscovery +{ +//*****************************************************************************/ +// 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: +//*****************************************************************************/ + 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_CEIL = 0xFFFFFFFF + + } MD_API_MINOR_VERSION; + +//*****************************************************************************/ +// API build number: +//*****************************************************************************/ + #define MD_API_BUILD_NUMBER_CURRENT 115 + +//*****************************************************************************/ +// Completion codes: +//*****************************************************************************/ + typedef enum ECompletionCode + { + CC_OK = 0, + CC_READ_PENDING = 1, + CC_ALREADY_INITIALIZED = 2, + CC_STILL_INITIALIZED = 3, + CC_CONCURRENT_GROUP_LOCKED = 4, + 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 */ + +//*******************************************************************************/ +// Abstract interface for the GPU metrics root object. +//*******************************************************************************/ + class IMetricsDevice_1_0; + class IMetricsDevice_1_1; + class IMetricsDevice_1_2; + class IMetricsDevice_1_5; + +//*******************************************************************************/ +// Abstract interface for Metrics Device overrides. +//*******************************************************************************/ + class IOverride_1_2; + +//*******************************************************************************/ +// 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; + +//*******************************************************************************/ +// 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; + +//*******************************************************************************/ +// Abstract interface for the metric that is sampled. +//*******************************************************************************/ + class IMetric_1_0; + +//*******************************************************************************/ +// Abstract interface for the measurement information (report reason, etc.). +//*******************************************************************************/ + class IInformation_1_0; + +//*******************************************************************************/ +// Abstract interface for the metric read and normalization equation. +//*******************************************************************************/ + class IEquation_1_0; + + +//*******************************************************************************/ +// Value types: +//*******************************************************************************/ + typedef enum EValueType + { + VALUE_TYPE_UINT32, + VALUE_TYPE_UINT64, + VALUE_TYPE_FLOAT, + VALUE_TYPE_BOOL, + VALUE_TYPE_CSTRING, + // ... + VALUE_TYPE_LAST, + + } TValueType; + +//*******************************************************************************/ +// Typed value: +//*******************************************************************************/ + typedef struct STypedValue_1_0 + { + TValueType ValueType; + union { + uint32_t ValueUInt32; + uint64_t ValueUInt64; + struct + { + uint32_t Low; + uint32_t High; + } ValueUInt64Fields; + float ValueFloat; + bool ValueBool; + char* ValueCString; + }; + + } 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" +//*******************************************************************************/ + typedef struct SGlobalSymbol_1_0 + { + const char* SymbolName; + TTypedValue_1_0 SymbolTypedValue; + + } TGlobalSymbol_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; + + } TMetricsDeviceParams_1_0; + +//*******************************************************************************/ +// 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: +//*******************************************************************************/ + 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 + + } TMetricApiType; + +//*******************************************************************************/ +// Measurement types: +//*******************************************************************************/ + typedef enum EMeasurementType + { + MEASUREMENT_TYPE_SNAPSHOT_IO = 0x00000001, + MEASUREMENT_TYPE_SNAPSHOT_QUERY = 0x00000002, + MEASUREMENT_TYPE_DELTA_QUERY = 0x00000004, + MEASUREMENT_TYPE_ALL = 0x0000ffff, + + } TMeasurementType; + +//*******************************************************************************/ +// 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, + + } TMetricUsageFlag; + +//*******************************************************************************/ +// 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, + + } TSamplingType; + +//*******************************************************************************/ +// 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 + + } TMetricCategory; + +//*******************************************************************************/ +// IoStream read flags: +//*******************************************************************************/ + typedef enum EIoReadFlag + { + IO_READ_FLAG_DROP_OLD_REPORTS = 0x00000001, + IO_READ_FLAG_GET_CONTEXT_ID_TAGS = 0x00000002, + + } TIoReadFlag; + +//*******************************************************************************/ +// Override modes: +//*******************************************************************************/ + typedef enum EOverrideMode + { + OVERRIDE_MODE_GLOBAL = 0x0001, + OVERRIDE_MODE_LOCAL = 0x0002, + + } TOverrideMode; + +//*******************************************************************************/ +// Global parameters of Concurrent Group: +//*******************************************************************************/ + typedef struct SConcurrentGroupParams_1_0 + { + const char* SymbolName; // For example "PerfMon" or "OA" or "PipeStats" + const char* Description; // For example "PerfMon and ODLAT Uncore ring counters" + + uint32_t MeasurementTypeMask; + + uint32_t MetricSetsCount; + uint32_t IoMeasurementInformationCount; + uint32_t IoGpuContextInformationCount; + + } TConcurrentGroupParams_1_0; + +//*******************************************************************************/ +// 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: +//*******************************************************************************/ + typedef struct SSetOverrideParams_1_2 + { + bool Enable; + + } TSetOverrideParams_1_2; + +//*******************************************************************************/ +// 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: +//*******************************************************************************/ + typedef struct SSetQueryOverrideParams_1_2 : SSetOverrideParams_1_2 + { + uint32_t Period; // Nanoseconds + + } TSetQueryOverrideParams_1_2; + +//*******************************************************************************/ +// Driver override params: +//*******************************************************************************/ + typedef struct SSetDriverOverrideParams_1_2 : SSetOverrideParams_1_2 + { + uint32_t Value; + + } SSetDriverOverrideParams_1_2; + +//*******************************************************************************/ +// 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]; + + } TApiSpecificId_1_0; + +//*******************************************************************************/ +// 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; + //... + + } TMetricSetParams_1_0; + +//*******************************************************************************/ +// GT differenced MetricSet params: +//*******************************************************************************/ + typedef struct SMetricSetParams_1_4 : SMetricSetParams_1_0 + { + uint32_t GtMask; + + } TMetricSetParams_1_4; + +//*******************************************************************************/ +// Metric result types: +//*******************************************************************************/ + typedef enum EMetricResultType + { + RESULT_UINT32, + RESULT_UINT64, + RESULT_BOOL, + RESULT_FLOAT, + // ... + RESULT_LAST + + } TMetricResultType; + +//*******************************************************************************/ +// Metric types: +//*******************************************************************************/ + typedef enum EMetricType + { + METRIC_TYPE_DURATION, + METRIC_TYPE_EVENT, + METRIC_TYPE_EVENT_WITH_RANGE, + METRIC_TYPE_THROUGHPUT, + METRIC_TYPE_TIMESTAMP, + METRIC_TYPE_FLAG, + METRIC_TYPE_RATIO, + METRIC_TYPE_RAW, + // ... + METRIC_TYPE_LAST + + } TMetricType; + +//*******************************************************************************/ +// Information types: +//*******************************************************************************/ + typedef enum EInformationType + { + INFORMATION_TYPE_REPORT_REASON, + INFORMATION_TYPE_VALUE, + INFORMATION_TYPE_FLAG, + INFORMATION_TYPE_TIMESTAMP, + INFORMATION_TYPE_CONTEXT_ID_TAG, + INFORMATION_TYPE_SAMPLE_PHASE, + INFORMATION_TYPE_GPU_NODE, + // ... + INFORMATION_TYPE_LAST + + } TInformationType; + +//*******************************************************************************/ +// Report reasons: +//*******************************************************************************/ + typedef enum EReportReason + { + REPORT_REASON_UNDEFINED = 0x0000, + REPORT_REASON_INTERNAL_TIMER = 0x0001, + REPORT_REASON_INTERNAL_TRIGGER1 = 0x0002, + REPORT_REASON_INTERNAL_TRIGGER2 = 0x0004, + REPORT_REASON_INTERNAL_CONTEXT_SWITCH = 0x0008, + REPORT_REASON_INTERNAL_GO = 0x0010, + REPORT_REASON_INTERNAL_FREQUENCY_CHANGE = 0x0020, + REPORT_REASON_QUERY_DEFAULT = 0x0100, + REPORT_REASON_QUERY_INTERNAL_RESOLVE = 0x0200, + REPORT_REASON_QUERY_INTERNAL_CLEAR = 0x0400, + + } TReportReason; + +//*******************************************************************************/ +// Sample phase: +//*******************************************************************************/ + typedef enum ESamplePhase + { + SAMPLE_PHASE_END, + SAMPLE_PHASE_BEGIN, + // ... + SAMPLE_PHASE_LAST + + } TSamplePhase; + +//*******************************************************************************/ +// 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_LAST + + } TInformationGpuNode; + +//*******************************************************************************/ +// Hardware unit types: +//*******************************************************************************/ + typedef enum EHwUnitType + { + HW_UNIT_GPU, + HW_UNIT_SLICE, + HW_UNIT_SUBSLICE, + HW_UNIT_SUBSLICE_BANK, + HW_UNIT_EU_UNIT, + HW_UNIT_UNCORE, + // ... + HW_UNIT_LAST + + } THwUnitType; + +//*******************************************************************************/ +// 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_FUNCTION_LAST_1_0 + + } TDeltaFunctionType; + +//*******************************************************************************/ +// Delta function: +//*******************************************************************************/ + typedef struct SDeltaFunction_1_0 + { + TDeltaFunctionType FunctionType; + union { + uint32_t BitsCount; // Used for DELTA_N_BITS to specify bits count + }; + + } TDeltaFunction_1_0; + +//*******************************************************************************/ +// 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_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_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_LAST_1_0 + + } TEquationElementType; + +//*******************************************************************************/ +// 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_LAST_1_0 + + } TEquationOperation; + +//*******************************************************************************/ +// Read params: +//*******************************************************************************/ + typedef struct SReadParams_1_0 + { + uint32_t ByteOffset; + uint32_t BitOffset; + uint32_t BitsCount; + uint32_t ByteOffsetExt; + + } TReadParams_1_0; + +//*******************************************************************************/ +// Equation element: +//*******************************************************************************/ + typedef struct SEquationElement_1_0 + { + TEquationElementType Type; + union + { + uint64_t ImmediateUInt64; + float ImmediateFloat; + TEquationOperation Operation; + TReadParams_1_0 ReadParams; + }; + char* SymbolName; + + } TEquationElement_1_0; + +/*****************************************************************************\ + +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: +//*******************************************************************************/ + 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; + + } TMetricParams_1_0; + +//*******************************************************************************/ +// 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; + + } TInformationParams_1_0; + +/*****************************************************************************\ + +Class: + IInformation_1_0 + +Description: + 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 + { + public: + virtual ~IMetric_1_0(); + + 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 + { + 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 ); + }; + +/*****************************************************************************\ + +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 : 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 ); + }; + +/*****************************************************************************\ + +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 : public IMetricSet_1_4 + { + public: + // To avoid hiding by 1.5 interface function + using IMetricSet_1_1::CalculateMetrics; + + // 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. + 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 ); + }; + +/*****************************************************************************\ + +Class: + 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 ); + }; + +/*****************************************************************************\ + +Class: + IConcurrentGroup_1_1 + +Description: + Updated 1.0 version to use with 1.1 interface version. + + Updates: + - GetMetricSet + +\*****************************************************************************/ + class IConcurrentGroup_1_1 : public IConcurrentGroup_1_0 + { + public: + // Update to 1.1 interface + 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 : public IConcurrentGroup_1_1 + { + public: + // To set sampling type during IoStream measurements + 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 : public IConcurrentGroup_1_3 + { + public: + // Update to 1.5 interface + virtual IMetricSet_1_5* GetMetricSet( uint32_t index ); + }; + +/*****************************************************************************\ + +Class: + IOverride_1_2 + +Description: + Abstract interface for Metrics Device overrides. + +\*****************************************************************************/ + 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 ); + }; + +/*****************************************************************************\ + +Class: + IMetricsDevice_1_0 + +Description: + Abstract interface for the GPU metrics root object. + +\*****************************************************************************/ + 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 ); + }; + +/*****************************************************************************\ + +Class: + IMetricsDevice_1_1 + +Description: + Updated 1.0 version to use with 1.1 interface version. + + Updates: + - GetConcurrentGroup + +\*****************************************************************************/ + class IMetricsDevice_1_1 : public IMetricsDevice_1_0 + { + public: + // Update to 1.1 interface + virtual IConcurrentGroup_1_1* GetConcurrentGroup( uint32_t index ); + }; + +/*****************************************************************************\ + +Class: + IMetricsDevice_1_2 + +Description: + Updated 1.1 version to use with 1.2 interface version. + Introduces an interface for getting overrides. + + Updates: + - GetParams + New: + - GetOverride + - GetOverrideByName + +\*****************************************************************************/ + class IMetricsDevice_1_2 : public IMetricsDevice_1_1 + { + public: + // Update returned params + virtual TMetricsDeviceParams_1_2* GetParams( void ); + + // To get override at the given index + virtual IOverride_1_2* GetOverride( uint32_t index ); + + // To get override with the given name + virtual IOverride_1_2* GetOverrideByName( const char* symbolName ); + }; + +/*****************************************************************************\ + +Class: + IMetricsDevice_1_5 + +Description: + Updated 1.2 version to use with 1.5 interface version. + + Updates: + - GetConcurrentGroup + +\*****************************************************************************/ + class IMetricsDevice_1_5 : public IMetricsDevice_1_2 + { + public: + // Update to 1.5 interface + virtual IConcurrentGroup_1_5* GetConcurrentGroup( uint32_t index ); + }; + +#ifdef __cplusplus + 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); + +#ifdef __cplusplus + } +#endif + +}; +#endif // __METRICS_DISCOVERY_H_ + diff --git a/third_party/metrics_library/.revision b/third_party/metrics_library/.revision new file mode 100644 index 0000000000..3c07a5236a --- /dev/null +++ b/third_party/metrics_library/.revision @@ -0,0 +1 @@ +608dcb5b626317e1e7550eedc84ff6e542a3b31b \ No newline at end of file diff --git a/third_party/metrics_library/LICENSE.md b/third_party/metrics_library/LICENSE.md new file mode 100644 index 0000000000..128ad94ab6 --- /dev/null +++ b/third_party/metrics_library/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020, 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: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +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. \ No newline at end of file diff --git a/third_party/metrics_library/README.md b/third_party/metrics_library/README.md new file mode 100644 index 0000000000..07bf26c790 --- /dev/null +++ b/third_party/metrics_library/README.md @@ -0,0 +1,63 @@ +# Intel(R) Metrics Library for MDAPI + +## Introduction + +This software is a user mode driver helper library that provides access to GPU performance counters. + +## License + +Intel(R) Metrics Library for MDAPI is distributed under the MIT License. + +You may obtain a copy of the License at: +https://opensource.org/licenses/MIT + +## Supported Platforms + +- Intel(R) Processors with Gen12 graphics devices +- Intel(R) Processors with Gen11 graphics devices +- Intel(R) Processors with Gen9 graphics devices + +## Supported Operating Systems + +Intel(R) Metrics Library for MDAPI is supported on Linux family operating systems with minimum kernel version 4.14. + +## Build and Install +Not a stand alone software component. Serves as a helper library for particular Intel drivers. +There is no need to build the library as long as it is an integrated part of those Intel drivers. + +1\. Download sources. + +2\. Run CMake generation: + +```shell +cmake . +``` + +3\. Build: + +```shell +make -j$(nproc) +``` + +4\. Built library will be here (for 64-bit Linux): + +```shell +(project_root)/dump/linux64/metrics_library/libigdml64.so +``` + +5\. To prepare an installation package: + +```shell +make package +``` + +6\. Install: + +```shell +sudo dpkg -i intel-metrics-library*.deb +``` + +*Note: To clear CMake parameters remove CMakeCache.txt, then regenerate.* + +## +___(*) Other names and brands my be claimed as property of others.___ diff --git a/third_party/metrics_library/metrics_library_api_1_0.h b/third_party/metrics_library/metrics_library_api_1_0.h new file mode 100644 index 0000000000..3a9344e50a --- /dev/null +++ b/third_party/metrics_library/metrics_library_api_1_0.h @@ -0,0 +1,653 @@ +/******************************************************************************\ + + Copyright © 2020, 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: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + 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_library_api_1_0.h + + Abstract: Interface for Metrics Library umd dll. + + Notes: + +\******************************************************************************/ +#pragma once +#include + +#ifdef _MSC_VER + #define ML_STDCALL __stdcall +#else + #define ML_STDCALL +#endif + +namespace MetricsLibraryApi +{ +////////////////////////////////////////////////////////////////////////// +/// @brief Metrics Library handles. +////////////////////////////////////////////////////////////////////////// +#define METRICS_LIBRARY_HANDLE(Object) typedef struct Object##Handle_1_0 \ + { \ + void* data; \ + Object##Handle_1_0( void ) { data = nullptr; } \ + Object##Handle_1_0( void* handle ) { data = handle; } \ + bool IsValid( void ) const { return data != nullptr; } \ + } Object##Handle_1_0; + +METRICS_LIBRARY_HANDLE( Client ) +METRICS_LIBRARY_HANDLE( ClientMemory ) +METRICS_LIBRARY_HANDLE( Configuration ) +METRICS_LIBRARY_HANDLE( Context ) +METRICS_LIBRARY_HANDLE( Marker ) +METRICS_LIBRARY_HANDLE( Override ) +METRICS_LIBRARY_HANDLE( Query ) + +////////////////////////////////////////////////////////////////////////// +/// @brief Client api types. +////////////////////////////////////////////////////////////////////////// +enum class ClientApi : uint32_t +{ + Unknown = 0, + // 1-5 reserved. + OpenCL = 6, + // 7-8 reserved. + OneApi = 9, + // 10 reserved. + // ... + Last +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Client gpu generation types. +////////////////////////////////////////////////////////////////////////// +enum class ClientGen : uint32_t +{ + Unknown = 0, + Gen9, + Gen9LP, + Gen10, + Gen11, + Gen11LP, + Gen12, + // ... + Last +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Library object types. +////////////////////////////////////////////////////////////////////////// +enum class ObjectType : uint32_t +{ + Unknown = 0, + + // Context objects: + Context = 10000, + + // Query objects: + QueryHwCounters = 20000, + QueryPipelineTimestamps = 20001, + + // Configuration objects: + ConfigurationHwCountersOa = 30000, + ConfigurationHwCountersUser, + + // Override objects: + OverrideUser = 40000, + OverrideNullHardware, + OverrideFlushCaches, + OverridePoshQuery, + OverrideDisablePoshPrimitives, + + // Markers: + MarkerStreamUser = 50000, + MarkerStreamUserExtended = 50001, + + // ... + Last +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Client options types. +////////////////////////////////////////////////////////////////////////// +enum class ClientOptionsType : uint32_t +{ + Posh = 0, + Ptbr, + Compute, + // ... + Last +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Status code types. +////////////////////////////////////////////////////////////////////////// +enum class StatusCode : uint32_t +{ + Success = 0, + Failed, + IncorrectVersion, + IncorrectParameter, + IncorrectSlot, + IncorrectObject, + InsufficientSpace, + NotInitialized, + NotSupported, + NotImplemented, + NullPointer, + OutOfMemory, + UnknownGen, + TbsUnableToEnable, + TbsUnableToRead, + ReportNotReady, + ReportLost, + ReportInconsistent, + // ... + Last +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Value types. +////////////////////////////////////////////////////////////////////////// +enum class ValueType : uint8_t +{ + Uint8 = 0, + Int8, + Uint16, + Int16, + Uint32, + Int32, + Uint64, + Int64, + Float, + Double, + Bool, + String, + // ... + Last +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Gpu configuration activation types. +////////////////////////////////////////////////////////////////////////// +enum class GpuConfigurationActivationType : uint32_t +{ + EscapeCode = 0, + Tbs, + // ... + Last +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Gpu command buffer types. +////////////////////////////////////////////////////////////////////////// +enum class GpuCommandBufferType : uint32_t +{ + Render = 0, + Posh, + Tile, + Compute, + // ... + Last +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Memory types. +////////////////////////////////////////////////////////////////////////// +enum class MemoryType : uint32_t +{ + Query = 0, + CommandBuffer, + Cpu, + // ... + Last +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Memory flags. +////////////////////////////////////////////////////////////////////////// +enum class MemoryFlags : uint32_t +{ + Linear = 1 << 0, + Cachable = 1 << 1 +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Parameter types. +////////////////////////////////////////////////////////////////////////// +enum class ParameterType : uint32_t +{ + QueryHwCountersReportApiSize = 0, + QueryHwCountersReportGpuSize, + QueryPipelineTimestampsReportApiSize, + QueryPipelineTimestampsReportGpuSize, + LibraryBuildNumber, + // ... + Last +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Client type. +////////////////////////////////////////////////////////////////////////// +struct ClientType_1_0 +{ + ClientApi Api; + ClientGen Gen; +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Typed value. +////////////////////////////////////////////////////////////////////////// +struct TypedValue_1_0 +{ + ValueType Type; + + union + { + int8_t ValueInt8; + uint8_t ValueUInt8; + int16_t ValueInt16; + uint16_t ValueUInt16; + int32_t ValueInt32; + uint32_t ValueUInt32; + int64_t ValueInt64; + uint64_t ValueUInt64; + float ValueFloat; + bool ValueBool; + const char* ValueString; + }; +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Gpu memory data. +////////////////////////////////////////////////////////////////////////// +struct GpuMemory_1_0 +{ + uint64_t GpuAddress; // Virtual gpu address. + void* CpuAddress; // Locked cpu address. + ClientMemoryHandle_1_0 HandleMemory; // Driver's handle. +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Query creation data. +////////////////////////////////////////////////////////////////////////// +struct QueryCreateData_1_0 +{ + ContextHandle_1_0 HandleContext; + ObjectType Type; + uint32_t Slots; +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Query hw counters command buffer data. +////////////////////////////////////////////////////////////////////////// +struct CommandBufferQueryHwCounters_1_0 +{ + QueryHandle_1_0 Handle; + ConfigurationHandle_1_0 HandleUserConfiguration; + uint32_t Slot; + uint64_t MarkerUser; + uint64_t MarkerDriver; + uint64_t EndTag; + bool Begin; +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Query pipeline timestamps command buffer data. +////////////////////////////////////////////////////////////////////////// +struct CommandBufferQueryPipelineTimestamps_1_0 +{ + QueryHandle_1_0 Handle; + uint64_t EndTag; + bool Begin; +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Overrides commands data. +////////////////////////////////////////////////////////////////////////// +struct CommandBufferOverride_1_0 +{ + OverrideHandle_1_0 Handle; + bool Enable; +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Marker stream user commands data. +////////////////////////////////////////////////////////////////////////// +struct CommandBufferMarkerStreamUser_1_0 +{ + uint32_t Reserved : 7; + uint32_t Value : 25; +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Marker stream user extended commands data. +////////////////////////////////////////////////////////////////////////// +struct CommandBufferMarkerStreamUserExtended_1_0 +{ +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Command buffer data. +////////////////////////////////////////////////////////////////////////// +struct CommandBufferData_1_0 +{ + ContextHandle_1_0 HandleContext; // Context handle. + ObjectType CommandsType; // Commands type related to library object. + GpuCommandBufferType Type; // Gpu command buffer type. + GpuMemory_1_0 Allocation; // Gpu memory allocation. + void* Data; // Gpu command buffer data. + uint32_t Size; // Gpu command buffer size. + uint32_t Offset; // Gpu command buffer offset from beginning. + + union + { + CommandBufferQueryHwCounters_1_0 QueryHwCounters; + CommandBufferQueryPipelineTimestamps_1_0 QueryPipelineTimestamps; + CommandBufferOverride_1_0 Override; + CommandBufferMarkerStreamUser_1_0 MarkerStreamUser; + CommandBufferMarkerStreamUserExtended_1_0 MarkerStreamUserExtended; + }; +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Command buffer size. +////////////////////////////////////////////////////////////////////////// +struct CommandBufferSize_1_0 +{ + uint32_t GpuMemorySize; + uint32_t GpuMemoryPatchesCount; +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Override create data. +////////////////////////////////////////////////////////////////////////// +struct OverrideCreateData_1_0 +{ + ContextHandle_1_0 HandleContext; + ObjectType Type; +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Marker creation data. +////////////////////////////////////////////////////////////////////////// +struct MarkerCreateData_1_0 +{ + ContextHandle_1_0 HandleContext; + ObjectType Type; +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Configuration creation data. +////////////////////////////////////////////////////////////////////////// +struct ConfigurationCreateData_1_0 +{ + ContextHandle_1_0 HandleContext; + ObjectType Type; +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Configuration activate data. +////////////////////////////////////////////////////////////////////////// +struct ConfigurationActivateData_1_0 +{ + GpuConfigurationActivationType Type; +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Get query report. +////////////////////////////////////////////////////////////////////////// +struct GetReportQuery_1_0 +{ + QueryHandle_1_0 Handle; // Input. + + uint32_t Slot; // Input. + uint32_t SlotsCount; // Input. + + uint32_t DataSize; // Input. + void* Data; // Input / output. +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Get override report. +////////////////////////////////////////////////////////////////////////// +struct GetReportOverride_1_0 +{ + OverrideHandle_1_0 Handle; // Input. + + uint32_t DataSize; // Input. + void* Data; // Output. +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Get data. +////////////////////////////////////////////////////////////////////////// +struct GetReportData_1_0 +{ + ObjectType Type; + + union + { + GetReportQuery_1_0 Query; + GetReportOverride_1_0 Override; + }; +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Gpu memory allocate data. +////////////////////////////////////////////////////////////////////////// +struct GpuMemoryAllocateData_1_0 +{ + MemoryType Type; // Input. + MemoryFlags Flags; // Input. + uint32_t Size; // Input. + void* Data; // Output. +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Cpu memory allocate data. +////////////////////////////////////////////////////////////////////////// +struct CpuMemoryAllocateData_1_0 +{ + uint32_t Size; // Input. + void* Data; // Output. +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Metrics Library functions. +////////////////////////////////////////////////////////////////////////// +using GetParameterFunction_1_0 = StatusCode( ML_STDCALL* ) ( const ParameterType parameter, ValueType* type, TypedValue_1_0* value ); + +using CommandBufferGetFunction_1_0 = StatusCode( ML_STDCALL* ) ( const CommandBufferData_1_0* data ); +using CommandBufferGetSizeFunction_1_0 = StatusCode( ML_STDCALL* ) ( const CommandBufferData_1_0* data, CommandBufferSize_1_0* size ); + +using QueryCreateFunction_1_0 = StatusCode( ML_STDCALL* ) ( const QueryCreateData_1_0* createData, QueryHandle_1_0* handle ); +using QueryDeleteFunction_1_0 = StatusCode( ML_STDCALL* ) ( const QueryHandle_1_0 handle ); + +using OverrideCreateFunction_1_0 = StatusCode( ML_STDCALL* ) ( const OverrideCreateData_1_0* createData, OverrideHandle_1_0* handle ); +using OverrideDeleteFunction_1_0 = StatusCode( ML_STDCALL* ) ( const OverrideHandle_1_0 handle ); + +using MarkerCreateFunction_1_0 = StatusCode( ML_STDCALL* ) ( const MarkerCreateData_1_0* createData, MarkerHandle_1_0* handle ); +using MarkerDeleteFunction_1_0 = StatusCode( ML_STDCALL* ) ( const MarkerHandle_1_0 handle ); + +using ConfigurationCreateFunction_1_0 = StatusCode( ML_STDCALL* ) ( const ConfigurationCreateData_1_0* createData, ConfigurationHandle_1_0* handle ); +using ConfigurationActivateFunction_1_0 = StatusCode( ML_STDCALL* ) ( const ConfigurationHandle_1_0 handle, const ConfigurationActivateData_1_0* activateData ); +using ConfigurationDeactivateFunction_1_0 = StatusCode( ML_STDCALL* ) ( const ConfigurationHandle_1_0 handle ); +using ConfigurationDeleteFunction_1_0 = StatusCode( ML_STDCALL* ) ( const ConfigurationHandle_1_0 handle ); + +using GetDataFunction_1_0 = StatusCode( ML_STDCALL* ) ( GetReportData_1_0* data ); + +////////////////////////////////////////////////////////////////////////// +/// @brief Metrics Library callbacks. +////////////////////////////////////////////////////////////////////////// +using CommandBufferFlushCallback_1_0 = StatusCode ( ML_STDCALL* ) ( const ClientHandle_1_0 handle ); +using CommandBufferHasSpaceCallback_1_0 = StatusCode ( ML_STDCALL* ) ( const ClientHandle_1_0 handle ); +using CommandBufferGetSpaceCallback_1_0 = StatusCode ( ML_STDCALL* ) ( const ClientHandle_1_0 handle ); + +using GpuMemoryAllocateCallback_1_0 = StatusCode ( ML_STDCALL* ) ( const ClientHandle_1_0 handle, GpuMemoryAllocateData_1_0* allocationData, ClientMemoryHandle_1_0* handleMemory ); +using GpuMemoryPatchCallback_1_0 = StatusCode ( ML_STDCALL* ) ( const ClientHandle_1_0 handle, const ClientMemoryHandle_1_0 handleMemory, const uint64_t allocationOffset, const uint64_t buffer ); +using GpuMemoryReleaseCallback_1_0 = StatusCode ( ML_STDCALL* ) ( const ClientHandle_1_0 handle ); + +using CpuMemoryAllocateCallback_1_0 = StatusCode ( ML_STDCALL* ) ( const ClientHandle_1_0 handle, CpuMemoryAllocateData_1_0* allocationData, ClientMemoryHandle_1_0* handleMemory ); +using CpuMemoryReleaseCallback_1_0 = StatusCode ( ML_STDCALL* ) ( const ClientHandle_1_0 handle ); + +////////////////////////////////////////////////////////////////////////// +/// @brief Metrics Library interface. +////////////////////////////////////////////////////////////////////////// +struct Interface_1_0 +{ + GetParameterFunction_1_0 GetParameter; + + CommandBufferGetFunction_1_0 CommandBufferGet; + CommandBufferGetSizeFunction_1_0 CommandBufferGetSize; + + QueryCreateFunction_1_0 QueryCreate; + QueryDeleteFunction_1_0 QueryDelete; + + OverrideCreateFunction_1_0 OverrideCreate; + OverrideDeleteFunction_1_0 OverrideDelete; + + MarkerCreateFunction_1_0 MarkerCreate; + MarkerDeleteFunction_1_0 MarkerDelete; + + ConfigurationCreateFunction_1_0 ConfigurationCreate; + ConfigurationActivateFunction_1_0 ConfigurationActivate; + ConfigurationDeactivateFunction_1_0 ConfigurationDeactivate; + ConfigurationDeleteFunction_1_0 ConfigurationDelete; + + GetDataFunction_1_0 GetData; +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Metrics Library interface callbacks. +////////////////////////////////////////////////////////////////////////// +struct ClientCallbacks_1_0 +{ + CommandBufferFlushCallback_1_0 CommandBufferFlush; + CommandBufferHasSpaceCallback_1_0 CommandBufferHasSpace; + CommandBufferGetSpaceCallback_1_0 CommandBufferGetSpace; + + GpuMemoryAllocateCallback_1_0 GpuMemoryAllocate; + GpuMemoryPatchCallback_1_0 GpuMemoryPatch; + GpuMemoryReleaseCallback_1_0 GpuMemoryRelease; + + CpuMemoryAllocateCallback_1_0 CpuMemoryAllocate; + CpuMemoryReleaseCallback_1_0 CpuMemoryRelease; +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Windows client data. +////////////////////////////////////////////////////////////////////////// +struct ClientDataWindows_1_0 +{ + void* Device; + void* Adapter; + void* Escape; + bool KmdInstrumentationEnabled; +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Linux client data. +////////////////////////////////////////////////////////////////////////// +struct ClientDataLinux_1_0 +{ + void* Reserved; +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Client options posh data. +////////////////////////////////////////////////////////////////////////// +struct ClientOptionsPoshData_1_0 +{ + bool Enabled; +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Client options ptbr data. +////////////////////////////////////////////////////////////////////////// +struct ClientOptionsPtbrData_1_0 +{ + bool Enabled; +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Client options compute data. +////////////////////////////////////////////////////////////////////////// +struct ClientOptionsComputeData_1_0 +{ + bool Asynchronous; +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Client options data. +////////////////////////////////////////////////////////////////////////// +struct ClientOptionsData_1_0 +{ + ClientOptionsType Type; + + union + { + ClientOptionsPoshData_1_0 Posh; + ClientOptionsPtbrData_1_0 Ptbr; + ClientOptionsComputeData_1_0 Compute; + }; +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Client data. +////////////////////////////////////////////////////////////////////////// +struct ClientData_1_0 +{ + ClientHandle_1_0 Handle; + + union + { + ClientDataWindows_1_0 Windows; + ClientDataLinux_1_0 Linux; + }; + + ClientOptionsData_1_0* ClientOptions; + uint32_t ClientOptionsCount; +}; + +////////////////////////////////////////////////////////////////////////// +/// @brief Context create data. +////////////////////////////////////////////////////////////////////////// +struct ContextCreateData_1_0 +{ + ClientData_1_0* ClientData; + ClientCallbacks_1_0* ClientCallbacks; + Interface_1_0* Api; +}; + +using ContextCreateFunction_1_0 = StatusCode ( ML_STDCALL* ) ( ClientType_1_0 clientType, ContextCreateData_1_0* createData, ContextHandle_1_0* handle ); +using ContextDeleteFunction_1_0 = StatusCode ( ML_STDCALL* ) ( const ContextHandle_1_0 handle ); + +////////////////////////////////////////////////////////////////////////// +/// @brief Metrics Library initialize/destroy functions. +////////////////////////////////////////////////////////////////////////// +#define METRICS_LIBRARY_CONTEXT_CREATE_1_0 "ContextCreate_1_0" +#define METRICS_LIBRARY_CONTEXT_DELETE_1_0 "ContextDelete_1_0" + +////////////////////////////////////////////////////////////////////////// +/// @brief Metrics Library current version. +////////////////////////////////////////////////////////////////////////// +#define METRICS_LIBRARY_MAJOR_NUMBER 1 +#define METRICS_LIBRARY_MINOR_NUMBER 0 +#define METRICS_LIBRARY_BUILD_NUMBER 1 + +} // namespace MetricsLibraryApi