/* Autogenerated file, DO NOT EDIT manually! generated by oa-metricset-codegen.py */
// SPDX-License-Identifier: MIT
/*
 * Copyright © 2024 Intel Corporation
 */

#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>

#include "xe_oa_metrics_cri.h"
#include "xe_oa_equations.h"
#include "xe_oa_registers_cri.h"


static void
cri_add_compute_basic_metric_set(struct intel_xe_perf *perf)
{
    struct intel_xe_perf_metric_set *metric_set;
    struct intel_xe_perf_logical_counter *counter;

    metric_set = calloc(1, sizeof(*metric_set));
    metric_set->name = "ComputeBasic";
    metric_set->symbol_name = "ComputeBasic";
    metric_set->hw_config_guid = "9fc46cf1-92cd-4dd7-99cc-d349ed779980";
    metric_set->counters = calloc(66, sizeof(struct intel_xe_perf_logical_counter));
    metric_set->n_counters = 0;
    metric_set->perf_oa_metrics_set = 0; // determined at runtime
    metric_set->perf_oa_format = XE_OA_FORMAT_PEC64u64;
    metric_set->perf_raw_size = 576;
    metric_set->gpu_time_offset = 0;
    metric_set->gpu_clock_offset = 1;
    metric_set->pec_offset = 2;
    cri_compute_basic_add_registers(perf, metric_set);
    intel_xe_perf_add_metric_set(perf, metric_set);

    {
        static const struct intel_xe_perf_logical_counter _counters[] = {

            {
                .name = "Async GpGpu Threadgroup Count",
                .symbol_name = "ASYNC_GPGPU_THREADGROUP_COUNT",
                .desc = "Number of Async GPGPU threadgroups dispatched",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__async_gpgpu_threadgroup_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Thread Dispatcher",
            },

            {
                .name = "Async GpGpu Thread Exit Count",
                .symbol_name = "ASYNC_GPGPU_THREAD_EXIT_COUNT",
                .desc = "Number of Async GPGPU EOT messages received",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_MESSAGES,
                .read_uint64 = cri__compute_basic__async_gpgpu_thread_exit_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Thread Dispatcher",
            },

            {
                .name = "AVG GPU Core Frequency",
                .symbol_name = "AvgGpuCoreFrequency",
                .desc = "Average GPU Core Frequency in the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_HZ,
                .read_uint64 = cri__compute_basic__avg_gpu_core_frequency__read,
                .max_uint64 = cri__compute_basic__avg_gpu_core_frequency__max,
                .group = "GPU",
            },

            {
                .name = "Command Parser Compute Engine Busy",
                .symbol_name = "COMMAND_PARSER_COMPUTE_ENGINE_BUSY",
                .desc = "Percentage of time in which there is a context loaded and active on the compute queue",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__compute_basic__command_parser_compute_engine_busy__read,
                .max_float = NULL /* undefined */,
                .group = "Front End",
            },

            {
                .name = "Command Parser Compute Engine Dispatch Kernel Count",
                .symbol_name = "COMMAND_PARSER_COMPUTE_ENGINE_DISPATCH_KERNEL_COUNT",
                .desc = "Number of compute walker commands parsed on the compute engine",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__command_parser_compute_engine_dispatch_kernel_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Front End",
            },

            {
                .name = "Command Parser Copy Engine Busy",
                .symbol_name = "COMMAND_PARSER_COPY_ENGINE_BUSY",
                .desc = "Percentage of time in which there is a context loaded and active on the copy queue.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__compute_basic__command_parser_copy_engine_busy__read,
                .max_float = NULL /* undefined */,
                .group = "Front End",
            },

            {
                .name = "Command Parser Flush Count",
                .symbol_name = "COMMAND_PARSER_FLUSH_COUNT",
                .desc = "Number of Stalling flushes at the top of the pipe",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__command_parser_flush_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Front End",
            },

            {
                .name = "Compressor Input",
                .symbol_name = "COMPRESSOR_INPUT",
                .desc = "Number of 256B writes to compressible surfaces at the input of the compressor",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__compressor_input__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Memory",
            },

            {
                .name = "Compressor Output",
                .symbol_name = "COMPRESSOR_OUTPUT",
                .desc = "Number of 256B writes to compressible surfaces at the output of the compressor",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__compressor_output__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Memory",
            },

            {
                .name = "Copy Engine Read Request",
                .symbol_name = "COPY_ENGINE_READ_REQUEST",
                .desc = "Number of read requests sent by the Copy Engine",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__copy_engine_read_request__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Copy Engine",
            },

            {
                .name = "Copy Engine Request Stall",
                .symbol_name = "COPY_ENGINE_REQUEST_STALL",
                .desc = "Percentage of time in which copy engine is stalled on the memory path due to stall on the read or write path when there are commands pending within copy engine",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__compute_basic__copy_engine_request_stall__read,
                .max_float = NULL /* undefined */,
                .group = "Copy Engine",
            },

            {
                .name = "Copy Engine Write Request",
                .symbol_name = "COPY_ENGINE_WRITE_REQUEST",
                .desc = "Number of write requests sent by the Copy Engine",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__copy_engine_write_request__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Copy Engine",
            },

            {
                .name = "GpGpu Dispatch",
                .symbol_name = "GPGPU_DISPATCH",
                .desc = "Percentage of time in which spent dispatching GPGPU threads to XVEs",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__compute_basic__gpgpu_dispatch__read,
                .max_float = NULL /* undefined */,
                .group = "Thread Dispatcher",
            },

            {
                .name = "GPU Busy",
                .symbol_name = "GPU_BUSY",
                .desc = "Percentage of time in which GPU is not idle including all GPU engines",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__compute_basic__gpu_busy__read,
                .max_float = NULL /* undefined */,
                .group = "Front End",
            },

            {
                .name = "GPU Memory Active",
                .symbol_name = "GPU_MEMORY_ACTIVE",
                .desc = "Percentage of time in which local memory is active",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__compute_basic__gpu_memory_active__read,
                .max_float = NULL /* undefined */,
                .group = "Device Cache",
            },

            {
                .name = "GPU Memory Byte Read",
                .symbol_name = "GPU_MEMORY_BYTE_READ",
                .desc = "Number of device local memory (HBM, GDDR, LPDDR, etc.) read bytes",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_BYTES,
                .read_uint64 = cri__compute_basic__gpu_memory_byte_read__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Device Cache",
            },

            {
                .name = "GPU Memory Byte Write",
                .symbol_name = "GPU_MEMORY_BYTE_WRITE",
                .desc = "Number of device local memory (HBM, GDDR, LPDDR, etc.) write bytes",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_BYTES,
                .read_uint64 = cri__compute_basic__gpu_memory_byte_write__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Device Cache",
            },

            {
                .name = "GPU Memory Read",
                .symbol_name = "GPU_MEMORY_READ",
                .desc = "Number of local memory reads",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__gpu_memory_read__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Device Cache",
            },

            {
                .name = "GPU Memory Write",
                .symbol_name = "GPU_MEMORY_WRITE",
                .desc = "Number of local memory writes",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__gpu_memory_write__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Device Cache",
            },

            {
                .name = "GPU Core Clocks",
                .symbol_name = "GpuCoreClocks",
                .desc = "The total number of GPU core clocks elapsed during the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__compute_basic__gpu_core_clocks__read,
                .max_uint64 = NULL /* undefined */,
                .group = "GPU",
            },

            {
                .name = "GPU Time Elapsed",
                .symbol_name = "GpuTime",
                .desc = "Time elapsed on the GPU during the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_NS,
                .read_uint64 = cri__compute_basic__gpu_time__read,
                .max_uint64 = NULL /* undefined */,
                .group = "GPU",
            },

            {
                .name = "ICache Hit",
                .symbol_name = "ICACHE_HIT",
                .desc = "Number of Instruction Cache hits",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__icache_hit__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "ICache Miss",
                .symbol_name = "ICACHE_MISS",
                .desc = "Number of Instruction Cache misses",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__icache_miss__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "L3 Atomic Access",
                .symbol_name = "L3_ATOMIC_ACCESS",
                .desc = "Number of atomic accesses to Device Cache bank",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__l3_atomic_access__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Device Cache",
            },

            {
                .name = "L3 Byte Read",
                .symbol_name = "L3_BYTE_READ",
                .desc = "Number of Device Cache bytes read",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_THROUGHPUT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_BYTES,
                .read_uint64 = cri__compute_basic__l3_byte_read__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Device Cache",
            },

            {
                .name = "L3 Byte Write",
                .symbol_name = "L3_BYTE_WRITE",
                .desc = "Number of Device Cache bytes written",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_THROUGHPUT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_BYTES,
                .read_uint64 = cri__compute_basic__l3_byte_write__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Device Cache",
            },

            {
                .name = "L3 Hit",
                .symbol_name = "L3_HIT",
                .desc = "Number of Device Cache accesses which hits in the Device Cache cache",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__l3_hit__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Device Cache",
            },

            {
                .name = "L3 Miss",
                .symbol_name = "L3_MISS",
                .desc = "Number of Device Cache accesses which miss in the Device Cache cache",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__l3_miss__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Device Cache",
            },

            {
                .name = "L3 Read",
                .symbol_name = "L3_READ",
                .desc = "Number of Device Cache 64B read requests",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__l3_read__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Device Cache",
            },

            {
                .name = "L3 Superq Full",
                .symbol_name = "L3_SUPERQ_FULL",
                .desc = "Percentage of time in which all slots in Device Cache request queue are waiting for data return / response",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__compute_basic__l3_superq_full__read,
                .max_float = NULL /* undefined */,
                .group = "Device Cache",
            },

            {
                .name = "L3 Write",
                .symbol_name = "L3_WRITE",
                .desc = "Number of Device Cache 64B write requests",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__l3_write__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Device Cache",
            },

            {
                .name = "Load Store Cache Access",
                .symbol_name = "LOAD_STORE_CACHE_ACCESS",
                .desc = "Number of Load Store Cache accesses",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__load_store_cache_access__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "Load Store Cache Byte Read",
                .symbol_name = "LOAD_STORE_CACHE_BYTE_READ",
                .desc = "Number of bytes read out of the Load Store Cache, excluding SLM accesses",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_BYTES,
                .read_uint64 = cri__compute_basic__load_store_cache_byte_read__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "Load Store Cache Byte Write",
                .symbol_name = "LOAD_STORE_CACHE_BYTE_WRITE",
                .desc = "Number of bytes written to the Load Store Cache, excluding SLM accesses",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_BYTES,
                .read_uint64 = cri__compute_basic__load_store_cache_byte_write__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "Load Store Cache Hit",
                .symbol_name = "LOAD_STORE_CACHE_HIT",
                .desc = "Number of Load Store Cache hits",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__load_store_cache_hit__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "Load Store Cache Partial Write Count",
                .symbol_name = "LOAD_STORE_CACHE_PARTIAL_WRITE_COUNT",
                .desc = "Number of writes to the Load Store Cache that don't fill a subsector",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__load_store_cache_partial_write_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "SLM Bank Conflict Count",
                .symbol_name = "SLM_BANK_CONFLICT_COUNT",
                .desc = "Number of SLM accesses resulting in a bank conflict",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__slm_bank_conflict_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "SLM Byte Read",
                .symbol_name = "SLM_BYTE_READ",
                .desc = "Number of bytes read from SLM",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_BYTES,
                .read_uint64 = cri__compute_basic__slm_byte_read__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "SLM Byte Write",
                .symbol_name = "SLM_BYTE_WRITE",
                .desc = "Number of bytes written to SLM",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_BYTES,
                .read_uint64 = cri__compute_basic__slm_byte_write__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "TLB Miss",
                .symbol_name = "TLB_MISS",
                .desc = "Number of misses from all TLBs and all engines",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__tlb_miss__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Memory",
            },

            {
                .name = "TLB Page Size 1g",
                .symbol_name = "TLB_PAGE_SIZE_1G",
                .desc = "Number of TLB accesses to pages of size 1 GB",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__tlb_page_size_1_g__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Memory",
            },

            {
                .name = "TLB Page Size 2m",
                .symbol_name = "TLB_PAGE_SIZE_2M",
                .desc = "Number of TLB accesses to pages of size 2 MB",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__tlb_page_size_2_m__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Memory",
            },

            {
                .name = "TLB Page Size 4k",
                .symbol_name = "TLB_PAGE_SIZE_4K",
                .desc = "Number of TLB accesses to pages of size 4 KB",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__tlb_page_size_4_k__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Memory",
            },

            {
                .name = "TLB Page Size 64k",
                .symbol_name = "TLB_PAGE_SIZE_64K",
                .desc = "Number of TLB accesses to pages of size 64 KB",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__tlb_page_size_64_k__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Memory",
            },

            {
                .name = "XVE Active",
                .symbol_name = "XVE_ACTIVE",
                .desc = "Percentage of time in which at least one pipe is active in XVE",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__compute_basic__xve_active__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Grfblock Occupancy All",
                .symbol_name = "XVE_GRFBLOCK_OCCUPANCY_ALL",
                .desc = "Number of GRF register blocks occupied",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__xve_grfblock_occupancy_all__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed ALU0 All",
                .symbol_name = "XVE_INST_EXECUTED_ALU0_ALL",
                .desc = "Number of execution slots taken by instructions executed on ALU0 pipe",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__xve_inst_executed_alu0_all__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed ALU0 All Utilization",
                .symbol_name = "XVE_INST_EXECUTED_ALU0_ALL_UTILIZATION",
                .desc = "Percentage of time taken by instructions executed on ALU0 pipe",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__compute_basic__xve_inst_executed_alu0_all_utilization__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed ALU1 All",
                .symbol_name = "XVE_INST_EXECUTED_ALU1_ALL",
                .desc = "Number of execution slots taken by instructions executed on ALU1 pipe. Does not include extended math instructions.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__xve_inst_executed_alu1_all__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed ALU1 All Utilization",
                .symbol_name = "XVE_INST_EXECUTED_ALU1_ALL_UTILIZATION",
                .desc = "Percentage of time taken by instructions executed on ALU1 pipe. Does not include extended math instructions.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__compute_basic__xve_inst_executed_alu1_all_utilization__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed ALU2 All",
                .symbol_name = "XVE_INST_EXECUTED_ALU2_ALL",
                .desc = "Number of execution slots taken by instructions executed in ALU2 pipe",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__xve_inst_executed_alu2_all__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed ALU2 All Utilization",
                .symbol_name = "XVE_INST_EXECUTED_ALU2_ALL_UTILIZATION",
                .desc = "Percentage of time taken by instructions executed in ALU2 pipe",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__compute_basic__xve_inst_executed_alu2_all_utilization__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed ALU3 All",
                .symbol_name = "XVE_INST_EXECUTED_ALU3_ALL",
                .desc = "Number of execution slots taken by instructions executed in ALU3 pipe",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__xve_inst_executed_alu3_all__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed Barrier",
                .symbol_name = "XVE_INST_EXECUTED_BARRIER",
                .desc = "Number of sync.bar and sync.host instructions executed",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__xve_inst_executed_barrier__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed Send All",
                .symbol_name = "XVE_INST_EXECUTED_SEND_ALL",
                .desc = "Number of instruction (GRF or SRF) dispatches executed on SEND Pipe",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__xve_inst_executed_send_all__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Issued All",
                .symbol_name = "XVE_INST_ISSUED_ALL",
                .desc = "Number of instructions issued (decoded) to any pipe",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__xve_inst_issued_all__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Lane Enabled",
                .symbol_name = "XVE_INST_LANE_ENABLED",
                .desc = "Number of execution lanes enabled for instructions executed on ALU0 and ALU1. Does not include control-flow instructions such as CALL, CALLA, RET, etc.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__xve_inst_lane_enabled__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Lane Total",
                .symbol_name = "XVE_INST_LANE_TOTAL",
                .desc = "Number of available execution lanes (enabled and not enabled) for instructions executed on ALU0 and ALU1, evaluated after shootdown. Does not include control-flow instructions such as CALL, CALLA, RET, etc.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__xve_inst_lane_total__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Multiple Pipe Active",
                .symbol_name = "XVE_MULTIPLE_PIPE_ACTIVE",
                .desc = "Percentage of time in which at least two pipes are actively executing a Gen ISA instruction among ALU0, ALU1, ALU2 and ALU3 pipes",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__compute_basic__xve_multiple_pipe_active__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Op Fp32",
                .symbol_name = "XVE_OP_FP32",
                .desc = "Number of effective 32-bit floating-point operations (FLOPs) executed on ALU0 and ALU1",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__xve_op_fp32__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Op Fp64",
                .symbol_name = "XVE_OP_FP64",
                .desc = "Number of effective 64-bit floating-point operations (FLOPs) executed on ALU0 and ALU1",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__compute_basic__xve_op_fp64__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Pipe ALU0 And ALU1 Active",
                .symbol_name = "XVE_PIPE_ALU0_AND_ALU1_ACTIVE",
                .desc = "Percentage of time in which ALU0 and ALU1 pipes are both actively executing a Gen ISA instruction",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__compute_basic__xve_pipe_alu0_and_alu1_active__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Pipe ALU0 And ALU2 Active",
                .symbol_name = "XVE_PIPE_ALU0_AND_ALU2_ACTIVE",
                .desc = "Percentage of time in which ALU0 and ALU2 pipes are both actively executing a Gen ISA instruction",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__compute_basic__xve_pipe_alu0_and_alu2_active__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Shared Function Access Hold",
                .symbol_name = "XVE_SHARED_FUNCTION_ACCESS_HOLD",
                .desc = "Percentage of time in which XVE requests stalled by Shared Function units",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__compute_basic__xve_shared_function_access_hold__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Stall",
                .symbol_name = "XVE_STALL",
                .desc = "Percentage of time in which any thread loaded but not even a single pipe is active in XVE",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__compute_basic__xve_stall__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Threads Occupancy All",
                .symbol_name = "XVE_THREADS_OCCUPANCY_ALL",
                .desc = "Percentage of thread slots occupied",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__compute_basic__xve_threads_occupancy_all__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },
        };
        int i;
        for (i = 0; i < sizeof(_counters) / sizeof(_counters[0]); i++) {
            if (_counters[i].availability && !_counters[i].availability(perf))
                continue;
            counter = &metric_set->counters[metric_set->n_counters++];
            *counter = _counters[i];
            counter->metric_set = metric_set;
            intel_xe_perf_add_logical_counter(perf, counter, counter->group);
        }
    }

    assert(metric_set->n_counters <= 66);
}


static void
cri_add_l1_profile_metric_set(struct intel_xe_perf *perf)
{
    struct intel_xe_perf_metric_set *metric_set;
    struct intel_xe_perf_logical_counter *counter;

    metric_set = calloc(1, sizeof(*metric_set));
    metric_set->name = "L1Profile";
    metric_set->symbol_name = "L1Profile";
    metric_set->hw_config_guid = "e658f5ac-8ace-4951-8f44-0cb77cac3afe";
    metric_set->counters = calloc(39, sizeof(struct intel_xe_perf_logical_counter));
    metric_set->n_counters = 0;
    metric_set->perf_oa_metrics_set = 0; // determined at runtime
    metric_set->perf_oa_format = XE_OA_FORMAT_PEC64u64;
    metric_set->perf_raw_size = 576;
    metric_set->gpu_time_offset = 0;
    metric_set->gpu_clock_offset = 1;
    metric_set->pec_offset = 2;
    cri_l1_profile_add_registers(perf, metric_set);
    intel_xe_perf_add_metric_set(perf, metric_set);

    {
        static const struct intel_xe_perf_logical_counter _counters[] = {

            {
                .name = "Async GpGpu Threadgroup Count",
                .symbol_name = "ASYNC_GPGPU_THREADGROUP_COUNT",
                .desc = "Number of Async GPGPU threadgroups dispatched",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__l1_profile__async_gpgpu_threadgroup_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Thread Dispatcher",
            },

            {
                .name = "AVG GPU Core Frequency",
                .symbol_name = "AvgGpuCoreFrequency",
                .desc = "Average GPU Core Frequency in the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_HZ,
                .read_uint64 = cri__l1_profile__avg_gpu_core_frequency__read,
                .max_uint64 = cri__l1_profile__avg_gpu_core_frequency__max,
                .group = "GPU",
            },

            {
                .name = "Global Overlapped Atomic Access Count",
                .symbol_name = "GLOBAL_OVERLAPPED_ATOMIC_ACCESS_COUNT",
                .desc = "Number of overlapped global memory atomic accesses within a message",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__l1_profile__global_overlapped_atomic_access_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "GPU Busy",
                .symbol_name = "GPU_BUSY",
                .desc = "Percentage of time in which GPU is not idle including all GPU engines",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__l1_profile__gpu_busy__read,
                .max_float = NULL /* undefined */,
                .group = "Front End",
            },

            {
                .name = "GPU Core Clocks",
                .symbol_name = "GpuCoreClocks",
                .desc = "The total number of GPU core clocks elapsed during the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__l1_profile__gpu_core_clocks__read,
                .max_uint64 = NULL /* undefined */,
                .group = "GPU",
            },

            {
                .name = "GPU Time Elapsed",
                .symbol_name = "GpuTime",
                .desc = "Time elapsed on the GPU during the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_NS,
                .read_uint64 = cri__l1_profile__gpu_time__read,
                .max_uint64 = NULL /* undefined */,
                .group = "GPU",
            },

            {
                .name = "ICache L3 Hit",
                .symbol_name = "ICACHE_L3_HIT",
                .desc = "Number of XVE instruction cache requests that hit the Device Cache",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__l1_profile__icache_l3_hit__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Device Cache",
            },

            {
                .name = "ICache L3 Read",
                .symbol_name = "ICACHE_L3_READ",
                .desc = "Number of Device Cache read requests coming from XVE Instruction Cache",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__l1_profile__icache_l3_read__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Device Cache",
            },

            {
                .name = "L3 Busy",
                .symbol_name = "L3_BUSY",
                .desc = "Percentage of time in which Device Cache request queue has one or more requests pending",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__l1_profile__l3_busy__read,
                .max_float = NULL /* undefined */,
                .group = "Device Cache",
            },

            {
                .name = "L3 Input Available",
                .symbol_name = "L3_INPUT_AVAILABLE",
                .desc = "Percentage of time in which Device Cache bank has input requests",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__l1_profile__l3_input_available__read,
                .max_float = NULL /* undefined */,
                .group = "Device Cache",
            },

            {
                .name = "L3 Output Ready",
                .symbol_name = "L3_OUTPUT_READY",
                .desc = "Percentage of time in which Device Cache bank has output ready",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__l1_profile__l3_output_ready__read,
                .max_float = NULL /* undefined */,
                .group = "Device Cache",
            },

            {
                .name = "L3 Stall",
                .symbol_name = "L3_STALL",
                .desc = "Percentage of time in which Device Cache bank stalled",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__l1_profile__l3_stall__read,
                .max_float = NULL /* undefined */,
                .group = "Device Cache",
            },

            {
                .name = "Load Store Cache Access",
                .symbol_name = "LOAD_STORE_CACHE_ACCESS",
                .desc = "Number of Load Store Cache accesses",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__l1_profile__load_store_cache_access__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "Load Store Cache Byte Read",
                .symbol_name = "LOAD_STORE_CACHE_BYTE_READ",
                .desc = "Number of bytes read out of the Load Store Cache, excluding SLM accesses",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_BYTES,
                .read_uint64 = cri__l1_profile__load_store_cache_byte_read__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "Load Store Cache Byte Write",
                .symbol_name = "LOAD_STORE_CACHE_BYTE_WRITE",
                .desc = "Number of bytes written to the Load Store Cache, excluding SLM accesses",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_BYTES,
                .read_uint64 = cri__l1_profile__load_store_cache_byte_write__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "Load Store Cache Hit",
                .symbol_name = "LOAD_STORE_CACHE_HIT",
                .desc = "Number of Load Store Cache hits",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__l1_profile__load_store_cache_hit__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "Load Store Cache Input Available",
                .symbol_name = "LOAD_STORE_CACHE_INPUT_AVAILABLE",
                .desc = "Percentage of time in which the Load Store Cache has input available",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__l1_profile__load_store_cache_input_available__read,
                .max_float = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "Load Store Cache L3 Hit",
                .symbol_name = "LOAD_STORE_CACHE_L3_HIT",
                .desc = "Number of Load Store Cache requests to Device Cache that are hit",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__l1_profile__load_store_cache_l3_hit__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Device Cache",
            },

            {
                .name = "Load Store Cache L3 Read",
                .symbol_name = "LOAD_STORE_CACHE_L3_READ",
                .desc = "Number of cacheline read requests from the Load Store Cache to Device Cache",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__l1_profile__load_store_cache_l3_read__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Device Cache",
            },

            {
                .name = "Load Store Cache L3 Write",
                .symbol_name = "LOAD_STORE_CACHE_L3_WRITE",
                .desc = "Number of cacheline write requests from the Load Store Cache to Device Cache",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__l1_profile__load_store_cache_l3_write__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Device Cache",
            },

            {
                .name = "Load Store Cache Number Of Bank Access Count",
                .symbol_name = "LOAD_STORE_CACHE_NUMBER_OF_BANK_ACCESS_COUNT",
                .desc = "Number of Load Store Cache banks accessed in a clock.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__l1_profile__load_store_cache_number_of_bank_access_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "Load Store Cache Output Ready",
                .symbol_name = "LOAD_STORE_CACHE_OUTPUT_READY",
                .desc = "Percentage of time in which the Load Store Cache has output ready",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__l1_profile__load_store_cache_output_ready__read,
                .max_float = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "Load Store Cache Partial Write Count",
                .symbol_name = "LOAD_STORE_CACHE_PARTIAL_WRITE_COUNT",
                .desc = "Number of writes to the Load Store Cache that don't fill a subsector",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__l1_profile__load_store_cache_partial_write_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "SLM Access Count",
                .symbol_name = "SLM_ACCESS_COUNT",
                .desc = "Number of SLM accesses",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__l1_profile__slm_access_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "SLM Atomic Access Count",
                .symbol_name = "SLM_ATOMIC_ACCESS_COUNT",
                .desc = "Number of SLM atomic accesses",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__l1_profile__slm_atomic_access_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "SLM Bank Conflict Count",
                .symbol_name = "SLM_BANK_CONFLICT_COUNT",
                .desc = "Number of SLM accesses resulting in a bank conflict",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__l1_profile__slm_bank_conflict_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "SLM Byte Read",
                .symbol_name = "SLM_BYTE_READ",
                .desc = "Number of bytes read from SLM",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_BYTES,
                .read_uint64 = cri__l1_profile__slm_byte_read__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "SLM Byte Write",
                .symbol_name = "SLM_BYTE_WRITE",
                .desc = "Number of bytes written to SLM",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_BYTES,
                .read_uint64 = cri__l1_profile__slm_byte_write__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "SLM Overlapped Atomic Access Count",
                .symbol_name = "SLM_OVERLAPPED_ATOMIC_ACCESS_COUNT",
                .desc = "Number of overlapped SLM atomic accesses within a message",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__l1_profile__slm_overlapped_atomic_access_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "XVE Load Store Cache Atomic Message Count",
                .symbol_name = "XVE_LOAD_STORE_CACHE_ATOMIC_MESSAGE_COUNT",
                .desc = "Number of atomic operations sent by XVEs to the Load Store Cache",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__l1_profile__xve_load_store_cache_atomic_message_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "XVE Load Store Cache Fence Message Count",
                .symbol_name = "XVE_LOAD_STORE_CACHE_FENCE_MESSAGE_COUNT",
                .desc = "Number of fence messages sent by XVEs to the Load Store Cache",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_MESSAGES,
                .read_uint64 = cri__l1_profile__xve_load_store_cache_fence_message_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "XVE Load Store Cache Read Message Count",
                .symbol_name = "XVE_LOAD_STORE_CACHE_READ_MESSAGE_COUNT",
                .desc = "Number of read messages sent by XVEs to the Load Store Cache",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_MESSAGES,
                .read_uint64 = cri__l1_profile__xve_load_store_cache_read_message_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "XVE Load Store Cache Register Request Count",
                .symbol_name = "XVE_LOAD_STORE_CACHE_REGISTER_REQUEST_COUNT",
                .desc = "Number of message payload transactions sent by XVEs to the Load Store Cache",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__l1_profile__xve_load_store_cache_register_request_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "XVE Load Store Cache Register Response Count",
                .symbol_name = "XVE_LOAD_STORE_CACHE_REGISTER_RESPONSE_COUNT",
                .desc = "Number of message payload transactions sent from the Load Store Cache back to XVEs",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__l1_profile__xve_load_store_cache_register_response_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "XVE Load Store Cache Write Message Count",
                .symbol_name = "XVE_LOAD_STORE_CACHE_WRITE_MESSAGE_COUNT",
                .desc = "Number of write messages sent by XVEs to the Load Store Cache",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_MESSAGES,
                .read_uint64 = cri__l1_profile__xve_load_store_cache_write_message_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "XVE SLM Atomic Message Count",
                .symbol_name = "XVE_SLM_ATOMIC_MESSAGE_COUNT",
                .desc = "Number of SLM atomic operations sent by XVEs",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__l1_profile__xve_slm_atomic_message_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "XVE SLM Fence Message Count",
                .symbol_name = "XVE_SLM_FENCE_MESSAGE_COUNT",
                .desc = "Number of SLM fence operations sent by XVEs",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__l1_profile__xve_slm_fence_message_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "XVE SLM Read Message Count",
                .symbol_name = "XVE_SLM_READ_MESSAGE_COUNT",
                .desc = "Number of SLM read messages sent by XVEs",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_MESSAGES,
                .read_uint64 = cri__l1_profile__xve_slm_read_message_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },

            {
                .name = "XVE SLM Write Message Count",
                .symbol_name = "XVE_SLM_WRITE_MESSAGE_COUNT",
                .desc = "Number of SLM write messages sent by XVEs",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_MESSAGES,
                .read_uint64 = cri__l1_profile__xve_slm_write_message_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "L1 Cache",
            },
        };
        int i;
        for (i = 0; i < sizeof(_counters) / sizeof(_counters[0]); i++) {
            if (_counters[i].availability && !_counters[i].availability(perf))
                continue;
            counter = &metric_set->counters[metric_set->n_counters++];
            *counter = _counters[i];
            counter->metric_set = metric_set;
            intel_xe_perf_add_logical_counter(perf, counter, counter->group);
        }
    }

    assert(metric_set->n_counters <= 39);
}


static void
cri_add_vector_engine_profile_metric_set(struct intel_xe_perf *perf)
{
    struct intel_xe_perf_metric_set *metric_set;
    struct intel_xe_perf_logical_counter *counter;

    metric_set = calloc(1, sizeof(*metric_set));
    metric_set->name = "VectorEngineProfile";
    metric_set->symbol_name = "VectorEngineProfile";
    metric_set->hw_config_guid = "7a949ef3-b6fa-4ae2-a483-d3b7d03b98bc";
    metric_set->counters = calloc(36, sizeof(struct intel_xe_perf_logical_counter));
    metric_set->n_counters = 0;
    metric_set->perf_oa_metrics_set = 0; // determined at runtime
    metric_set->perf_oa_format = XE_OA_FORMAT_PEC64u64;
    metric_set->perf_raw_size = 576;
    metric_set->gpu_time_offset = 0;
    metric_set->gpu_clock_offset = 1;
    metric_set->pec_offset = 2;
    cri_vector_engine_profile_add_registers(perf, metric_set);
    intel_xe_perf_add_metric_set(perf, metric_set);

    {
        static const struct intel_xe_perf_logical_counter _counters[] = {

            {
                .name = "Async GpGpu Threadgroup Count",
                .symbol_name = "ASYNC_GPGPU_THREADGROUP_COUNT",
                .desc = "Number of Async GPGPU threadgroups dispatched",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__async_gpgpu_threadgroup_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Thread Dispatcher",
            },

            {
                .name = "AVG GPU Core Frequency",
                .symbol_name = "AvgGpuCoreFrequency",
                .desc = "Average GPU Core Frequency in the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_HZ,
                .read_uint64 = cri__vector_engine_profile__avg_gpu_core_frequency__read,
                .max_uint64 = cri__vector_engine_profile__avg_gpu_core_frequency__max,
                .group = "GPU",
            },

            {
                .name = "Command Parser Compute Engine Busy",
                .symbol_name = "COMMAND_PARSER_COMPUTE_ENGINE_BUSY",
                .desc = "Percentage of time in which there is a context loaded and active on the compute queue",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_profile__command_parser_compute_engine_busy__read,
                .max_float = NULL /* undefined */,
                .group = "Front End",
            },

            {
                .name = "Command Parser Compute Engine Dispatch Kernel Count",
                .symbol_name = "COMMAND_PARSER_COMPUTE_ENGINE_DISPATCH_KERNEL_COUNT",
                .desc = "Number of compute walker commands parsed on the compute engine",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__command_parser_compute_engine_dispatch_kernel_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Front End",
            },

            {
                .name = "GPU Busy",
                .symbol_name = "GPU_BUSY",
                .desc = "Percentage of time in which GPU is not idle including all GPU engines",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_profile__gpu_busy__read,
                .max_float = NULL /* undefined */,
                .group = "Front End",
            },

            {
                .name = "GPU Core Clocks",
                .symbol_name = "GpuCoreClocks",
                .desc = "The total number of GPU core clocks elapsed during the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__vector_engine_profile__gpu_core_clocks__read,
                .max_uint64 = NULL /* undefined */,
                .group = "GPU",
            },

            {
                .name = "GPU Time Elapsed",
                .symbol_name = "GpuTime",
                .desc = "Time elapsed on the GPU during the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_NS,
                .read_uint64 = cri__vector_engine_profile__gpu_time__read,
                .max_uint64 = NULL /* undefined */,
                .group = "GPU",
            },

            {
                .name = "ICache Hit",
                .symbol_name = "ICACHE_HIT",
                .desc = "Number of Instruction Cache hits",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__icache_hit__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "ICache Miss",
                .symbol_name = "ICACHE_MISS",
                .desc = "Number of Instruction Cache misses",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__icache_miss__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed ALU0 All",
                .symbol_name = "XVE_INST_EXECUTED_ALU0_ALL",
                .desc = "Number of execution slots taken by instructions executed on ALU0 pipe",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_alu0_all__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed ALU1 All",
                .symbol_name = "XVE_INST_EXECUTED_ALU1_ALL",
                .desc = "Number of execution slots taken by instructions executed on ALU1 pipe. Does not include extended math instructions.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_alu1_all__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed ALU2 All",
                .symbol_name = "XVE_INST_EXECUTED_ALU2_ALL",
                .desc = "Number of execution slots taken by instructions executed in ALU2 pipe",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_alu2_all__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed Barrier",
                .symbol_name = "XVE_INST_EXECUTED_BARRIER",
                .desc = "Number of sync.bar and sync.host instructions executed",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_barrier__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed Bf16",
                .symbol_name = "XVE_INST_EXECUTED_BF16",
                .desc = "Number of execution slots taken by BF16 ALU instructions",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_bf16__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed Bitconv",
                .symbol_name = "XVE_INST_EXECUTED_BITCONV",
                .desc = "Number of execution slots taken by bit manipulation instructions",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_bitconv__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed Control All",
                .symbol_name = "XVE_INST_EXECUTED_CONTROL_ALL",
                .desc = "Number of instructions executed on JEU Pipe",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_control_all__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed Fp16",
                .symbol_name = "XVE_INST_EXECUTED_FP16",
                .desc = "Number of execution slots taken by FP16 ALU instructions. Does not include extended math instructions.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_fp16__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed Fp32",
                .symbol_name = "XVE_INST_EXECUTED_FP32",
                .desc = "Number of execution slots taken by FP32 ALU instructions. Does not include extended math instructions.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_fp32__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed Fp64",
                .symbol_name = "XVE_INST_EXECUTED_FP64",
                .desc = "Number of execution slots taken by FP64 ALU instructions",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_fp64__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed Fp64 2nd",
                .symbol_name = "XVE_INST_EXECUTED_FP64_2ND",
                .desc = "Number of execution slots taken by FP64 ALU instructions executed in the second pipe",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_fp64_2_nd__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed Int16",
                .symbol_name = "XVE_INST_EXECUTED_INT16",
                .desc = "Number of execution slots taken by INT16 ALU instructions",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_int16__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed Int32",
                .symbol_name = "XVE_INST_EXECUTED_INT32",
                .desc = "Number of execution slots taken by INT32 ALU instructions",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_int32__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed Int64",
                .symbol_name = "XVE_INST_EXECUTED_INT64",
                .desc = "Number of execution slots taken by INT64 instructions",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_int64__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed Math",
                .symbol_name = "XVE_INST_EXECUTED_MATH",
                .desc = "Number of execution slots taken by extended math instructions",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_math__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed Nondivergent",
                .symbol_name = "XVE_INST_EXECUTED_NONDIVERGENT",
                .desc = "Number of non-divergent instructions (not execution slots) executed",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_nondivergent__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed Predication",
                .symbol_name = "XVE_INST_EXECUTED_PREDICATION",
                .desc = "Number of instructions (not execution slots) executed with predication mask enabled",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_predication__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed Send All",
                .symbol_name = "XVE_INST_EXECUTED_SEND_ALL",
                .desc = "Number of instruction (GRF or SRF) dispatches executed on SEND Pipe",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_send_all__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed XMX Bf16",
                .symbol_name = "XVE_INST_EXECUTED_XMX_BF16",
                .desc = "Number of execution slots taken by BF16 XMX instructions",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_xmx_bf16__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed XMX Fp16",
                .symbol_name = "XVE_INST_EXECUTED_XMX_FP16",
                .desc = "Number of execution slots taken by FP16 XMX instructions",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_xmx_fp16__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed XMX Fp4",
                .symbol_name = "XVE_INST_EXECUTED_XMX_FP4",
                .desc = "Number of execution slots taken by FP4 XMX instruction",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_xmx_fp4__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed XMX Fp64",
                .symbol_name = "XVE_INST_EXECUTED_XMX_FP64",
                .desc = "Number of execution slots taken by FP64 XMX instructions",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_xmx_fp64__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed XMX Fp8",
                .symbol_name = "XVE_INST_EXECUTED_XMX_FP8",
                .desc = "Number of execution slots taken by FP8 XMX instructions",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_xmx_fp8__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed XMX Int4",
                .symbol_name = "XVE_INST_EXECUTED_XMX_INT4",
                .desc = "Number of execution slots taken by INT4 XMX instructions",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_xmx_int4__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Executed XMX Int8",
                .symbol_name = "XVE_INST_EXECUTED_XMX_INT8",
                .desc = "Number of execution slots taken by INT8 XMX instructions",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_executed_xmx_int8__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Inst Issued All",
                .symbol_name = "XVE_INST_ISSUED_ALL",
                .desc = "Number of instructions issued (decoded) to any pipe",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_profile__xve_inst_issued_all__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Threads Occupancy All",
                .symbol_name = "XVE_THREADS_OCCUPANCY_ALL",
                .desc = "Percentage of thread slots occupied",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_profile__xve_threads_occupancy_all__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },
        };
        int i;
        for (i = 0; i < sizeof(_counters) / sizeof(_counters[0]); i++) {
            if (_counters[i].availability && !_counters[i].availability(perf))
                continue;
            counter = &metric_set->counters[metric_set->n_counters++];
            *counter = _counters[i];
            counter->metric_set = metric_set;
            intel_xe_perf_add_logical_counter(perf, counter, counter->group);
        }
    }

    assert(metric_set->n_counters <= 36);
}


static void
cri_add_vector_engine_stalls_metric_set(struct intel_xe_perf *perf)
{
    struct intel_xe_perf_metric_set *metric_set;
    struct intel_xe_perf_logical_counter *counter;

    metric_set = calloc(1, sizeof(*metric_set));
    metric_set->name = "VectorEngineStalls";
    metric_set->symbol_name = "VectorEngineStalls";
    metric_set->hw_config_guid = "ae64b97e-60be-4e1b-8415-f88915aad009";
    metric_set->counters = calloc(33, sizeof(struct intel_xe_perf_logical_counter));
    metric_set->n_counters = 0;
    metric_set->perf_oa_metrics_set = 0; // determined at runtime
    metric_set->perf_oa_format = XE_OA_FORMAT_PEC64u64;
    metric_set->perf_raw_size = 576;
    metric_set->gpu_time_offset = 0;
    metric_set->gpu_clock_offset = 1;
    metric_set->pec_offset = 2;
    cri_vector_engine_stalls_add_registers(perf, metric_set);
    intel_xe_perf_add_metric_set(perf, metric_set);

    {
        static const struct intel_xe_perf_logical_counter _counters[] = {

            {
                .name = "Async GpGpu Threadgroup Count",
                .symbol_name = "ASYNC_GPGPU_THREADGROUP_COUNT",
                .desc = "Number of Async GPGPU threadgroups dispatched",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_stalls__async_gpgpu_threadgroup_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Thread Dispatcher",
            },

            {
                .name = "Async GpGpu Thread Exit Count",
                .symbol_name = "ASYNC_GPGPU_THREAD_EXIT_COUNT",
                .desc = "Number of Async GPGPU EOT messages received",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_MESSAGES,
                .read_uint64 = cri__vector_engine_stalls__async_gpgpu_thread_exit_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Thread Dispatcher",
            },

            {
                .name = "AVG GPU Core Frequency",
                .symbol_name = "AvgGpuCoreFrequency",
                .desc = "Average GPU Core Frequency in the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_HZ,
                .read_uint64 = cri__vector_engine_stalls__avg_gpu_core_frequency__read,
                .max_uint64 = cri__vector_engine_stalls__avg_gpu_core_frequency__max,
                .group = "GPU",
            },

            {
                .name = "GPU Busy",
                .symbol_name = "GPU_BUSY",
                .desc = "Percentage of time in which GPU is not idle including all GPU engines",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__gpu_busy__read,
                .max_float = NULL /* undefined */,
                .group = "Front End",
            },

            {
                .name = "GPU Core Clocks",
                .symbol_name = "GpuCoreClocks",
                .desc = "The total number of GPU core clocks elapsed during the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__vector_engine_stalls__gpu_core_clocks__read,
                .max_uint64 = NULL /* undefined */,
                .group = "GPU",
            },

            {
                .name = "GPU Time Elapsed",
                .symbol_name = "GpuTime",
                .desc = "Time elapsed on the GPU during the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_NS,
                .read_uint64 = cri__vector_engine_stalls__gpu_time__read,
                .max_uint64 = NULL /* undefined */,
                .group = "GPU",
            },

            {
                .name = "Threadgroup Dispatch Queue0 Input Available",
                .symbol_name = "THREADGROUP_DISPATCH_QUEUE0_INPUT_AVAILABLE",
                .desc = "Percentage of time in which Thread Spawner has input available on queue 0",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__threadgroup_dispatch_queue0_input_available__read,
                .max_float = NULL /* undefined */,
                .group = "Thread Dispatcher",
            },

            {
                .name = "Threadgroup Dispatch Queue0 Resource Stall",
                .symbol_name = "THREADGROUP_DISPATCH_QUEUE0_RESOURCE_STALL",
                .desc = "Percentage of time in which Thread Spawner queue 0 is stalled waiting for any resource to be available (for example, SLM, Barrier, BTD stack, etc.)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__threadgroup_dispatch_queue0_resource_stall__read,
                .max_float = NULL /* undefined */,
                .group = "Thread Dispatcher",
            },

            {
                .name = "Threadgroup Dispatch Queue1 Input Available",
                .symbol_name = "THREADGROUP_DISPATCH_QUEUE1_INPUT_AVAILABLE",
                .desc = "Percentage of time in which Thread Spawner has input available on queue 1",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__threadgroup_dispatch_queue1_input_available__read,
                .max_float = NULL /* undefined */,
                .group = "Thread Dispatcher",
            },

            {
                .name = "Threadgroup Dispatch Queue1 Resource Stall",
                .symbol_name = "THREADGROUP_DISPATCH_QUEUE1_RESOURCE_STALL",
                .desc = "Percentage of time in which Thread Spawner queue 1 is stalled waiting for any resource to be available (for example, SLM, Barrier, BTD stack, etc.)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__threadgroup_dispatch_queue1_resource_stall__read,
                .max_float = NULL /* undefined */,
                .group = "Thread Dispatcher",
            },

            {
                .name = "Thread Dispatch GpGpu Common Engine",
                .symbol_name = "THREAD_DISPATCH_GPGPU_COMMON_ENGINE",
                .desc = "Number of Common (non-Async)) GPGPU threads dispatched",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_stalls__thread_dispatch_gpgpu_common_engine__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Thread Dispatcher",
            },

            {
                .name = "Thread Dispatch GpGpu Compute Engine",
                .symbol_name = "THREAD_DISPATCH_GPGPU_COMPUTE_ENGINE",
                .desc = "Number of Compute (Async) GPGPU threads dispatched",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_stalls__thread_dispatch_gpgpu_compute_engine__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Thread Dispatcher",
            },

            {
                .name = "Thread Dispatch Input Available",
                .symbol_name = "THREAD_DISPATCH_INPUT_AVAILABLE",
                .desc = "Percentage of time in which Thread Dispatch input is available",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__thread_dispatch_input_available__read,
                .max_float = NULL /* undefined */,
                .group = "Thread Dispatcher",
            },

            {
                .name = "Thread Dispatch Other",
                .symbol_name = "THREAD_DISPATCH_OTHER",
                .desc = "Number of threads dispatched that do not fit into any of the other identified groups. This group includes, at least, AMFS threads and may include other groups.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__vector_engine_stalls__thread_dispatch_other__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Thread Dispatcher",
            },

            {
                .name = "Thread Dispatch Queue0 Active",
                .symbol_name = "THREAD_DISPATCH_QUEUE0_ACTIVE",
                .desc = "Percentage of time in which non-Pixel Shader threads are ready for dispatch in a particular Xe core",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__thread_dispatch_queue0_active__read,
                .max_float = NULL /* undefined */,
                .group = "Thread Dispatcher",
            },

            {
                .name = "Thread Dispatch Queue0 Stall",
                .symbol_name = "THREAD_DISPATCH_QUEUE0_STALL",
                .desc = "Percentage of time in which queue 0 is stalled waiting for threads to be available",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__thread_dispatch_queue0_stall__read,
                .max_float = NULL /* undefined */,
                .group = "Thread Dispatcher",
            },

            {
                .name = "Thread Dispatch Queue1 Active",
                .symbol_name = "THREAD_DISPATCH_QUEUE1_ACTIVE",
                .desc = "Percentage of time in which non-Pixel Shader threads are ready for dispatch in a particular Xe core",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__thread_dispatch_queue1_active__read,
                .max_float = NULL /* undefined */,
                .group = "Thread Dispatcher",
            },

            {
                .name = "Thread Dispatch Queue1 Stall",
                .symbol_name = "THREAD_DISPATCH_QUEUE1_STALL",
                .desc = "Percentage of time in which queue 1 is stalled waiting for threads to be available",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__thread_dispatch_queue1_stall__read,
                .max_float = NULL /* undefined */,
                .group = "Thread Dispatcher",
            },

            {
                .name = "XVE Active",
                .symbol_name = "XVE_ACTIVE",
                .desc = "Percentage of time in which at least one pipe is active in XVE",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__xve_active__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Multiple Pipe Active",
                .symbol_name = "XVE_MULTIPLE_PIPE_ACTIVE",
                .desc = "Percentage of time in which at least two pipes are actively executing a Gen ISA instruction among ALU0, ALU1, ALU2 and ALU3 pipes",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__xve_multiple_pipe_active__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Pipe ALU0 And ALU1 Active",
                .symbol_name = "XVE_PIPE_ALU0_AND_ALU1_ACTIVE",
                .desc = "Percentage of time in which ALU0 and ALU1 pipes are both actively executing a Gen ISA instruction",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__xve_pipe_alu0_and_alu1_active__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Pipe ALU0 And ALU2 Active",
                .symbol_name = "XVE_PIPE_ALU0_AND_ALU2_ACTIVE",
                .desc = "Percentage of time in which ALU0 and ALU2 pipes are both actively executing a Gen ISA instruction",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__xve_pipe_alu0_and_alu2_active__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Shared Function Access Hold",
                .symbol_name = "XVE_SHARED_FUNCTION_ACCESS_HOLD",
                .desc = "Percentage of time in which XVE requests stalled by Shared Function units",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__xve_shared_function_access_hold__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Stall",
                .symbol_name = "XVE_STALL",
                .desc = "Percentage of time in which any thread loaded but not even a single pipe is active in XVE",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__xve_stall__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Stall Aluwr",
                .symbol_name = "XVE_STALL_ALUWR",
                .desc = "Percentage of time in which XVE stalled, with at least one thread waiting for ALU to write GRF/ACC register. Multiple stall reasons can qualify during the same cycle",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__xve_stall_aluwr__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Stall Barrier",
                .symbol_name = "XVE_STALL_BARRIER",
                .desc = "Percentage of time in which XVE stalled, with at least one thread waiting for Gateway to write Notify register. Multiple stall reasons can qualify during the same cycle",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__xve_stall_barrier__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Stall Control",
                .symbol_name = "XVE_STALL_CONTROL",
                .desc = "Percentage of time in which XVE stalled, with at least one thread waiting for JEU to complete branch instruction. Multiple stall reasons can qualify during the same cycle",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__xve_stall_control__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Stall Instfetch",
                .symbol_name = "XVE_STALL_INSTFETCH",
                .desc = "Percentage of time in which XVE stalled, with at least one thread waiting for Instruction Fetch. Multiple stall reasons can qualify during the same cycle",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__xve_stall_instfetch__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Stall Other",
                .symbol_name = "XVE_STALL_OTHER",
                .desc = "Percentage of time in which XVE stalled, with at least one thread waiting on any other dependency (Flag/EoT etc). Multiple stall reasons can qualify during the same cycle",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__xve_stall_other__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Stall Pipestall",
                .symbol_name = "XVE_STALL_PIPESTALL",
                .desc = "Percentage of time in which XVE stalled, with at least one thread ready to be scheduled (Grf conf/send holds etc). Multiple stall reasons can qualify during the same cycle",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__xve_stall_pipestall__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Stall Sbid",
                .symbol_name = "XVE_STALL_SBID",
                .desc = "Percentage of time in which XVE stalled, with at least one thread waiting for Scoreboard token to be available. Multiple stall reasons can qualify during the same cycle",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__xve_stall_sbid__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Stall Sendwr",
                .symbol_name = "XVE_STALL_SENDWR",
                .desc = "Percentage of time in which XVE stalled, with at least one thread waiting for SEND message to be dispatched from XVE. Multiple stall reasons can qualify during the same cycle",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__xve_stall_sendwr__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },

            {
                .name = "XVE Threads Occupancy All",
                .symbol_name = "XVE_THREADS_OCCUPANCY_ALL",
                .desc = "Percentage of thread slots occupied",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__vector_engine_stalls__xve_threads_occupancy_all__read,
                .max_float = NULL /* undefined */,
                .group = "Vector Engine",
            },
        };
        int i;
        for (i = 0; i < sizeof(_counters) / sizeof(_counters[0]); i++) {
            if (_counters[i].availability && !_counters[i].availability(perf))
                continue;
            counter = &metric_set->counters[metric_set->n_counters++];
            *counter = _counters[i];
            counter->metric_set = metric_set;
            intel_xe_perf_add_logical_counter(perf, counter, counter->group);
        }
    }

    assert(metric_set->n_counters <= 33);
}

static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE0_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 0, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE1_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 1, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE10_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 10, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE11_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 11, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE12_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 12, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE13_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 13, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE14_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 14, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE15_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 15, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE16_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 16, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE17_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 17, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE18_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 18, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE19_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 19, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE2_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 2, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE20_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 20, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE21_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 21, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE22_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 22, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE23_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 23, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE24_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 24, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE25_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 25, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE26_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 26, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE27_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 27, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE28_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 28, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE3_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 3, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE4_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 4, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE5_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 5, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE6_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 6, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE7_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 7, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE8_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 8, 0)) {
        return true;
    }
    return false;
}
static bool cri_test_oa_TEST_EVENT1_CYCLES_XECORE9_availability(const struct intel_xe_perf *perf) {
    if (intel_xe_perf_devinfo_subslice_available(&perf->devinfo, 9, 0)) {
        return true;
    }
    return false;
}

static void
cri_add_test_oa_metric_set(struct intel_xe_perf *perf)
{
    struct intel_xe_perf_metric_set *metric_set;
    struct intel_xe_perf_logical_counter *counter;

    metric_set = calloc(1, sizeof(*metric_set));
    metric_set->name = "TestOa";
    metric_set->symbol_name = "TestOa";
    metric_set->hw_config_guid = "331884b0-bd9e-4262-bacd-c6fb4265a317";
    metric_set->counters = calloc(40, sizeof(struct intel_xe_perf_logical_counter));
    metric_set->n_counters = 0;
    metric_set->perf_oa_metrics_set = 0; // determined at runtime
    metric_set->perf_oa_format = XE_OA_FORMAT_PEC64u64;
    metric_set->perf_raw_size = 576;
    metric_set->gpu_time_offset = 0;
    metric_set->gpu_clock_offset = 1;
    metric_set->pec_offset = 2;
    cri_test_oa_add_registers(perf, metric_set);
    intel_xe_perf_add_metric_set(perf, metric_set);

    {
        static const struct intel_xe_perf_logical_counter _counters[] = {

            {
                .name = "Async GpGpu Threadgroup Count",
                .symbol_name = "ASYNC_GPGPU_THREADGROUP_COUNT",
                .desc = "Number of Async GPGPU threadgroups dispatched",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__test_oa__async_gpgpu_threadgroup_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Thread Dispatcher",
            },

            {
                .name = "AVG GPU Core Frequency",
                .symbol_name = "AvgGpuCoreFrequency",
                .desc = "Average GPU Core Frequency in the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_HZ,
                .read_uint64 = cri__test_oa__avg_gpu_core_frequency__read,
                .max_uint64 = cri__test_oa__avg_gpu_core_frequency__max,
                .group = "GPU",
            },

            {
                .name = "GpGpu Threadgroup Count",
                .symbol_name = "GPGPU_THREADGROUP_COUNT",
                .desc = "Number of GPGPU threadgroups dispatched",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__test_oa__gpgpu_threadgroup_count__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Thread Dispatcher",
            },

            {
                .name = "GPU Busy",
                .symbol_name = "GPU_BUSY",
                .desc = "Percentage of time in which GPU is not idle including all GPU engines",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__test_oa__gpu_busy__read,
                .max_float = NULL /* undefined */,
                .group = "Front End",
            },

            {
                .name = "GPU Core Clocks",
                .symbol_name = "GpuCoreClocks",
                .desc = "The total number of GPU core clocks elapsed during the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__gpu_core_clocks__read,
                .max_uint64 = NULL /* undefined */,
                .group = "GPU",
            },

            {
                .name = "GPU Time Elapsed",
                .symbol_name = "GpuTime",
                .desc = "Time elapsed on the GPU during the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_NS,
                .read_uint64 = cri__test_oa__gpu_time__read,
                .max_uint64 = NULL /* undefined */,
                .group = "GPU",
            },

            {
                .name = "Test Event1",
                .symbol_name = "TEST_EVENT1",
                .desc = "Number of GPU (gt) clock cycles at every clock period",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__test_oa__test_event1__read,
                .max_float = NULL /* undefined */,
                .group = "Test",
            },

            {
                .name = "Test Event1 Cycles",
                .symbol_name = "TEST_EVENT1_CYCLES",
                .desc = "Number of GPU (gt) clock cycles at every clock period",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
            },

            {
                .name = "Test Event1 Cycles Average",
                .symbol_name = "TEST_EVENT1_CYCLES_AVERAGE",
                .desc = "Average number of GPU (gt) clock cycles at every clock period",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_average__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
            },

            {
                .name = "Test Event1 Cycles Xecore0",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE0",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE0)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore0__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE0_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore1",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE1",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE1)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore1__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE1_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore10",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE10",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE10)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore10__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE10_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore11",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE11",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE11)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore11__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE11_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore12",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE12",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE12)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore12__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE12_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore13",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE13",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE13)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore13__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE13_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore14",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE14",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE14)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore14__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE14_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore15",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE15",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE15)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore15__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE15_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore16",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE16",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE16)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore16__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE16_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore17",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE17",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE17)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore17__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE17_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore18",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE18",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE18)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore18__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE18_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore19",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE19",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE19)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore19__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE19_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore2",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE2",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE2)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore2__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE2_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore20",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE20",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE20)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore20__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE20_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore21",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE21",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE21)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore21__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE21_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore22",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE22",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE22)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore22__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE22_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore23",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE23",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE23)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore23__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE23_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore24",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE24",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE24)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore24__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE24_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore25",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE25",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE25)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore25__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE25_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore26",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE26",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE26)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore26__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE26_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore27",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE27",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE27)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore27__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE27_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore28",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE28",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE28)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore28__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE28_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore3",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE3",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE3)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore3__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE3_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore4",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE4",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE4)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore4__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE4_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore5",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE5",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE5)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore5__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE5_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore6",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE6",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE6)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore6__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE6_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore7",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE7",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE7)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore7__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE7_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore8",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE8",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE8)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore8__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE8_availability,
            },

            {
                .name = "Test Event1 Cycles Xecore9",
                .symbol_name = "TEST_EVENT1_CYCLES_XECORE9",
                .desc = "Number of GPU (gt) clock cycles at every clock period (XECORE9)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event1_cycles_xecore9__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
                .availability = cri_test_oa_TEST_EVENT1_CYCLES_XECORE9_availability,
            },

            {
                .name = "Test Event2",
                .symbol_name = "TEST_EVENT2",
                .desc = "Number of GPU (gt) clock cycles at every other clock period",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__test_oa__test_event2__read,
                .max_float = NULL /* undefined */,
                .group = "Test",
            },

            {
                .name = "Test Event2 Cycles",
                .symbol_name = "TEST_EVENT2_CYCLES",
                .desc = "Number of GPU (gt) clock cycles at every other clock period",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__test_oa__test_event2_cycles__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Test",
            },
        };
        int i;
        for (i = 0; i < sizeof(_counters) / sizeof(_counters[0]); i++) {
            if (_counters[i].availability && !_counters[i].availability(perf))
                continue;
            counter = &metric_set->counters[metric_set->n_counters++];
            *counter = _counters[i];
            counter->metric_set = metric_set;
            intel_xe_perf_add_logical_counter(perf, counter, counter->group);
        }
    }

    assert(metric_set->n_counters <= 40);
}


static void
cri_add_media_set2_metric_set(struct intel_xe_perf *perf)
{
    struct intel_xe_perf_metric_set *metric_set;
    struct intel_xe_perf_logical_counter *counter;

    metric_set = calloc(1, sizeof(*metric_set));
    metric_set->name = "MediaSet2";
    metric_set->symbol_name = "MediaSet2";
    metric_set->hw_config_guid = "08357a1e-f136-4133-a2c0-89e02a9b80f4";
    metric_set->counters = calloc(9, sizeof(struct intel_xe_perf_logical_counter));
    metric_set->n_counters = 0;
    metric_set->perf_oa_metrics_set = 0; // determined at runtime
    metric_set->perf_oa_format = XE_OAM_FORMAT_MPEC8u64_B8_C8;

    metric_set->perf_raw_size = 192;
    metric_set->gpu_time_offset = 0;
    metric_set->gpu_clock_offset = 1;
    metric_set->pec_offset = 2;
    metric_set->b_offset = metric_set->pec_offset + 8;
    metric_set->c_offset = metric_set->b_offset + 8;
    cri_media_set2_add_registers(perf, metric_set);
    intel_xe_perf_add_metric_set(perf, metric_set);

    {
        static const struct intel_xe_perf_logical_counter _counters[] = {

            {
                .name = "AVG GPU Media Frequency",
                .symbol_name = "AvgGpuCoreFrequency",
                .desc = "Average GPU Media Frequency in the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_HZ,
                .read_uint64 = cri__media_set2__avg_gpu_core_frequency__read,
                .max_uint64 = cri__media_set2__avg_gpu_core_frequency__max,
                .group = "GPU",
            },

            {
                .name = "Command Parser Video Enhancement Engine0 Busy",
                .symbol_name = "COMMAND_PARSER_VIDEO_ENHANCEMENT_ENGINE0_BUSY",
                .desc = "Number of VECS0 (VEBOX0) activities",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__media_set2__command_parser_video_enhancement_engine0_busy__read,
                .max_float = NULL /* undefined */,
                .group = "Media",
            },

            {
                .name = "Command Parser Video Enhancement Engine1 Busy",
                .symbol_name = "COMMAND_PARSER_VIDEO_ENHANCEMENT_ENGINE1_BUSY",
                .desc = "Number of VECS1 (VEBOX1) activities",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__media_set2__command_parser_video_enhancement_engine1_busy__read,
                .max_float = NULL /* undefined */,
                .group = "Media",
            },

            {
                .name = "GPU Media Clocks",
                .symbol_name = "GpuCoreClocks",
                .desc = "The total number of media slice clocks elapsed during the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__media_set2__gpu_core_clocks__read,
                .max_uint64 = NULL /* undefined */,
                .group = "GPU",
            },

            {
                .name = "GPU Time Elapsed",
                .symbol_name = "GpuTime",
                .desc = "Time elapsed on the GPU during the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_NS,
                .read_uint64 = cri__media_set2__gpu_time__read,
                .max_uint64 = NULL /* undefined */,
                .group = "GPU",
            },

            {
                .name = "Video Enhancement Box0 Read Request",
                .symbol_name = "VIDEO_ENHANCEMENT_BOX0_READ_REQUEST",
                .desc = "Number of VEBOX0 read requests",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__media_set2__video_enhancement_box0_read_request__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Media",
            },

            {
                .name = "Video Enhancement Box0 Write Request",
                .symbol_name = "VIDEO_ENHANCEMENT_BOX0_WRITE_REQUEST",
                .desc = "Number of VEBOX0 write requests",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__media_set2__video_enhancement_box0_write_request__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Media",
            },

            {
                .name = "Video Enhancement Box1 Read Request",
                .symbol_name = "VIDEO_ENHANCEMENT_BOX1_READ_REQUEST",
                .desc = "Number of VEBOX1 read requests",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__media_set2__video_enhancement_box1_read_request__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Media",
            },

            {
                .name = "Video Enhancement Box1 Write Request",
                .symbol_name = "VIDEO_ENHANCEMENT_BOX1_WRITE_REQUEST",
                .desc = "Number of VEBOX1 write requests",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__media_set2__video_enhancement_box1_write_request__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Media",
            },
        };
        int i;
        for (i = 0; i < sizeof(_counters) / sizeof(_counters[0]); i++) {
            if (_counters[i].availability && !_counters[i].availability(perf))
                continue;
            counter = &metric_set->counters[metric_set->n_counters++];
            *counter = _counters[i];
            counter->metric_set = metric_set;
            intel_xe_perf_add_logical_counter(perf, counter, counter->group);
        }
    }

    assert(metric_set->n_counters <= 9);
}


static void
cri_add_media_set1_metric_set(struct intel_xe_perf *perf)
{
    struct intel_xe_perf_metric_set *metric_set;
    struct intel_xe_perf_logical_counter *counter;

    metric_set = calloc(1, sizeof(*metric_set));
    metric_set->name = "MediaSet1";
    metric_set->symbol_name = "MediaSet1";
    metric_set->hw_config_guid = "7d45bd5d-49d6-4de2-9b14-bbeb91a7905b";
    metric_set->counters = calloc(4, sizeof(struct intel_xe_perf_logical_counter));
    metric_set->n_counters = 0;
    metric_set->perf_oa_metrics_set = 0; // determined at runtime
    metric_set->perf_oa_format = XE_OAM_FORMAT_MPEC8u64_B8_C8;

    metric_set->perf_raw_size = 192;
    metric_set->gpu_time_offset = 0;
    metric_set->gpu_clock_offset = 1;
    metric_set->pec_offset = 2;
    metric_set->b_offset = metric_set->pec_offset + 8;
    metric_set->c_offset = metric_set->b_offset + 8;
    cri_media_set1_add_registers(perf, metric_set);
    intel_xe_perf_add_metric_set(perf, metric_set);

    {
        static const struct intel_xe_perf_logical_counter _counters[] = {

            {
                .name = "AVG GPU Media Frequency",
                .symbol_name = "AvgGpuCoreFrequency",
                .desc = "Average GPU Media Frequency in the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_HZ,
                .read_uint64 = cri__media_set1__avg_gpu_core_frequency__read,
                .max_uint64 = cri__media_set1__avg_gpu_core_frequency__max,
                .group = "GPU",
            },

            {
                .name = "Command Parser Graphics Security Controller Busy",
                .symbol_name = "COMMAND_PARSER_GRAPHICS_SECURITY_CONTROLLER_BUSY",
                .desc = "Number of GSCCS activities",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_RAW,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_FLOAT,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_PERCENT,
                .read_float = cri__media_set1__command_parser_graphics_security_controller_busy__read,
                .max_float = NULL /* undefined */,
                .group = "Media",
            },

            {
                .name = "GPU Media Clocks",
                .symbol_name = "GpuCoreClocks",
                .desc = "The total number of media slice clocks elapsed during the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__media_set1__gpu_core_clocks__read,
                .max_uint64 = NULL /* undefined */,
                .group = "GPU",
            },

            {
                .name = "GPU Time Elapsed",
                .symbol_name = "GpuTime",
                .desc = "Time elapsed on the GPU during the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_NS,
                .read_uint64 = cri__media_set1__gpu_time__read,
                .max_uint64 = NULL /* undefined */,
                .group = "GPU",
            },
        };
        int i;
        for (i = 0; i < sizeof(_counters) / sizeof(_counters[0]); i++) {
            if (_counters[i].availability && !_counters[i].availability(perf))
                continue;
            counter = &metric_set->counters[metric_set->n_counters++];
            *counter = _counters[i];
            counter->metric_set = metric_set;
            intel_xe_perf_add_logical_counter(perf, counter, counter->group);
        }
    }

    assert(metric_set->n_counters <= 4);
}


static void
cri_add_mert_ext_set_metric_set(struct intel_xe_perf *perf)
{
    struct intel_xe_perf_metric_set *metric_set;
    struct intel_xe_perf_logical_counter *counter;

    metric_set = calloc(1, sizeof(*metric_set));
    metric_set->name = "MertExtSet";
    metric_set->symbol_name = "MertExtSet";
    metric_set->hw_config_guid = "ab8af1a9-2db0-410f-a9c9-3d8e35b74a0f";
    metric_set->counters = calloc(7, sizeof(struct intel_xe_perf_logical_counter));
    metric_set->n_counters = 0;
    metric_set->perf_oa_metrics_set = 0; // determined at runtime
    metric_set->perf_oa_format = XE_OAM_FORMAT_MPEC8u32_B8_C8;

    metric_set->perf_raw_size = 128;
    metric_set->gpu_time_offset = 0;
    metric_set->gpu_clock_offset = 1;
    metric_set->pec_offset = 2;
    metric_set->b_offset = metric_set->pec_offset + 8;
    metric_set->c_offset = metric_set->b_offset + 8;
    cri_mert_ext_set_add_registers(perf, metric_set);
    intel_xe_perf_add_metric_set(perf, metric_set);

    {
        static const struct intel_xe_perf_logical_counter _counters[] = {

            {
                .name = "AVG GPU Mert Frequency",
                .symbol_name = "AvgGpuCoreFrequency",
                .desc = "Average GPU Mert Frequency in the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_HZ,
                .read_uint64 = cri__mert_ext_set__avg_gpu_core_frequency__read,
                .max_uint64 = cri__mert_ext_set__avg_gpu_core_frequency__max,
                .group = "GPU",
            },

            {
                .name = "GPU Mert Clocks",
                .symbol_name = "GpuCoreClocks",
                .desc = "The total number of Mert slice clocks elapsed during the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_CYCLES,
                .read_uint64 = cri__mert_ext_set__gpu_core_clocks__read,
                .max_uint64 = NULL /* undefined */,
                .group = "GPU",
            },

            {
                .name = "GPU Time Elapsed",
                .symbol_name = "GpuTime",
                .desc = "Time elapsed on the GPU during the measurement.",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_NS,
                .read_uint64 = cri__mert_ext_set__gpu_time__read,
                .max_uint64 = NULL /* undefined */,
                .group = "GPU",
            },

            {
                .name = "Host To GpuMem Transaction Read",
                .symbol_name = "HOST_TO_GPUMEM_TRANSACTION_READ",
                .desc = "Number of host 64B reads to GPU local (HBM) memory (downstream over an interface such as pcie, cxl or an integrated fabric as applicable to the respective product segment)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__mert_ext_set__host_to_gpumem_transaction_read__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Memory",
            },

            {
                .name = "Host To GpuMem Transaction Write",
                .symbol_name = "HOST_TO_GPUMEM_TRANSACTION_WRITE",
                .desc = "Number of host 64B writes to GPU local (HBM) memory (downstream over an interface such as pcie, cxl or an integrated fabric as applicable to the respective product segment)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__mert_ext_set__host_to_gpumem_transaction_write__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Memory",
            },

            {
                .name = "SysMem Transaction Read",
                .symbol_name = "SYSMEM_TRANSACTION_READ",
                .desc = "Number of system memory 64B reads (upstream over an interface such as pcie, cxl or an integrated fabric as applicable to the respective product segment)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__mert_ext_set__sysmem_transaction_read__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Memory",
            },

            {
                .name = "SysMem Transaction Write",
                .symbol_name = "SYSMEM_TRANSACTION_WRITE",
                .desc = "Number of system memory 64B writes (upstream over an interface such as pcie, cxl or an integrated fabric as applicable to the respective product segment)",
                .type = INTEL_XE_PERF_LOGICAL_COUNTER_TYPE_EVENT,
                .storage = INTEL_XE_PERF_LOGICAL_COUNTER_STORAGE_UINT64,
                .unit = INTEL_XE_PERF_LOGICAL_COUNTER_UNIT_EVENTS,
                .read_uint64 = cri__mert_ext_set__sysmem_transaction_write__read,
                .max_uint64 = NULL /* undefined */,
                .group = "Memory",
            },
        };
        int i;
        for (i = 0; i < sizeof(_counters) / sizeof(_counters[0]); i++) {
            if (_counters[i].availability && !_counters[i].availability(perf))
                continue;
            counter = &metric_set->counters[metric_set->n_counters++];
            *counter = _counters[i];
            counter->metric_set = metric_set;
            intel_xe_perf_add_logical_counter(perf, counter, counter->group);
        }
    }

    assert(metric_set->n_counters <= 7);
}

void
intel_xe_perf_load_metrics_cri(struct intel_xe_perf *perf)
{
    cri_add_compute_basic_metric_set(perf);
    cri_add_l1_profile_metric_set(perf);
    cri_add_vector_engine_profile_metric_set(perf);
    cri_add_vector_engine_stalls_metric_set(perf);
    cri_add_test_oa_metric_set(perf);
    cri_add_media_set2_metric_set(perf);
    cri_add_media_set1_metric_set(perf);
    cri_add_mert_ext_set_metric_set(perf);
}
