2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2020-02-22 16:28:27 +08:00
|
|
|
* Copyright (C) 2017-2020 Intel Corporation
|
2018-09-18 15:11:08 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
#pragma once
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/event/perf_counter.h"
|
|
|
|
#include "opencl/source/os_interface/metrics_library.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-04-18 20:59:28 +08:00
|
|
|
#include <mutex>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-05-20 17:19:27 +08:00
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
// Forward declaration.
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
template <typename Node>
|
|
|
|
struct TagNode;
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
// Performance counters implementation.
|
|
|
|
//////////////////////////////////////////////////////
|
2017-12-21 07:45:38 +08:00
|
|
|
class PerformanceCounters {
|
|
|
|
public:
|
2019-05-20 17:19:27 +08:00
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
// Constructor/destructor.
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
PerformanceCounters();
|
2017-12-21 07:45:38 +08:00
|
|
|
virtual ~PerformanceCounters() = default;
|
2019-05-20 17:19:27 +08:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
// Performance counters creation.
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
static std::unique_ptr<PerformanceCounters> create(class Device *device);
|
2019-12-19 17:04:04 +08:00
|
|
|
bool enable(bool ccsEngine);
|
2017-12-21 07:45:38 +08:00
|
|
|
void shutdown();
|
2019-05-20 17:19:27 +08:00
|
|
|
uint32_t getReferenceNumber();
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
// Gpu oa/mmio configuration.
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
virtual bool enableCountersConfiguration() = 0;
|
|
|
|
virtual void releaseCountersConfiguration() = 0;
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
// Gpu commands.
|
|
|
|
//////////////////////////////////////////////////////
|
2019-11-13 21:48:44 +08:00
|
|
|
uint32_t getGpuCommandsSize(const MetricsLibraryApi::GpuCommandBufferType commandBufferType, const bool begin);
|
|
|
|
bool getGpuCommands(const MetricsLibraryApi::GpuCommandBufferType commandBufferType, TagNode<HwPerfCounter> &performanceCounters, const bool begin, const uint32_t bufferSize, void *pBuffer);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-05-20 17:19:27 +08:00
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
// Gpu/Api reports.
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
uint32_t getApiReportSize();
|
|
|
|
uint32_t getGpuReportSize();
|
|
|
|
bool getApiReport(const size_t inputParamSize, void *pClientData, size_t *pOutputSize, bool isEventComplete);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-05-20 17:19:27 +08:00
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
// Metrics Library interface.
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
MetricsLibrary *getMetricsLibraryInterface();
|
|
|
|
void setMetricsLibraryInterface(std::unique_ptr<MetricsLibrary> newMetricsLibrary);
|
|
|
|
bool openMetricsLibrary();
|
|
|
|
void closeMetricsLibrary();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-05-20 17:19:27 +08:00
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
// Metrics Library context/query handles.
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
ContextHandle_1_0 getMetricsLibraryContext();
|
|
|
|
QueryHandle_1_0 getQueryHandle();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
protected:
|
2019-05-20 17:19:27 +08:00
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
// Common members.
|
|
|
|
/////////////////////////////////////////////////////
|
2017-12-21 07:45:38 +08:00
|
|
|
std::mutex mutex;
|
2019-05-20 17:19:27 +08:00
|
|
|
uint32_t referenceCounter = 0;
|
|
|
|
bool available = false;
|
2019-12-19 17:04:04 +08:00
|
|
|
bool usingCcsEngine = false;
|
2019-05-20 17:19:27 +08:00
|
|
|
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
// Metrics Library interface.
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
std::unique_ptr<MetricsLibrary> metricsLibrary = {};
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
// Metrics Library client data.
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
ClientData_1_0 clientData = {};
|
|
|
|
ClientType_1_0 clientType = {ClientApi::OpenCL, ClientGen::Unknown};
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
// Metrics Library context.
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
ContextCreateData_1_0 contextData = {};
|
|
|
|
ContextHandle_1_0 context = {};
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
// Metrics Library oa/mmio counters configuration.
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
ConfigurationHandle_1_0 oaConfiguration = {};
|
|
|
|
ConfigurationHandle_1_0 userConfiguration = {};
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
// Metrics Library query object.
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
QueryHandle_1_0 query = {};
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|