From 3883f790ccb647a3fd8ffcd84df592989e09692d Mon Sep 17 00:00:00 2001 From: Artur Harasimiuk Date: Fri, 5 Jan 2018 13:35:03 +0100 Subject: [PATCH] Instrumentation refactoring Use bool instead of int where it should be. Tweak naming. Removed unused members Change-Id: I468be28d78e9da7c7fa1632e362ed077929fb91a --- CMakeLists.txt | 18 +++++ runtime/CMakeLists.txt | 8 ++- runtime/command_queue/command_queue.cpp | 6 +- runtime/command_queue/dispatch_walker.h | 8 +-- runtime/event/perf_counter.h | 2 +- runtime/instrumentation/.clang-tidy | 40 +++++++++++ runtime/instrumentation/instrumentation.cpp | 44 ++++++------ runtime/instrumentation/instrumentation.h | 57 +++++++--------- .../linux/performance_counters_linux.cpp | 8 +-- runtime/os_interface/performance_counters.cpp | 14 ++-- .../instrumentation/instrumentation_tests.cpp | 10 +-- unit_tests/libult/CMakeLists.txt | 6 +- .../linux/mock_performance_counters_linux.cpp | 2 +- .../linux/mock_performance_counters_linux.h | 2 +- .../performance_counters_linux_tests.cpp | 8 +-- .../mock_performance_counters.cpp | 68 +++++++++---------- .../os_interface/mock_performance_counters.h | 30 ++++---- .../windows/mock_performance_counters_win.cpp | 2 +- .../windows/mock_performance_counters_win.h | 2 +- 19 files changed, 196 insertions(+), 139 deletions(-) create mode 100644 runtime/instrumentation/.clang-tidy diff --git a/CMakeLists.txt b/CMakeLists.txt index 4803ebb833..281ae1789d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -249,6 +249,20 @@ else(ARTIFACTS_DIR) endforeach(TARGET_tmp) message(STATUS "IGC Includes: ${IGDRCL__IGC_INCLUDE_DIR}") endif() + + if(INSTRUMENTATION_SOURCE_DIR) + get_filename_component(INSTRUMENTATION_SOURCE_DIR "${INSTRUMENTATION_SOURCE_DIR}" ABSOLUTE) + else(INSTRUMENTATION_SOURCE_DIR) + get_filename_component(INSTRUMENTATION_SOURCE_DIR_tmp "${CMAKE_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 "Intrumentation source dir is: ${INSTRUMENTATION_SOURCE_DIR}") + add_subdirectory("${INSTRUMENTATION_SOURCE_DIR}" "${IGDRCL_BUILD_DIR}/instrumentation") + set(HAVE_INSTRUMENTATION TRUE) + endif() endif(ARTIFACTS_DIR) add_definitions(-DGMM_OCL) @@ -469,6 +483,10 @@ set(SKU_INFO_SRCS_DIR_SUFFIX "/") include_directories(${IGDRCL_SOURCE_DIR}) include_directories(${IGDRCL_BUILD_DIR}) include_directories(${IGDRCL_SOURCE_DIR}/runtime/sku_info/definitions${SKU_INFO_SRCS_DIR_SUFFIX}) +include_directories(${IGDRCL_SOURCE_DIR}/runtime/instrumentation${SKU_INFO_SRCS_DIR_SUFFIX}) +if(HAVE_INSTRUMENTATION) + include_directories($) +endif() # Define where to put binaries if(MSVC) diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 7cfdb27ece..05247e482f 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -336,8 +336,8 @@ set (RUNTIME_SRCS_INDIRECT_HEAP ) set (RUNTIME_SRCS_INSTRUMENTATION - instrumentation/instrumentation.cpp - instrumentation/instrumentation.h + instrumentation${SKU_INFO_SRCS_DIR_SUFFIX}/instrumentation.cpp + instrumentation${SKU_INFO_SRCS_DIR_SUFFIX}/instrumentation.h ) set (RUNTIME_SRCS_KERNEL @@ -770,6 +770,10 @@ if(NOT GMMUMD_LIB_NAME) endif() target_link_libraries(${NEO_STATIC_LIB_NAME} ${GMMUMD_LIB_NAME}) +if(HAVE_INSTRUMENTATION) +target_link_libraries(${NEO_STATIC_LIB_NAME} instrumentation_umd) +endif() + if(WIN32) if(GTPIN_HEADERS_DIR) set( DEF_FILE "${CMAKE_CURRENT_SOURCE_DIR}/dll/windows/GTPinExports${IGDRCL_OPTION__BITS}.def" ) diff --git a/runtime/command_queue/command_queue.cpp b/runtime/command_queue/command_queue.cpp index caf95921d5..9d24fb648a 100644 --- a/runtime/command_queue/command_queue.cpp +++ b/runtime/command_queue/command_queue.cpp @@ -444,10 +444,10 @@ bool CommandQueue::setPerfCountersEnabled(bool perfCountersEnabled, cl_uint conf perfCounters->shutdown(); return false; } - InstrReadRegsCfg *pUserCounters = &perfConfigurationData->readRegs; - for (uint32_t i = 0; i < pUserCounters->regsCount; ++i) { + InstrReadRegsCfg *pUserCounters = &perfConfigurationData->ReadRegs; + for (uint32_t i = 0; i < pUserCounters->RegsCount; ++i) { perfCountersUserRegistersNumber++; - if (pUserCounters->reg[i].bitSize > 32) { + if (pUserCounters->Reg[i].BitSize > 32) { perfCountersUserRegistersNumber++; } } diff --git a/runtime/command_queue/dispatch_walker.h b/runtime/command_queue/dispatch_walker.h index a59c8bed76..0599c78dd5 100644 --- a/runtime/command_queue/dispatch_walker.h +++ b/runtime/command_queue/dispatch_walker.h @@ -285,20 +285,20 @@ void dispatchPerfCountersUserCounterCommands( uint32_t cmdNum = 0; uint32_t regAddr = 0; auto configData = commandQueue.getPerfCountersConfigData(); - auto userRegs = &configData->readRegs; + auto userRegs = &configData->ReadRegs; - for (uint32_t i = 0; i < userRegs->regsCount; i++) { + for (uint32_t i = 0; i < userRegs->RegsCount; i++) { auto pRegister = (MI_STORE_REGISTER_MEM *)commandStream->getSpace(sizeof(MI_STORE_REGISTER_MEM)); *pRegister = MI_STORE_REGISTER_MEM::sInit(); - regAddr = userRegs->reg[i].offset; + regAddr = userRegs->Reg[i].Offset; pRegister->setRegisterAddress(regAddr); //offset between base (low) registers is cl_ulong wide address = baseAddr + i * sizeof(cl_ulong); pRegister->setMemoryAddress(address); cmdNum++; - if (userRegs->reg[i].bitSize > 32) { + if (userRegs->Reg[i].BitSize > 32) { pRegister = (MI_STORE_REGISTER_MEM *)commandStream->getSpace(sizeof(MI_STORE_REGISTER_MEM)); *pRegister = MI_STORE_REGISTER_MEM::sInit(); diff --git a/runtime/event/perf_counter.h b/runtime/event/perf_counter.h index 4a857fffb0..312530e828 100644 --- a/runtime/event/perf_counter.h +++ b/runtime/event/perf_counter.h @@ -23,7 +23,7 @@ #pragma once #include "runtime/event/hw_timestamps.h" -#include "runtime/instrumentation/instrumentation.h" +#include "instrumentation.h" namespace OCLRT { diff --git a/runtime/instrumentation/.clang-tidy b/runtime/instrumentation/.clang-tidy new file mode 100644 index 0000000000..adb666a971 --- /dev/null +++ b/runtime/instrumentation/.clang-tidy @@ -0,0 +1,40 @@ +--- +Checks: 'clang-diagnostic-*,clang-analyzer-*,google-default-arguments,readability-identifier-naming,modernize-use-override,modernize-use-default-member-init,-clang-analyzer-alpha*,-clang-analyzer-core.StackAddressEscape,-clang-analyzer-optin.performance.Padding,-clang-analyzer-cplusplus.NewDeleteLeaks' +# WarningsAsErrors: '.*' +HeaderFilterRegex: 'runtime/' +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/runtime/instrumentation/instrumentation.cpp b/runtime/instrumentation/instrumentation.cpp index 36d161a858..e2f19bade3 100644 --- a/runtime/instrumentation/instrumentation.cpp +++ b/runtime/instrumentation/instrumentation.cpp @@ -20,26 +20,26 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -#include "runtime/instrumentation/instrumentation.h" +#include "instrumentation.h" namespace OCLRT { -int instrAutoSamplingStart( +bool instrAutoSamplingStart( InstrEscCbData cbData, void **ppOAInterface) { - return -1; + return false; } -int instrAutoSamplingStop( +bool instrAutoSamplingStop( void **ppOAInterface) { - return -1; + return false; } -int instrCheckPmRegsCfg( +bool instrCheckPmRegsCfg( InstrPmRegsCfg *pQueryPmRegsCfg, uint32_t *pLastPmRegsCfgHandle, const void *pASInterface) { - return -1; + return false; } void instrGetPerfCountersQueryData( @@ -54,52 +54,52 @@ void instrGetPerfCountersQueryData( const InstrAllowedContexts *pAllowedContexts) { } -int instrEscGetPmRegsCfg( +bool instrEscGetPmRegsCfg( InstrEscCbData cbData, uint32_t cfgId, InstrPmRegsCfg *pCfg, InstrAutoSamplingMode *pAutoSampling) { - return -1; + return false; } -int instrEscHwMetricsEnable( +bool instrEscHwMetricsEnable( InstrEscCbData cbData, - int enable) { - return -1; + bool enable) { + return false; } -int instrEscLoadPmRegsCfg( +bool instrEscLoadPmRegsCfg( InstrEscCbData cbData, InstrPmRegsCfg *pCfg, - int hardwareAccess) { - return -1; + bool hardwareAccess) { + return false; } -int instrEscSetPmRegsCfg( +bool instrEscSetPmRegsCfg( InstrEscCbData cbData, uint32_t count, uint32_t *pOffsets, uint32_t *pValues) { - return -1; + return false; } -int instrEscSendReadRegsCfg( +bool instrEscSendReadRegsCfg( InstrEscCbData cbData, uint32_t count, uint32_t *pOffsets, uint32_t *pBitSizes) { - return -1; + return false; } -int instrSetAvailable(int enabled) { - return -1; +bool instrSetAvailable(bool enabled) { + return false; } void instrEscVerifyEnable( InstrEscCbData cbData) { } -uint64_t instrSetPlatformInfo( +uint32_t instrSetPlatformInfo( uint32_t productId, void *pSkuTable) { return 0; diff --git a/runtime/instrumentation/instrumentation.h b/runtime/instrumentation/instrumentation.h index 57200471eb..6cc641493c 100644 --- a/runtime/instrumentation/instrumentation.h +++ b/runtime/instrumentation/instrumentation.h @@ -129,40 +129,29 @@ typedef struct { } HwPerfCounters; typedef struct { - uint32_t offset; - union { - uint32_t value32; - uint64_t value64; - }; - uint32_t bitSize; - uint32_t flags; + uint32_t Offset; + uint32_t BitSize; } InstrPmReg; typedef struct { - uint32_t handle; - InstrPmReg reg[INSTR_MAX_PM_REGS]; - uint32_t regsCount; - uint32_t pendingRegsCount; + uint32_t Handle; + uint32_t RegsCount; } InstrPmRegsOaCountersCfg; typedef struct { - uint32_t handle; - InstrPmReg reg[INSTR_MAX_PM_REGS]; - uint32_t regsCount; - uint32_t pendingRegsCount; + uint32_t Handle; + uint32_t RegsCount; } InstrPmRegsGpCountersCfg; typedef struct { - uint32_t handle; - InstrPmReg reg[INSTR_MAX_READ_REGS]; - uint32_t regsCount; - uint32_t srmsCount; + InstrPmReg Reg[INSTR_MAX_READ_REGS]; + uint32_t RegsCount; } InstrReadRegsCfg; typedef struct { - InstrPmRegsOaCountersCfg oaCounters; - InstrPmRegsGpCountersCfg gpCounters; - InstrReadRegsCfg readRegs; + InstrPmRegsOaCountersCfg OaCounters; + InstrPmRegsGpCountersCfg GpCounters; + InstrReadRegsCfg ReadRegs; } InstrPmRegsCfg; typedef struct { @@ -172,14 +161,14 @@ typedef struct { bool DDI; } InstrEscCbData; -int instrAutoSamplingStart( +bool instrAutoSamplingStart( InstrEscCbData cbData, void **ppOAInterface); -int instrAutoSamplingStop( +bool instrAutoSamplingStop( void **ppOAInterface); -int instrCheckPmRegsCfg( +bool instrCheckPmRegsCfg( InstrPmRegsCfg *pQueryPmRegsCfg, uint32_t *pLastPmRegsCfgHandle, const void *pASInterface); @@ -195,39 +184,39 @@ void instrGetPerfCountersQueryData( bool resetASData = false, const InstrAllowedContexts *pAllowedContexts = nullptr); -int instrEscGetPmRegsCfg( +bool instrEscGetPmRegsCfg( InstrEscCbData cbData, uint32_t cfgId, InstrPmRegsCfg *pCfg, InstrAutoSamplingMode *pAutoSampling); -int instrEscHwMetricsEnable( +bool instrEscHwMetricsEnable( InstrEscCbData cbData, - int enable); + bool enable); -int instrEscLoadPmRegsCfg( +bool instrEscLoadPmRegsCfg( InstrEscCbData cbData, InstrPmRegsCfg *pCfg, - int hardwareAccess = 1); + bool hardwareAccess = 1); -int instrEscSetPmRegsCfg( +bool instrEscSetPmRegsCfg( InstrEscCbData cbData, uint32_t count, uint32_t *pOffsets, uint32_t *pValues); -int instrEscSendReadRegsCfg( +bool instrEscSendReadRegsCfg( InstrEscCbData cbData, uint32_t count, uint32_t *pOffsets, uint32_t *pBitSizes); -int instrSetAvailable(int enabled); +bool instrSetAvailable(bool enabled); void instrEscVerifyEnable( InstrEscCbData cbData); -uint64_t instrSetPlatformInfo( +uint32_t instrSetPlatformInfo( uint32_t productId, void *pSkuTable); diff --git a/runtime/os_interface/linux/performance_counters_linux.cpp b/runtime/os_interface/linux/performance_counters_linux.cpp index 3358d76610..7cb6a4f761 100644 --- a/runtime/os_interface/linux/performance_counters_linux.cpp +++ b/runtime/os_interface/linux/performance_counters_linux.cpp @@ -70,16 +70,16 @@ bool PerformanceCountersLinux::verifyPmRegsCfg(InstrPmRegsCfg *pCfg, uint32_t *p return false; } bool PerformanceCountersLinux::getPerfmonConfig(InstrPmRegsCfg *pCfg) { - unsigned int oaCfgHandle = pCfg->oaCounters.handle; - unsigned int gpCfgHandle = pCfg->gpCounters.handle; + unsigned int oaCfgHandle = pCfg->OaCounters.Handle; + unsigned int gpCfgHandle = pCfg->GpCounters.Handle; int fd = osInterface->get()->getDrm()->getFileDescriptor(); if (perfmonLoadConfigFunc(fd, nullptr, &oaCfgHandle, &gpCfgHandle) != 0) { return false; } - if (pCfg->oaCounters.handle != 0 && oaCfgHandle != pCfg->oaCounters.handle) { + if (pCfg->OaCounters.Handle != 0 && oaCfgHandle != pCfg->OaCounters.Handle) { return false; } - if (pCfg->gpCounters.handle != 0 && gpCfgHandle != pCfg->gpCounters.handle) { + if (pCfg->GpCounters.Handle != 0 && gpCfgHandle != pCfg->GpCounters.Handle) { return false; } return true; diff --git a/runtime/os_interface/performance_counters.cpp b/runtime/os_interface/performance_counters.cpp index d1c98f649a..0b8375ab23 100644 --- a/runtime/os_interface/performance_counters.cpp +++ b/runtime/os_interface/performance_counters.cpp @@ -68,7 +68,7 @@ void PerformanceCounters::initialize(const HardwareInfo *hwInfo) { gfxFamily = hwInfo->pPlatform->eRenderCoreFamily; } void PerformanceCounters::enableImpl() { - hwMetricsEnabled = (hwMetricsEnableFunc(cbData, true) != 0) ? false : true; + hwMetricsEnabled = hwMetricsEnableFunc(cbData, true); if (!pAutoSamplingInterface && hwMetricsEnabled) { autoSamplingStartFunc(cbData, &pAutoSamplingInterface); @@ -108,12 +108,12 @@ InstrPmRegsCfg *PerformanceCounters::getPmRegsCfg(uint32_t configuration) { } InstrPmRegsCfg *pPmRegsCfg = new InstrPmRegsCfg(); - pPmRegsCfg->oaCounters.handle = INSTR_PM_REGS_CFG_INVALID; + pPmRegsCfg->OaCounters.Handle = INSTR_PM_REGS_CFG_INVALID; mutex.lock(); std::lock_guard lg(mutex, std::adopt_lock); - if (getPmRegsCfgFunc(cbData, configuration, pPmRegsCfg, nullptr) == 0) { + if (getPmRegsCfgFunc(cbData, configuration, pPmRegsCfg, nullptr)) { return pPmRegsCfg; } delete pPmRegsCfg; @@ -123,8 +123,8 @@ bool PerformanceCounters::verifyPmRegsCfg(InstrPmRegsCfg *pCfg, uint32_t *pLastP if (pCfg == nullptr || pLastPmRegsCfgHandle == nullptr || pLastPmRegsCfgPending == nullptr) { return false; } - if (checkPmRegsCfgFunc(pCfg, pLastPmRegsCfgHandle, pAutoSamplingInterface) == 0) { - if (loadPmRegsCfgFunc(cbData, pCfg, 1) == 0) { + if (checkPmRegsCfgFunc(pCfg, pLastPmRegsCfgHandle, pAutoSamplingInterface)) { + if (loadPmRegsCfgFunc(cbData, pCfg, 1)) { return true; } } @@ -158,7 +158,7 @@ bool PerformanceCounters::processEventReport(size_t inputParamSize, void *inputP } int PerformanceCounters::sendPerfConfiguration(uint32_t count, uint32_t *pOffsets, uint32_t *pValues) { - int ret = -1; + bool ret = false; if (count == 0 || pOffsets == NULL || pValues == NULL) { return CL_INVALID_VALUE; @@ -172,7 +172,7 @@ int PerformanceCounters::sendPerfConfiguration(uint32_t count, uint32_t *pOffset ret = sendReadRegsCfgFunc(cbData, count - 1, pOffsets + 1, pValues + 1); } - return ret != 0 ? CL_PROFILING_INFO_NOT_AVAILABLE : CL_SUCCESS; + return ret ? CL_SUCCESS : CL_PROFILING_INFO_NOT_AVAILABLE; } size_t PerformanceCounters::querySize() { diff --git a/unit_tests/instrumentation/instrumentation_tests.cpp b/unit_tests/instrumentation/instrumentation_tests.cpp index 01025ad68c..a9ccab226b 100644 --- a/unit_tests/instrumentation/instrumentation_tests.cpp +++ b/unit_tests/instrumentation/instrumentation_tests.cpp @@ -20,7 +20,7 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -#include "runtime/instrumentation/instrumentation.h" +#include "instrumentation.h" #include "gtest/gtest.h" #include "gmock/gmock.h" @@ -46,6 +46,8 @@ TEST(InstrumentationTest, instrCheckPmRegsCfg) { uint32_t *pLastPmRegsCfgHandle = nullptr; const void *pASInterface = nullptr; instrCheckPmRegsCfg(pQueryPmRegsCfg, pLastPmRegsCfgHandle, pASInterface); + InstrPmRegsCfg cfg; + instrCheckPmRegsCfg(&cfg, pLastPmRegsCfgHandle, pASInterface); } TEST(InstrumentationTest, instrGetPerfCountersQueryData) { @@ -71,14 +73,14 @@ TEST(InstrumentationTest, instrEscGetPmRegsCfg) { TEST(InstrumentationTest, instrEscHwMetricsEnable) { InstrEscCbData cbData = {0}; - int enable = 0; + bool enable = false; instrEscHwMetricsEnable(cbData, enable); } TEST(InstrumentationTest, instrEscLoadPmRegsCfg) { InstrEscCbData cbData = {0}; InstrPmRegsCfg *pCfg = nullptr; - int hardwareAccess = 0; + bool hardwareAccess = false; instrEscLoadPmRegsCfg(cbData, pCfg, hardwareAccess); } @@ -99,7 +101,7 @@ TEST(InstrumentationTest, instrEscSendReadRegsCfg) { } TEST(InstrumentationTest, instrSetAvailable) { - int enabled = 0; + bool enabled = false; instrSetAvailable(enabled); } diff --git a/unit_tests/libult/CMakeLists.txt b/unit_tests/libult/CMakeLists.txt index 086c2ad8cb..cc33b74526 100644 --- a/unit_tests/libult/CMakeLists.txt +++ b/unit_tests/libult/CMakeLists.txt @@ -86,7 +86,7 @@ target_include_directories(igdrcl_libult PRIVATE ${INSTRUMENTATION_INCLUDE_PATH} ${GTEST_INCLUDE_DIR} ${KHRONOS_HEADERS_DIR} - ${IGDRCL__IGC_INCLUDE_DIR} + ${IGDRCL__IGC_INCLUDE_DIR} ${THIRD_PARTY_DIR} ${GMOCK_INCLUDE_DIR} ) @@ -97,6 +97,10 @@ target_include_directories(igdrcl_libult_cs PRIVATE target_include_directories(igdrcl_libult BEFORE PRIVATE ${HW_SRC_INCLUDES}) target_include_directories(igdrcl_libult_cs BEFORE PRIVATE ${HW_SRC_INCLUDES}) +# if(HAVE_INSTRUMENTATION) +# target_include_directories(igdrcl_libult PRIVATE $) +# endif() + set_target_properties (igdrcl_libult PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties (igdrcl_libult_cs PROPERTIES POSITION_INDEPENDENT_CODE ON) target_compile_definitions(igdrcl_libult PUBLIC ${IGDRCL_LIB_FLAGS_DEFINITIONS} ${TESTED_GEN_FLAGS_DEFINITONS}) diff --git a/unit_tests/os_interface/linux/mock_performance_counters_linux.cpp b/unit_tests/os_interface/linux/mock_performance_counters_linux.cpp index fb25ee11fe..b3075ba20a 100644 --- a/unit_tests/os_interface/linux/mock_performance_counters_linux.cpp +++ b/unit_tests/os_interface/linux/mock_performance_counters_linux.cpp @@ -66,7 +66,7 @@ int dlcloseMock(void *handle) throw() { } return 0; } -uint64_t setPlatformInfo(uint32_t productId, void *pSkuTable) { +uint32_t setPlatformInfo(uint32_t productId, void *pSkuTable) { PerfCounterFlagsLinux::setPlatformInfoFuncCalled++; return 0; } diff --git a/unit_tests/os_interface/linux/mock_performance_counters_linux.h b/unit_tests/os_interface/linux/mock_performance_counters_linux.h index fc477ab541..665e52a87e 100644 --- a/unit_tests/os_interface/linux/mock_performance_counters_linux.h +++ b/unit_tests/os_interface/linux/mock_performance_counters_linux.h @@ -32,7 +32,7 @@ void *dlsymMockPassing(void *handle, const char *symbol) throw(); void *dlsymMockFailing(void *handle, const char *symbol) throw(); int getTimeFuncPassing(clockid_t clk_id, struct timespec *tp) throw(); int dlcloseMock(void *handle) throw(); -uint64_t setPlatformInfo(uint32_t productId, void *pSkuTable); +uint32_t setPlatformInfo(uint32_t productId, void *pSkuTable); int perfmonLoadConfigMock(int fd, drm_intel_context *ctx, uint32_t *oa_cfg_id, uint32_t *gp_cfg_id); class PerfCounterFlagsLinux : public PerfCounterFlags { diff --git a/unit_tests/os_interface/linux/performance_counters_linux_tests.cpp b/unit_tests/os_interface/linux/performance_counters_linux_tests.cpp index cf9441036a..437d4ce66e 100644 --- a/unit_tests/os_interface/linux/performance_counters_linux_tests.cpp +++ b/unit_tests/os_interface/linux/performance_counters_linux_tests.cpp @@ -418,9 +418,9 @@ TEST_P(PerformanceCountersLinuxGetPerfmonConfigTest, givenPassingPerfmonLoadConf performanceCountersLinux->setPerfmonLoadConfigFunc(perfmonLoadConfigChangingOa); } if (isZeroValue) { - config.oaCounters.handle = 0; + config.OaCounters.Handle = 0; } else { - config.oaCounters.handle = 1; + config.OaCounters.Handle = 1; } auto retVal = performanceCountersLinux->getPerfmonConfig(&config); EXPECT_EQ(1, PerfCounterFlagsLinux::perfmonLoadConfigCalled); @@ -441,9 +441,9 @@ TEST_P(PerformanceCountersLinuxGetPerfmonConfigTest, givenPassingPerfmonLoadConf performanceCountersLinux->setPerfmonLoadConfigFunc(perfmonLoadConfigChangingGp); } if (isZeroValue) { - config.gpCounters.handle = 0; + config.GpCounters.Handle = 0; } else { - config.gpCounters.handle = 1; + config.GpCounters.Handle = 1; } auto retVal = performanceCountersLinux->getPerfmonConfig(&config); EXPECT_EQ(1, PerfCounterFlagsLinux::perfmonLoadConfigCalled); diff --git a/unit_tests/os_interface/mock_performance_counters.cpp b/unit_tests/os_interface/mock_performance_counters.cpp index 11988e03cb..a930a053ed 100644 --- a/unit_tests/os_interface/mock_performance_counters.cpp +++ b/unit_tests/os_interface/mock_performance_counters.cpp @@ -54,83 +54,83 @@ int PerfCounterFlags::loadPmRegsCfgCalled; int PerfCounterFlags::setPmRegsCfgCalled; int PerfCounterFlags::sendReadRegsCfgCalled; -int hwMetricsEnableFuncFailing(InstrEscCbData cbData, int enable) { +bool hwMetricsEnableFuncFailing(InstrEscCbData cbData, bool enable) { PerfCounterFlags::escHwMetricsCalled++; PerfCounterFlags::hwMetricsEnableStatus = enable; - return -1; + return false; } -int hwMetricsEnableFuncPassing(InstrEscCbData cbData, int enable) { +bool hwMetricsEnableFuncPassing(InstrEscCbData cbData, bool enable) { PerfCounterFlags::escHwMetricsCalled++; PerfCounterFlags::hwMetricsEnableStatus = enable; - return 0; + return true; } -int autoSamplingStart(InstrEscCbData cbData, void **ppOAInterface) { +bool autoSamplingStart(InstrEscCbData cbData, void **ppOAInterface) { PerfCounterFlags::autoSamplingFuncCalled++; PerfCounterFlags::autoSamplingStarted++; ppOAInterface[0] = new char[1]; - return 0; + return true; } -int autoSamplingStartFailing(InstrEscCbData cbData, void **ppOAInterface) { +bool autoSamplingStartFailing(InstrEscCbData cbData, void **ppOAInterface) { PerfCounterFlags::autoSamplingFuncCalled++; PerfCounterFlags::autoSamplingStarted++; ppOAInterface[0] = nullptr; - return -1; + return false; } -int autoSamplingStop(void **ppOAInterface) { +bool autoSamplingStop(void **ppOAInterface) { PerfCounterFlags::autoSamplingFuncCalled++; PerfCounterFlags::autoSamplingStopped++; if (ppOAInterface[0]) { delete[] static_cast(ppOAInterface[0]); ppOAInterface[0] = nullptr; - return 0; + return true; } - return -1; + return false; } -int getPmRegsCfgPassing(InstrEscCbData cbData, uint32_t cfgId, InstrPmRegsCfg *pCfg, InstrAutoSamplingMode *pAutoSampling) { +bool getPmRegsCfgPassing(InstrEscCbData cbData, uint32_t cfgId, InstrPmRegsCfg *pCfg, InstrAutoSamplingMode *pAutoSampling) { PerfCounterFlags::getPmRegsCfgCalled++; if (cfgId == 1) { - pCfg->readRegs.regsCount = 2; - pCfg->readRegs.reg[0].bitSize = 32; - pCfg->readRegs.reg[1].bitSize = 64; + pCfg->ReadRegs.RegsCount = 2; + pCfg->ReadRegs.Reg[0].BitSize = 32; + pCfg->ReadRegs.Reg[1].BitSize = 64; } - return 0; + return true; } -int getPmRegsCfgFailing(InstrEscCbData cbData, uint32_t cfgId, InstrPmRegsCfg *pCfg, InstrAutoSamplingMode *pAutoSampling) { +bool getPmRegsCfgFailing(InstrEscCbData cbData, uint32_t cfgId, InstrPmRegsCfg *pCfg, InstrAutoSamplingMode *pAutoSampling) { PerfCounterFlags::getPmRegsCfgCalled++; - return -1; + return false; } -int checkPmRegsCfgPassing(InstrPmRegsCfg *pQueryPmRegsCfg, uint32_t *pLastPmRegsCfgHandle, const void *pASInterface) { +bool checkPmRegsCfgPassing(InstrPmRegsCfg *pQueryPmRegsCfg, uint32_t *pLastPmRegsCfgHandle, const void *pASInterface) { PerfCounterFlags::checkPmRegsCfgCalled++; - return 0; + return true; } -int checkPmRegsCfgFailing(InstrPmRegsCfg *pQueryPmRegsCfg, uint32_t *pLastPmRegsCfgHandle, const void *pASInterface) { +bool checkPmRegsCfgFailing(InstrPmRegsCfg *pQueryPmRegsCfg, uint32_t *pLastPmRegsCfgHandle, const void *pASInterface) { PerfCounterFlags::checkPmRegsCfgCalled++; - return -1; + return false; } -int loadPmRegsCfgPassing(InstrEscCbData cbData, InstrPmRegsCfg *pCfg, int hardwareAccess) { +bool loadPmRegsCfgPassing(InstrEscCbData cbData, InstrPmRegsCfg *pCfg, bool hardwareAccess) { PerfCounterFlags::loadPmRegsCfgCalled++; - return 0; + return true; } -int loadPmRegsCfgFailing(InstrEscCbData cbData, InstrPmRegsCfg *pCfg, int hardwareAccess) { +bool loadPmRegsCfgFailing(InstrEscCbData cbData, InstrPmRegsCfg *pCfg, bool hardwareAccess) { PerfCounterFlags::loadPmRegsCfgCalled++; - return -1; + return false; } -int setPmRegsCfgFuncPassing(InstrEscCbData cbData, uint32_t count, uint32_t *pOffsets, uint32_t *pValues) { +bool setPmRegsCfgFuncPassing(InstrEscCbData cbData, uint32_t count, uint32_t *pOffsets, uint32_t *pValues) { PerfCounterFlags::setPmRegsCfgCalled++; - return 0; + return true; } -int setPmRegsCfgFuncFailing(InstrEscCbData cbData, uint32_t count, uint32_t *pOffsets, uint32_t *pValues) { +bool setPmRegsCfgFuncFailing(InstrEscCbData cbData, uint32_t count, uint32_t *pOffsets, uint32_t *pValues) { PerfCounterFlags::setPmRegsCfgCalled++; - return -1; + return false; } -int sendReadRegsCfgFuncPassing(InstrEscCbData cbData, uint32_t count, uint32_t *pOffsets, uint32_t *pBitSizes) { +bool sendReadRegsCfgFuncPassing(InstrEscCbData cbData, uint32_t count, uint32_t *pOffsets, uint32_t *pBitSizes) { PerfCounterFlags::sendReadRegsCfgCalled++; - return 0; + return true; } -int sendReadRegsCfgFuncFailing(InstrEscCbData cbData, uint32_t count, uint32_t *pOffsets, uint32_t *pBitSizes) { +bool sendReadRegsCfgFuncFailing(InstrEscCbData cbData, uint32_t count, uint32_t *pOffsets, uint32_t *pBitSizes) { PerfCounterFlags::sendReadRegsCfgCalled++; - return -1; + return false; } template diff --git a/unit_tests/os_interface/mock_performance_counters.h b/unit_tests/os_interface/mock_performance_counters.h index 34b909d294..4024cd0c9f 100644 --- a/unit_tests/os_interface/mock_performance_counters.h +++ b/unit_tests/os_interface/mock_performance_counters.h @@ -27,23 +27,23 @@ namespace OCLRT { class OSInterface; -int hwMetricsEnableFuncPassing(InstrEscCbData cbData, int enable); -int hwMetricsEnableFuncFailing(InstrEscCbData cbData, int enable); -int autoSamplingStart(InstrEscCbData cbData, void **ppOAInterface); -int autoSamplingStartFailing(InstrEscCbData cbData, void **ppOAInterface); -int autoSamplingStop(void **ppOAInterface); -int getPmRegsCfgPassing(InstrEscCbData cbData, uint32_t cfgId, InstrPmRegsCfg *pCfg, InstrAutoSamplingMode *pAutoSampling); -int getPmRegsCfgFailing(InstrEscCbData cbData, uint32_t cfgId, InstrPmRegsCfg *pCfg, InstrAutoSamplingMode *pAutoSampling); -int checkPmRegsCfgPassing(InstrPmRegsCfg *pQueryPmRegsCfg, uint32_t *pLastPmRegsCfgHandle, const void *pASInterface); -int checkPmRegsCfgFailing(InstrPmRegsCfg *pQueryPmRegsCfg, uint32_t *pLastPmRegsCfgHandle, const void *pASInterface); -int loadPmRegsCfgPassing(InstrEscCbData cbData, InstrPmRegsCfg *pCfg, int hardwareAccess); -int loadPmRegsCfgFailing(InstrEscCbData cbData, InstrPmRegsCfg *pCfg, int hardwareAccess); +bool hwMetricsEnableFuncPassing(InstrEscCbData cbData, bool enable); +bool hwMetricsEnableFuncFailing(InstrEscCbData cbData, bool enable); +bool autoSamplingStart(InstrEscCbData cbData, void **ppOAInterface); +bool autoSamplingStartFailing(InstrEscCbData cbData, void **ppOAInterface); +bool autoSamplingStop(void **ppOAInterface); +bool getPmRegsCfgPassing(InstrEscCbData cbData, uint32_t cfgId, InstrPmRegsCfg *pCfg, InstrAutoSamplingMode *pAutoSampling); +bool getPmRegsCfgFailing(InstrEscCbData cbData, uint32_t cfgId, InstrPmRegsCfg *pCfg, InstrAutoSamplingMode *pAutoSampling); +bool checkPmRegsCfgPassing(InstrPmRegsCfg *pQueryPmRegsCfg, uint32_t *pLastPmRegsCfgHandle, const void *pASInterface); +bool checkPmRegsCfgFailing(InstrPmRegsCfg *pQueryPmRegsCfg, uint32_t *pLastPmRegsCfgHandle, const void *pASInterface); +bool loadPmRegsCfgPassing(InstrEscCbData cbData, InstrPmRegsCfg *pCfg, bool hardwareAccess); +bool loadPmRegsCfgFailing(InstrEscCbData cbData, InstrPmRegsCfg *pCfg, bool hardwareAccess); template void getPerfCountersQueryData(InstrEscCbData cbData, GTDI_QUERY *pData, HwPerfCountersLayout *pLayout, uint64_t cpuRawTimestamp, void *pASInterface, InstrPmRegsCfg *pPmRegsCfg, bool useMiRPC, bool resetASData = false, const InstrAllowedContexts *pAllowedContexts = NULL); -int setPmRegsCfgFuncPassing(InstrEscCbData cbData, uint32_t count, uint32_t *pOffsets, uint32_t *pValues); -int setPmRegsCfgFuncFailing(InstrEscCbData cbData, uint32_t count, uint32_t *pOffsets, uint32_t *pValues); -int sendReadRegsCfgFuncPassing(InstrEscCbData cbData, uint32_t count, uint32_t *pOffsets, uint32_t *pBitSizes); -int sendReadRegsCfgFuncFailing(InstrEscCbData cbData, uint32_t count, uint32_t *pOffsets, uint32_t *pBitSizes); +bool setPmRegsCfgFuncPassing(InstrEscCbData cbData, uint32_t count, uint32_t *pOffsets, uint32_t *pValues); +bool setPmRegsCfgFuncFailing(InstrEscCbData cbData, uint32_t count, uint32_t *pOffsets, uint32_t *pValues); +bool sendReadRegsCfgFuncPassing(InstrEscCbData cbData, uint32_t count, uint32_t *pOffsets, uint32_t *pBitSizes); +bool sendReadRegsCfgFuncFailing(InstrEscCbData cbData, uint32_t count, uint32_t *pOffsets, uint32_t *pBitSizes); class PerfCounterFlags { public: diff --git a/unit_tests/os_interface/windows/mock_performance_counters_win.cpp b/unit_tests/os_interface/windows/mock_performance_counters_win.cpp index 570384b4c8..2da1fdd3c8 100644 --- a/unit_tests/os_interface/windows/mock_performance_counters_win.cpp +++ b/unit_tests/os_interface/windows/mock_performance_counters_win.cpp @@ -38,7 +38,7 @@ std::unique_ptr MockPerformanceCounters::create(OSTime *osT int PerfCounterFlagsWin::setAvailableFuncCalled; int PerfCounterFlagsWin::verifyEnableFuncCalled; -int setAvailable(int value) { +bool setAvailable(bool value) { PerfCounterFlagsWin::setAvailableFuncCalled++; return value; } diff --git a/unit_tests/os_interface/windows/mock_performance_counters_win.h b/unit_tests/os_interface/windows/mock_performance_counters_win.h index 1c50d3a03f..a71fef0be6 100644 --- a/unit_tests/os_interface/windows/mock_performance_counters_win.h +++ b/unit_tests/os_interface/windows/mock_performance_counters_win.h @@ -28,7 +28,7 @@ namespace OCLRT { -int setAvailable(int value); +bool setAvailable(bool value); void verifyEnable(InstrEscCbData cbData); class PerfCounterFlagsWin : public PerfCounterFlags {