mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-28 16:48:45 +08:00
Metrics Library Performance Counters implementation.
Signed-off-by: Piotr Maciejewski <piotr.maciejewski@intel.com> Change-Id: I0f00dca1892f4857baaebc75ba2208a4f33db1bf
This commit is contained in:
committed by
sys_ocldev
parent
369982995d
commit
d1d794c658
@@ -36,6 +36,7 @@ set(RUNTIME_SRCS_OS_INTERFACE_WINDOWS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_library.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_library.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_win.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_metrics_library.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_socket.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_thread_win.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_thread_win.h
|
||||
|
||||
@@ -22,10 +22,6 @@ OSInterface::~OSInterface() {
|
||||
delete osInterfaceImpl;
|
||||
}
|
||||
|
||||
uint32_t OSInterface::getHwContextId() const {
|
||||
return osInterfaceImpl->getHwContextId();
|
||||
}
|
||||
|
||||
uint32_t OSInterface::getDeviceHandle() const {
|
||||
return static_cast<uint32_t>(osInterfaceImpl->getDeviceHandle());
|
||||
}
|
||||
|
||||
55
runtime/os_interface/windows/os_metrics_library.cpp
Normal file
55
runtime/os_interface/windows/os_metrics_library.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/os_interface/metrics_library.h"
|
||||
|
||||
namespace NEO {
|
||||
//////////////////////////////////////////////////////
|
||||
// FUNCTION: MetricsLibrary::oaConfigurationActivate
|
||||
//////////////////////////////////////////////////////
|
||||
bool MetricsLibrary::oaConfigurationActivate(
|
||||
const ConfigurationHandle_1_0 &handle) {
|
||||
ConfigurationActivateData_1_0 data = {};
|
||||
data.Type = GpuConfigurationActivationType::EscapeCode;
|
||||
|
||||
return api->functions.ConfigurationActivate(
|
||||
handle,
|
||||
&data) == StatusCode::Success;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// FUNCTION: MetricsLibrary::oaConfigurationDeactivate
|
||||
//////////////////////////////////////////////////////
|
||||
bool MetricsLibrary::oaConfigurationDeactivate(
|
||||
const ConfigurationHandle_1_0 &handle) {
|
||||
return api->functions.ConfigurationDeactivate(
|
||||
handle) == StatusCode::Success;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// FUNCTION: MetricsLibrary::userConfigurationCreate
|
||||
//////////////////////////////////////////////////////
|
||||
bool MetricsLibrary::userConfigurationCreate(
|
||||
const ContextHandle_1_0 &context,
|
||||
ConfigurationHandle_1_0 &handle) {
|
||||
ConfigurationCreateData_1_0 data = {};
|
||||
data.HandleContext = context;
|
||||
data.Type = ObjectType::ConfigurationHwCountersUser;
|
||||
|
||||
return api->functions.ConfigurationCreate(
|
||||
&data,
|
||||
&handle) == StatusCode::Success;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// FUNCTION: MetricsLibrary::userConfigurationDelete
|
||||
//////////////////////////////////////////////////////
|
||||
bool MetricsLibrary::userConfigurationDelete(
|
||||
const ConfigurationHandle_1_0 &handle) {
|
||||
return api->functions.ConfigurationDelete(handle) == StatusCode::Success;
|
||||
}
|
||||
} // namespace NEO
|
||||
@@ -7,31 +7,82 @@
|
||||
|
||||
#include "performance_counters_win.h"
|
||||
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/helpers/hw_helper.h"
|
||||
#include "runtime/os_interface/windows/os_interface.h"
|
||||
#include "runtime/os_interface/windows/windows_wrapper.h"
|
||||
#include "runtime/os_interface/windows/os_time_win.h"
|
||||
|
||||
namespace NEO {
|
||||
std::unique_ptr<PerformanceCounters> PerformanceCounters::create(OSTime *osTime) {
|
||||
return std::unique_ptr<PerformanceCounters>(new PerformanceCountersWin(osTime));
|
||||
}
|
||||
PerformanceCountersWin::PerformanceCountersWin(OSTime *osTime) : PerformanceCounters(osTime) {
|
||||
cbData.hAdapter = (void *)(UINT_PTR)osInterface->get()->getAdapterHandle();
|
||||
cbData.hDevice = (void *)(UINT_PTR)osInterface->get()->getDeviceHandle();
|
||||
cbData.pfnEscapeCb = osInterface->get()->getEscapeHandle();
|
||||
/////////////////////////////////////////////////////
|
||||
// PerformanceCounters::create
|
||||
/////////////////////////////////////////////////////
|
||||
std::unique_ptr<PerformanceCounters> PerformanceCounters::create(Device *device) {
|
||||
auto counter = std::make_unique<PerformanceCountersWin>();
|
||||
auto osInterface = device->getOSTime()->getOSInterface()->get();
|
||||
auto gen = device->getHardwareInfo().platform.eRenderCoreFamily;
|
||||
auto &hwHelper = HwHelper::get(gen);
|
||||
UNRECOVERABLE_IF(counter == nullptr);
|
||||
|
||||
counter->clientData.Windows.Adapter = reinterpret_cast<void *>(static_cast<UINT_PTR>(osInterface->getAdapterHandle()));
|
||||
counter->clientData.Windows.Device = reinterpret_cast<void *>(static_cast<UINT_PTR>(osInterface->getDeviceHandle()));
|
||||
counter->clientData.Windows.Device = reinterpret_cast<void *>(static_cast<UINT_PTR>(osInterface->getDeviceHandle()));
|
||||
counter->clientData.Windows.Escape = osInterface->getEscapeHandle();
|
||||
counter->clientData.Windows.KmdInstrumentationEnabled = device->getHardwareInfo().capabilityTable.instrumentationEnabled;
|
||||
counter->contextData.ClientData = &counter->clientData;
|
||||
counter->clientType.Gen = static_cast<MetricsLibraryApi::ClientGen>(hwHelper.getMetricsLibraryGenId());
|
||||
|
||||
return counter;
|
||||
}
|
||||
|
||||
PerformanceCountersWin::~PerformanceCountersWin() {
|
||||
if (pAutoSamplingInterface) {
|
||||
autoSamplingStopFunc(&pAutoSamplingInterface);
|
||||
pAutoSamplingInterface = nullptr;
|
||||
available = false;
|
||||
//////////////////////////////////////////////////////
|
||||
// PerformanceCountersWin::enableCountersConfiguration
|
||||
//////////////////////////////////////////////////////
|
||||
bool PerformanceCountersWin::enableCountersConfiguration() {
|
||||
// Release previous counters configuration so the user
|
||||
// can change configuration between kernels.
|
||||
releaseCountersConfiguration();
|
||||
|
||||
// Create mmio user configuration.
|
||||
if (!metricsLibrary->userConfigurationCreate(
|
||||
context,
|
||||
userConfiguration)) {
|
||||
DEBUG_BREAK_IF(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create oa configuration.
|
||||
if (!metricsLibrary->oaConfigurationCreate(
|
||||
context,
|
||||
oaConfiguration)) {
|
||||
DEBUG_BREAK_IF(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enable oa configuration.
|
||||
if (!metricsLibrary->oaConfigurationActivate(
|
||||
oaConfiguration)) {
|
||||
DEBUG_BREAK_IF(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// PerformanceCountersWin::releaseCountersConfiguration
|
||||
//////////////////////////////////////////////////////
|
||||
void PerformanceCountersWin::releaseCountersConfiguration() {
|
||||
// Mmio user configuration.
|
||||
if (userConfiguration.IsValid()) {
|
||||
metricsLibrary->userConfigurationDelete(userConfiguration);
|
||||
userConfiguration.data = nullptr;
|
||||
}
|
||||
|
||||
// Oa configuration.
|
||||
if (oaConfiguration.IsValid()) {
|
||||
metricsLibrary->oaConfigurationDeactivate(oaConfiguration);
|
||||
metricsLibrary->oaConfigurationDelete(oaConfiguration);
|
||||
oaConfiguration.data = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void PerformanceCountersWin::initialize(const HardwareInfo *hwInfo) {
|
||||
PerformanceCounters::initialize(hwInfo);
|
||||
setAvailableFunc(true);
|
||||
verifyEnableFunc(cbData);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -7,18 +7,18 @@
|
||||
|
||||
#pragma once
|
||||
#include "runtime/os_interface/performance_counters.h"
|
||||
#include "runtime/os_interface/windows/os_interface.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class PerformanceCountersWin : virtual public PerformanceCounters {
|
||||
public:
|
||||
PerformanceCountersWin(OSTime *osTime);
|
||||
~PerformanceCountersWin() override;
|
||||
void initialize(const HardwareInfo *hwInfo) override;
|
||||
PerformanceCountersWin() = default;
|
||||
~PerformanceCountersWin() override = default;
|
||||
|
||||
protected:
|
||||
decltype(&instrSetAvailable) setAvailableFunc = instrSetAvailable;
|
||||
decltype(&instrEscVerifyEnable) verifyEnableFunc = instrEscVerifyEnable;
|
||||
/////////////////////////////////////////////////////
|
||||
// Gpu oa/mmio configuration.
|
||||
/////////////////////////////////////////////////////
|
||||
bool enableCountersConfiguration() override;
|
||||
void releaseCountersConfiguration() override;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
||||
Reference in New Issue
Block a user