2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2024-10-22 20:56:08 +08:00
|
|
|
* Copyright (C) 2018-2024 Intel Corporation
|
2018-09-18 15:11:08 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
#include "performance_counters_win.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/device/device.h"
|
2023-02-02 00:23:01 +08:00
|
|
|
#include "shared/source/helpers/gfx_core_helper.h"
|
2023-02-06 17:05:43 +08:00
|
|
|
#include "shared/source/helpers/hw_info.h"
|
2021-05-21 07:17:57 +08:00
|
|
|
#include "shared/source/os_interface/os_interface.h"
|
|
|
|
#include "shared/source/os_interface/windows/wddm/wddm.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2019-05-20 17:19:27 +08:00
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
// PerformanceCounters::create
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
std::unique_ptr<PerformanceCounters> PerformanceCounters::create(Device *device) {
|
|
|
|
auto counter = std::make_unique<PerformanceCountersWin>();
|
2023-10-18 16:00:43 +08:00
|
|
|
auto wddm = device->getRootDeviceEnvironment().osInterface->getDriverModel()->as<Wddm>();
|
2022-12-09 23:11:27 +08:00
|
|
|
auto &gfxCoreHelper = device->getGfxCoreHelper();
|
2019-05-20 17:19:27 +08:00
|
|
|
UNRECOVERABLE_IF(counter == nullptr);
|
|
|
|
|
2021-05-21 07:17:57 +08:00
|
|
|
counter->clientData.Windows.Adapter = reinterpret_cast<void *>(static_cast<UINT_PTR>(wddm->getAdapter()));
|
|
|
|
counter->clientData.Windows.Device = reinterpret_cast<void *>(static_cast<UINT_PTR>(wddm->getDeviceHandle()));
|
2023-10-20 22:34:45 +08:00
|
|
|
counter->clientData.Windows.Escape = reinterpret_cast<void *>(wddm->getEscapeHandle());
|
2019-05-20 17:19:27 +08:00
|
|
|
counter->clientData.Windows.KmdInstrumentationEnabled = device->getHardwareInfo().capabilityTable.instrumentationEnabled;
|
|
|
|
counter->contextData.ClientData = &counter->clientData;
|
2022-12-08 20:22:35 +08:00
|
|
|
counter->clientType.Gen = static_cast<MetricsLibraryApi::ClientGen>(gfxCoreHelper.getMetricsLibraryGenId());
|
2024-10-22 20:56:08 +08:00
|
|
|
counter->metricsLibrary->api->callbacks.CommandBufferFlush = &PerformanceCounters::flushCommandBufferCallback;
|
|
|
|
counter->clientData.Handle = reinterpret_cast<void *>(device);
|
2019-05-20 17:19:27 +08:00
|
|
|
|
|
|
|
return counter;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2019-05-20 17:19:27 +08:00
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
// PerformanceCountersWin::enableCountersConfiguration
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
bool PerformanceCountersWin::enableCountersConfiguration() {
|
|
|
|
// Release previous counters configuration so the user
|
|
|
|
// can change configuration between kernels.
|
|
|
|
releaseCountersConfiguration();
|
|
|
|
|
|
|
|
// Create oa configuration.
|
|
|
|
if (!metricsLibrary->oaConfigurationCreate(
|
|
|
|
context,
|
|
|
|
oaConfiguration)) {
|
|
|
|
DEBUG_BREAK_IF(true);
|
|
|
|
return false;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2019-05-20 17:19:27 +08:00
|
|
|
// Enable oa configuration.
|
|
|
|
if (!metricsLibrary->oaConfigurationActivate(
|
|
|
|
oaConfiguration)) {
|
|
|
|
DEBUG_BREAK_IF(true);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2019-05-20 17:19:27 +08:00
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
// PerformanceCountersWin::releaseCountersConfiguration
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
void PerformanceCountersWin::releaseCountersConfiguration() {
|
|
|
|
|
|
|
|
// Oa configuration.
|
|
|
|
if (oaConfiguration.IsValid()) {
|
|
|
|
metricsLibrary->oaConfigurationDeactivate(oaConfiguration);
|
|
|
|
metricsLibrary->oaConfigurationDelete(oaConfiguration);
|
|
|
|
oaConfiguration.data = nullptr;
|
|
|
|
}
|
|
|
|
}
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|