Commit 0fd43597 authored by Mark Janes's avatar Mark Janes

iris/perf: implement routines to return counter info

With this commit, Iris will report that AMD_performance_monitor is
supported, and will allow the caller to query the available metrics.
Reviewed-by: Kenneth Graunke's avatarKenneth Graunke <kenneth@whitecape.org>
parent e4aa0fc6
......@@ -460,6 +460,11 @@ struct iris_vtable {
struct iris_bo *bo, uint32_t offset,
uint64_t imm);
void (*emit_mi_report_perf_count)(struct iris_batch *batch,
struct iris_bo *bo,
uint32_t offset_in_bytes,
uint32_t report_id);
unsigned (*derived_program_state_size)(enum iris_program_cache_id id);
void (*store_derived_program_state)(struct iris_context *ice,
enum iris_program_cache_id cache_id,
......@@ -886,6 +891,11 @@ void iris_render_cache_add_bo(struct iris_batch *batch,
enum isl_aux_usage aux_usage);
void iris_cache_flush_for_depth(struct iris_batch *batch, struct iris_bo *bo);
void iris_depth_cache_add_bo(struct iris_batch *batch, struct iris_bo *bo);
int iris_get_driver_query_info(struct pipe_screen *pscreen, unsigned index,
struct pipe_driver_query_info *info);
int iris_get_driver_query_group_info(struct pipe_screen *pscreen,
unsigned index,
struct pipe_driver_query_group_info *info);
/* iris_state.c */
void gen9_toggle_preemption(struct iris_context *ice,
......
This diff is collapsed.
/*
* Copyright © 2019 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef IRIS_MONITOR_H
#define IRIS_MONITOR_H
#include "pipe/p_screen.h"
struct iris_monitor_counter {
int group;
int counter;
};
struct iris_monitor_config {
struct gen_perf_config *perf_cfg;
/* gallium requires an index for each counter */
int num_counters;
struct iris_monitor_counter *counters;
};
int iris_get_monitor_info(struct pipe_screen *pscreen, unsigned index,
struct pipe_driver_query_info *info);
int iris_get_monitor_group_info(struct pipe_screen *pscreen,
unsigned index,
struct pipe_driver_query_group_info *info);
#endif
......@@ -53,6 +53,7 @@
#include "iris_screen.h"
#include "intel/compiler/brw_compiler.h"
#include "intel/common/gen_gem.h"
#include "iris_monitor.h"
static void
iris_flush_frontbuffer(struct pipe_screen *_screen,
......@@ -683,6 +684,8 @@ iris_screen_create(int fd, const struct pipe_screen_config *config)
pscreen->flush_frontbuffer = iris_flush_frontbuffer;
pscreen->get_timestamp = iris_get_timestamp;
pscreen->query_memory_info = iris_query_memory_info;
pscreen->get_driver_query_group_info = iris_get_monitor_group_info;
pscreen->get_driver_query_info = iris_get_monitor_info;
return pscreen;
}
......@@ -33,6 +33,7 @@
#include "iris_bufmgr.h"
struct iris_bo;
struct iris_monitor_config;
#define READ_ONCE(x) (*(volatile __typeof__(x) *)&(x))
#define WRITE_ONCE(x, v) *(volatile __typeof__(x) *)&(x) = (v)
......@@ -75,6 +76,7 @@ struct iris_screen {
struct isl_device isl_dev;
struct iris_bufmgr *bufmgr;
struct brw_compiler *compiler;
struct iris_monitor_config *monitor_cfg;
/**
* A buffer containing nothing useful, for hardware workarounds that
......
......@@ -6450,6 +6450,18 @@ iris_lost_genx_state(struct iris_context *ice, struct iris_batch *batch)
memset(genx->last_index_buffer, 0, sizeof(genx->last_index_buffer));
}
static void
iris_emit_mi_report_perf_count(struct iris_batch *batch,
struct iris_bo *bo,
uint32_t offset_in_bytes,
uint32_t report_id)
{
iris_emit_cmd(batch, GENX(MI_REPORT_PERF_COUNT), mi_rpc) {
mi_rpc.MemoryAddress = rw_bo(bo, offset_in_bytes);
mi_rpc.ReportID = report_id;
}
}
void
genX(init_state)(struct iris_context *ice)
{
......@@ -6502,6 +6514,7 @@ genX(init_state)(struct iris_context *ice)
ice->vtbl.update_surface_base_address = iris_update_surface_base_address;
ice->vtbl.upload_compute_state = iris_upload_compute_state;
ice->vtbl.emit_raw_pipe_control = iris_emit_raw_pipe_control;
ice->vtbl.emit_mi_report_perf_count = iris_emit_mi_report_perf_count;
ice->vtbl.rebind_buffer = iris_rebind_buffer;
ice->vtbl.load_register_reg32 = iris_load_register_reg32;
ice->vtbl.load_register_reg64 = iris_load_register_reg64;
......
......@@ -37,6 +37,7 @@ files_libiris = files(
'iris_formats.c',
'iris_genx_macros.h',
'iris_genx_protos.h',
'iris_monitor.c',
'iris_pipe.h',
'iris_pipe_control.c',
'iris_program.c',
......@@ -89,7 +90,7 @@ libiris = static_library(
dependencies : [dep_libdrm, dep_valgrind, idep_genxml, idep_libintel_common],
link_with : [
iris_gen_libs, libintel_compiler, libintel_dev, libisl,
libblorp
libblorp, libintel_perf
],
)
......
  • Hi

    I've bisected back to this commit, when I launch Steam it segfaults when it's built with -O3 and LTO

    Building with just -O3 works around the issue too

    steam[1804860]: segfault at 0 ip 00000000f6371b97 sp 00000000fff096c0 error 6 in iris_dri.so[f5cf7000+1134000]

  • Neither 661be3fe or 0f3768bc fixes things for me here

    I tried reverting 0fd43597 but got a build failure

    ../mesa-9999/src/gallium/drivers/iris/iris_query.c:46:10: fatal error: iris_monitor.h: No such file or directory
       46 | #include "iris_monitor.h"
          |          ^~~~~~~~~~~~~~~~

    This is what I'm building with:

    meson --buildtype plain --libdir lib --localstatedir /var/lib --prefix /usr --sysconfdir /etc --wrap-mode nodownload --cross-file /var/tmp/portage/media-libs/mesa-9999/temp/meson.i686-pc-linux-gnu.x86 -Dplatforms=surfaceless,x11,wayland,drm -Dllvm=true -Dlmsensors=true -Dlibunwind=false -Dgallium-nine=true -Dgallium-va=true -Dva-libs-path=/usr/lib/va/drivers -Dgallium-vdpau=true -Dgallium-xa=false -Dgallium-xvmc=false -Dgallium-opencl=disabled -Dglx-read-only-text=false -Dosmesa=none -Dbuild-tests=false -Dglx=dri -Dshared-glapi=true -Ddri3=true -Degl=true -Dgbm=true -Dgles1=false -Dgles2=true -Dglvnd=false -Dselinux=false -Dvalgrind=false -Ddri-drivers= -Dgallium-drivers=iris,radeonsi,swrast -Dvulkan-drivers=amd,intel -Dvulkan-overlay-layer=true --buildtype plain -Db_ndebug=true /var/tmp/portage/media-libs/mesa-9999/work/mesa-9999 /var/tmp/portage/media-libs/mesa-9999/work/mesa-9999-abi_x86_32.x86

    The Meson build system
    Version: 0.51.1
    Source dir: /var/tmp/portage/media-libs/mesa-9999/work/mesa-9999
    Build dir: /var/tmp/portage/media-libs/mesa-9999/work/mesa-9999-abi_x86_32.x86
    Build type: cross build
    Program python found: YES (/var/tmp/portage/media-libs/mesa-9999/temp/python3.7/bin/python)
    Project name: mesa
    Project version: 19.2.0-devel
    Appending CFLAGS from environment: '-O3 -march=native -pipe -flto=8'
    Appending LDFLAGS from environment: '-O3 -march=native -pipe -flto=8 -Wl,-O2 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,--build-id=sha1'
    C compiler for the build machine: x86_64-pc-linux-gnu-gcc -m32 (gcc 9.1.0 "x86_64-pc-linux-gnu-gcc (Gentoo 9.1.0-r1 p1.1) 9.1.0")
    Appending CXXFLAGS from environment: '-O3 -march=native -pipe -flto=8'
    Appending LDFLAGS from environment: '-O3 -march=native -pipe -flto=8 -Wl,-O2 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,--build-id=sha1'
    C++ compiler for the build machine: x86_64-pc-linux-gnu-g++ -m32 (gcc 9.1.0 "x86_64-pc-linux-gnu-g++ (Gentoo 9.1.0-r1 p1.1) 9.1.0")
    C compiler for the host machine: x86_64-pc-linux-gnu-gcc -m32 (gcc 9.1.0 "x86_64-pc-linux-gnu-gcc (Gentoo 9.1.0-r1 p1.1) 9.1.0")
    WARNING: Env var AR seems to point to the cross compiler.
    This is probably wrong, it should always point to the native compiler.
    Edited by Mike Lothian
  • I got a backtrace from gdb:

    Thread 1 "steam" received signal SIGSEGV, Segmentation fault.
    0xf632d4ad in ralloc_steal () from /usr/lib/dri/iris_dri.so
    (gdb) bt
    #0  0xf632d4ad in ralloc_steal () from /usr/lib/dri/iris_dri.so
    #1  0xf63efe93 in steal_memory(ir_instruction*, void*) [clone .lto_priv.0] () from /usr/lib/dri/iris_dri.so
    #2  0xf63ee7ca in ir_hierarchical_visitor::visit_enter(ir_function*) () from /usr/lib/dri/iris_dri.so
    #3  0xf63ee0b1 in ir_function::accept(ir_hierarchical_visitor*) () from /usr/lib/dri/iris_dri.so
    #4  0xf6678787 in _mesa_get_fixed_func_fragment_program () from /usr/lib/dri/iris_dri.so
    #5  0xf675c65b in update_program () from /usr/lib/dri/iris_dri.so
    #6  0xf6772b2f in _mesa_update_state_locked () from /usr/lib/dri/iris_dri.so
    #7  0xf6773237 in _mesa_update_state () from /usr/lib/dri/iris_dri.so
    #8  0xf6497467 in _mesa_Clear () from /usr/lib/dri/iris_dri.so
    #9  0xed1ae806 in ?? () from /home/fireburn/.local/share/Steam/ubuntu12_32/vgui2_s.so
    #10 0xed1bd4ed in ?? () from /home/fireburn/.local/share/Steam/ubuntu12_32/vgui2_s.so
    #11 0xf054bc6d in ?? () from /home/fireburn/.local/share/Steam/ubuntu12_32/steamui.so
    #12 0xf054bef5 in ?? () from /home/fireburn/.local/share/Steam/ubuntu12_32/steamui.so
    #13 0xf053e28f in ?? () from /home/fireburn/.local/share/Steam/ubuntu12_32/steamui.so
    #14 0xf0491eaa in ?? () from /home/fireburn/.local/share/Steam/ubuntu12_32/steamui.so
    #15 0xf0493c2e in ?? () from /home/fireburn/.local/share/Steam/ubuntu12_32/steamui.so
    #16 0x5658e1b0 in RunSteam(int, char**, bool) ()
    #17 0x5658f0ab in ?? ()
    #18 0x5657a06c in ?? ()
    #19 0xf78a5021 in __libc_start_main () from /lib/libc.so.6
    #20 0x5657dd29 in _start ()
    Edited by Mike Lothian
  • mentioned in commit rellla/mesa@728ebcde

    Toggle commit list
  • mentioned in commit 18511e3f

    Toggle commit list
  • mentioned in issue #1358 (closed)

    Toggle commit list
  • mentioned in commit 921154a5

    Toggle commit list
  • mentioned in commit 8241167c

    Toggle commit list
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment