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