st/mesa: simplify checking whether to pin threads to L3
Reviewed-by: Eric Anholt <eric@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8017>
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user