Program Listing for File metrics-source.h

Return to documentation for file (include\metrics\metrics-source.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 "metrics/metrics-config.h"

#include "metrics/gpu-id.h"
#include "metrics/types.h"

#include <cstdint>

namespace gpa {
namespace metrics {

class IMetricGroup;

enum class MetricsSourceType {
    kInvalid,
    kQueryBased_Unspecified,

    kQueryBased_GraphicsApi,
    kQueryBased_IntelMD,
    kTimeBased_IntelMD,

    kComposite,
};

struct MetricsSourceData
{
    MetricsSourceType type = MetricsSourceType::kInvalid;
    GraphicsApi graphicsApi = GraphicsApi::kNone;
    Category categoryFlags = Category::kDefault;
    bool includeExtraGroups = false;
    GpuId gpuId = {};
};

class GPA_METRICS_CLASS_EXPORT IMetricsSource
{
public:
    virtual ~IMetricsSource();

    virtual MetricsSourceType Type(MetricsSourceData* pMetricsSourceData = nullptr) const = 0;

    virtual uint32_t NumAvailableMetrics() const = 0;

    virtual MetricDesc const& MetricDescription(uint32_t const metricIndex) const = 0;

    virtual uint32_t NumMetricGroups() const = 0;

    virtual uint32_t NumMetricsInGroup(uint32_t const metricGroupIndex) const = 0;

    virtual int32_t GroupContainingMetric(uint32_t const metricIndex) const = 0;

    virtual IMetricGroup const* MetricGroup(uint32_t metricGroupIndex) const = 0;

    virtual uint32_t NumMetricPrototypes() const = 0;

    virtual Result MetricPrototypeDescription(
        uint32_t const metricPrototypeIndex,
        MetricDesc* const pMetricPrototypeDescription) const = 0;

    virtual Result InstantiateMetricPrototype(
        uint32_t const metricPrototypeIndex,
        char const* pNameOverride,
        char const* pSymbolicNameOverride,
        char const* pDescriptionOverride,
        char const* pUnitsOverride,
        uint32_t optionCount,
        MetricInstanceOption const* pOptionArray,
        uint32_t* pInstantiatedMetricIndex) = 0;

    virtual Result RemoveInstantiatedMetric(uint32_t const instantiatedMetricIndex) = 0;

    virtual Result PrepareInstantiatedMetricsForUsage(
        char const* pGroupNamePrefixOverride,
        char const* pGroupSymbolicNamePrefixOverride) = 0;

    virtual uint32_t NumInstantiatedMetrics() const = 0;

    virtual MetricDesc const& InstantiatedMetricDescription(uint32_t const instantiatedMetricIndex) const = 0;
};

GPA_METRICS_EXPORT
IMetricsSource* CreateMetricsSource(
    MetricsSourceData* pMetricsSourceData,
    char* pErrorMessage = nullptr,
    uint32_t errorSize = 0);

GPA_METRICS_EXPORT
void DestroyMetricsSource(IMetricsSource* pMetricsSource);

}  // namespace metrics
}  // namespace gpa