Mesa (master): st/mesa: simplify checking whether to pin threads to L3

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jan 5 04:11:34 UTC 2021


Module: Mesa
Branch: master
Commit: 1f17f8bb6de8a4187da4a74811b6b810e50ffd7a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1f17f8bb6de8a4187da4a74811b6b810e50ffd7a

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Sun Nov 29 03:03:50 2020 -0500

st/mesa: simplify checking whether to pin threads to L3

Reviewed-by: Eric Anholt <eric at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8017>

---

 src/mesa/state_tracker/st_context.c |  4 ++++
 src/mesa/state_tracker/st_context.h |  6 ++++--
 src/mesa/state_tracker/st_draw.c    | 10 ++++------
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 771679a6b3a..89127319ad5 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -814,6 +814,10 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
          !st->lower_ucp;
    st->shader_has_one_variant[MESA_SHADER_COMPUTE] = st->has_shareable_shaders;
 
+   if (util_cpu_caps.cores_per_L3 == util_cpu_caps.nr_cpus ||
+       !st->pipe->set_context_param)
+      st->pin_thread_counter = ST_L3_PINNING_DISABLED;
+
    st->bitmap.cache.empty = true;
 
    if (ctx->Const.ForceGLNamesReuse && ctx->Shared->RefCount == 1) {
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 0967567826a..f694e5825a1 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -55,6 +55,7 @@ struct st_program;
 struct st_perf_monitor_group;
 struct u_upload_mgr;
 
+#define ST_L3_PINNING_DISABLED 0xffffffff
 
 struct st_bitmap_cache
 {
@@ -131,6 +132,9 @@ struct st_context
    struct draw_stage *feedback_stage;  /**< For GL_FEEDBACK rendermode */
    struct draw_stage *selection_stage;  /**< For GL_SELECT rendermode */
    struct draw_stage *rastpos_stage;  /**< For glRasterPos */
+
+   unsigned pin_thread_counter; /* for L3 thread pinning on AMD Zen */
+
    GLboolean clamp_frag_color_in_shader;
    GLboolean clamp_vert_color_in_shader;
    boolean clamp_frag_depth_in_shader;
@@ -234,8 +238,6 @@ struct st_context
    /** This masks out unused shader resources. Only valid in draw calls. */
    uint64_t active_states;
 
-   unsigned pin_thread_counter; /* for L3 thread pinning on AMD Zen */
-
    /* If true, further analysis of states is required to know if something
     * has changed. Used mainly for shaders.
     */
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 2f5802f8227..7e79d7f6a65 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -102,21 +102,19 @@ prepare_draw(struct st_context *st, struct gl_context *ctx)
       st_validate_state(st, ST_PIPELINE_RENDER);
    }
 
-   struct pipe_context *pipe = st->pipe;
-
    /* Pin threads regularly to the same Zen CCX that the main thread is
     * running on. The main thread can move between CCXs.
     */
-   if (unlikely(/* AMD Zen */
-                util_cpu_caps.nr_cpus != util_cpu_caps.cores_per_L3 &&
+   if (unlikely(st->pin_thread_counter != ST_L3_PINNING_DISABLED &&
                 /* no glthread */
                 ctx->CurrentClientDispatch != ctx->MarshalExec &&
-                /* driver support */
-                pipe->set_context_param &&
                 /* do it occasionally */
                 ++st->pin_thread_counter % 512 == 0)) {
+      st->pin_thread_counter = 0;
+
       int cpu = util_get_current_cpu();
       if (cpu >= 0) {
+         struct pipe_context *pipe = st->pipe;
          unsigned L3_cache = util_cpu_caps.cpu_to_L3[cpu];
 
          pipe->set_context_param(pipe,



More information about the mesa-commit mailing list