Path: blob/21.2-virgl/src/amd/common/ac_perfcounter.h
7178 views
/*1* Copyright 2015 Advanced Micro Devices, Inc.2* All Rights Reserved.3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the "Software"),6* to deal in the Software without restriction, including without limitation7* on the rights to use, copy, modify, merge, publish, distribute, sub8* license, and/or sell copies of the Software, and to permit persons to whom9* the Software is furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice (including the next12* paragraph) shall be included in all copies or substantial portions of the13* Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL18* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,19* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR20* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE21* USE OR OTHER DEALINGS IN THE SOFTWARE.22*/2324#ifndef AC_PERFCOUNTER_H25#define AC_PERFCOUNTER_H2627#include <stdbool.h>2829#include "sid.h"3031#include "ac_gpu_info.h"3233/* Max counters per HW block */34#define AC_QUERY_MAX_COUNTERS 163536#define AC_PC_SHADERS_WINDOWING (1u << 31)3738enum ac_pc_block_flags39{40/* This block is part of the shader engine */41AC_PC_BLOCK_SE = (1 << 0),4243/* Expose per-instance groups instead of summing all instances (within44* an SE). */45AC_PC_BLOCK_INSTANCE_GROUPS = (1 << 1),4647/* Expose per-SE groups instead of summing instances across SEs. */48AC_PC_BLOCK_SE_GROUPS = (1 << 2),4950/* Shader block */51AC_PC_BLOCK_SHADER = (1 << 3),5253/* Non-shader block with perfcounters windowed by shaders. */54AC_PC_BLOCK_SHADER_WINDOWED = (1 << 4),55};5657enum ac_pc_gpu_block {58CPF = 0x0,59IA = 0x1,60VGT = 0x2,61PA_SU = 0x3,62PA_SC = 0x4,63SPI = 0x5,64SQ = 0x6,65SX = 0x7,66TA = 0x8,67TD = 0x9,68TCP = 0xA,69TCC = 0xB,70TCA = 0xC,71DB = 0xD,72CB = 0xE,73GDS = 0xF,74SRBM = 0x10,75GRBM = 0x11,76GRBMSE = 0x12,77RLC = 0x13,78DMA = 0x14,79MC = 0x15,80CPG = 0x16,81CPC = 0x17,82WD = 0x18,83TCS = 0x19,84ATC = 0x1A,85ATCL2 = 0x1B,86MCVML2 = 0x1C,87EA = 0x1D,88RPB = 0x1E,89RMI = 0x1F,90UMCCH = 0x20,91GE = 0x21,92GE1 = GE,93GL1A = 0x22,94GL1C = 0x23,95GL1CG = 0x24,96GL2A = 0x25,97GL2C = 0x26,98CHA = 0x27,99CHC = 0x28,100CHCG = 0x29,101GUS = 0x2A,102GCR = 0x2B,103PA_PH = 0x2C,104UTCL1 = 0x2D,105GEDIST = 0x2E,106GESE = 0x2F,107DF = 0x30,108NUM_GPU_BLOCK,109};110111struct ac_pc_block_base {112enum ac_pc_gpu_block gpu_block;113const char *name;114unsigned num_counters;115unsigned flags;116117unsigned select_or;118unsigned *select0;119unsigned counter0_lo;120unsigned *counters;121122/* SPM */123unsigned num_spm_counters;124unsigned num_spm_wires;125unsigned *select1;126unsigned spm_block_select;127};128129struct ac_pc_block_gfxdescr {130struct ac_pc_block_base *b;131unsigned selectors;132unsigned instances;133};134135struct ac_pc_block {136const struct ac_pc_block_gfxdescr *b;137unsigned num_instances;138139unsigned num_groups;140char *group_names;141unsigned group_name_stride;142143char *selector_names;144unsigned selector_name_stride;145};146147struct ac_perfcounters {148unsigned num_groups;149unsigned num_blocks;150struct ac_pc_block *blocks;151152bool separate_se;153bool separate_instance;154};155156/* The order is chosen to be compatible with GPUPerfStudio's hardcoding of157* performance counter group IDs.158*/159static const char *const ac_pc_shader_type_suffixes[] = {"", "_ES", "_GS", "_VS",160"_PS", "_LS", "_HS", "_CS"};161162static const unsigned ac_pc_shader_type_bits[] = {1630x7f,164S_036780_ES_EN(1),165S_036780_GS_EN(1),166S_036780_VS_EN(1),167S_036780_PS_EN(1),168S_036780_LS_EN(1),169S_036780_HS_EN(1),170S_036780_CS_EN(1),171};172173static inline bool174ac_pc_block_has_per_se_groups(const struct ac_perfcounters *pc,175const struct ac_pc_block *block)176{177return block->b->b->flags & AC_PC_BLOCK_SE_GROUPS ||178(block->b->b->flags & AC_PC_BLOCK_SE && pc->separate_se);179}180181static inline bool182ac_pc_block_has_per_instance_groups(const struct ac_perfcounters *pc,183const struct ac_pc_block *block)184{185return block->b->b->flags & AC_PC_BLOCK_INSTANCE_GROUPS ||186(block->num_instances > 1 && pc->separate_instance);187}188189struct ac_pc_block *ac_lookup_counter(const struct ac_perfcounters *pc,190unsigned index, unsigned *base_gid,191unsigned *sub_index);192struct ac_pc_block *ac_lookup_group(const struct ac_perfcounters *pc,193unsigned *index);194195bool ac_init_block_names(const struct radeon_info *info,196const struct ac_perfcounters *pc,197struct ac_pc_block *block);198199bool ac_init_perfcounters(const struct radeon_info *info,200bool separate_se,201bool separate_instance,202struct ac_perfcounters *pc);203void ac_destroy_perfcounters(struct ac_perfcounters *pc);204205#endif206207208