Program Listing for File metrics-extractor.h
↰ Return to documentation for file (include\playback\data-collection\metrics-extractor.h
)
/******************************************************************************
Copyright (c) 2018 Intel Corporation
This software and the related documents are Intel copyrighted materials,
and your use of them is governed by the express license under which they
were provided to you ("License"). Unless the License provides otherwise,
you may not use, modify, copy, publish, distribute, disclose or transmit
this software or the related documents without Intel's prior written
permission.
This software and the related documents are provided as is, with no express
or implied warranties, other than those that are expressly stated in the
License.
******************************************************************************/
#pragma once
#include "igpa-config.h"
#include "metrics/query-manager.h"
#include "metrics/types.h"
#include "playback/callable-receiver.h"
#include "playback/callable-broadcaster.h"
#include "playback/data-collection/metrics-query-result.h"
#include "playback/data-collection/metrics-requests.h"
#include "runtime/event-publisher.h"
#include <memory>
#include <utility>
#include <vector>
namespace gpa {
namespace data_collection {
class CollectionRange;
class MetricsRequest;
} // namespace data_collection
namespace metrics {
class IMetric;
class IMetricsSource;
class IMetricsSourceComposite;
} // namespace metrics
namespace playback {
typedef std::vector<metrics::IQueryManager*> QueryManagerVector;
struct DeviceQueryManagers
{
void* device;
QueryManagerVector queryManagerVector;
};
typedef std::vector<DeviceQueryManagers> DeviceQueryManagersVector;
struct MetricsResources
{
metrics::IMetricsSourceComposite* metricsSourceComposite;
DeviceQueryManagersVector deviceQueryManagersVector;
};
class RangeObjectAccessor;
class MetricsExtractor
: public CallableReceiver,
public runtime::EventPublisher::Subscriber,
public CallableCallbacks
{
public:
MetricsExtractor();
~MetricsExtractor();
// CallableReceiver overrides
void PostSetupRange(CallableCache* range) override;
void PreExecuteRange(CallableCache* range) override;
void PreExecuteCall(Callable* callable, uint64_t callIndex) override;
void PostExecuteCall(Callable* callable, uint64_t callIndex) override;
void BeforePostExecuteRange(QueuesRequiringGpuSynchronization& queuesToSynchronize) override;
void PostExecuteRange(CallableCache* range) override;
// EventPublisher::Subscriber implementation
void OnEvent(char const* topic, runtime::EventData const& event) override;
bool SetRangeAndApiForCollection(CallableCache* range, uint32_t graphicsApi);
void SetRequest(data_collection::MetricsRequest const* request);
void SetQueryReportOfInterestEvaluationCallback(
metrics::QueryReportOfInterestEvaluationCallback* pCallback = nullptr,
void* userData = nullptr);
data_collection::MetricsQueryResult GetResult();
data_collection::MetricsRequests GetRequestsForMetrics(
metrics::IMetric const** metrics, uint64_t nMetrics,
data_collection::CollectionRange const* collectionRanges, uint64_t nRanges,
bool freqOverrideEnabled = false, float freqOverrideVal = 1.0f) const;
data_collection::MetricsRequests GetRequestsForMetrics(
metrics::MetricId const* metricIDs, uint64_t nMetricIDs,
data_collection::CollectionRange const* collectionRanges, uint64_t nRanges,
bool freqOverrideEnabled = false, float freqOverrideVal = 1.0f) const;
metrics::IMetricsSource* GetMetricsSource();
metrics::IMetricsSourceComposite* GetMetricsSourceComposite();
private:
struct QueryConfig
{
metrics::IQueryManager const* const queryManager = nullptr;
void const* const commandQueue = nullptr;
};
class DeviceContextGuard;
CallableCache* mRange;
std::vector<MetricsResources> mMetricsResourcesVector;
metrics::GraphicsApi mMetricsResourcesGraphicsApi;
MetricsResources* mMetricsResources;
data_collection::MetricsRequest const* mRequest;
metrics::QueryReportOfInterestEvaluationCallback* mQueryReportCallback;
void* mQueryReportCallbackUserData;
QueuesRequiringGpuSynchronization mQueuesRequiringGpuSynchronization;
std::unique_ptr<metrics::CommandBufferData> mCommandBufferData;
std::unique_ptr<DeviceContextGuard> mDeviceContextGuard;
std::unique_ptr<data_collection::MetricsQueryResult> mResult;
metrics::IQueryManager* mSubscribedQueryManager;
uint32_t mSubscriptionStartingMetricIndex;
bool mBeganQuery;
std::vector<QueryConfig> mUnsupportedQueryConfigurations;
bool QueryConfigurationIsSupported(
metrics::IQueryManager const* const queryManager,
void const* const commandQueue) const;
bool UpdateCommandBufferData(uint64_t firstCallIndex, uint64_t lastCallIndex);
std::unique_ptr<DeviceContextGuard> GetD3d11ImmediateDeviceContext(void* commandBuffer);
void CreateMetricsResources(uint32_t api, void* instance, void* physicalDevice, void* device);
bool CreateMatchedMetricsSourceAndQueryManager(
metrics::QueryManagerType queryManagerType,
metrics::GraphicsApi graphicsApi,
metrics::Category categoryFlags,
bool includeExtraGroups,
void* instance,
void* physicalDevice,
void* device,
metrics::IMetricsSourceComposite* pMetricsSourceComposite,
metrics::IMetricsSource** ppMetricsSource,
metrics::IQueryManager** ppQueryManager);
void DestroyQueryManagers(QueryManagerVector& queryManagerVector);
void DestroyMetricsResources(MetricsResources* metricsResources, void* device);
void DestroyAllMetricsResources();
MetricsResources* GetMetricsResourcesForGraphicsApi(metrics::GraphicsApi graphicsApi);
void* GetDeviceForCallable(Callable& callable, uint64_t callIndex);
};
} // namespace playback
} // namespace gpa