From e549b6fe42c45efa6e2625cef7c328cb6a6a4319 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Mon, 2 May 2022 09:27:59 +0200 Subject: [PATCH] radeonsi: scale the number of shader compiler threads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of spawning all the threads on startup. This speeds up short lived programs (eg: piglit runs duration is reduced by ±25%), avoid wasting resources and still make use of multi-threaded capabilities. Reviewed-by: Marek Olšák Part-of: --- src/gallium/drivers/radeonsi/si_pipe.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 7eb7d364f80..48d7844732c 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -1192,18 +1192,27 @@ static struct pipe_screen *radeonsi_screen_create_impl(struct radeon_winsys *ws, /* Take a reference on the glsl types for the compiler threads. */ glsl_type_singleton_init_or_ref(); - if (!util_queue_init( - &sscreen->shader_compiler_queue, "sh", 64, num_comp_hi_threads, - UTIL_QUEUE_INIT_RESIZE_IF_FULL | UTIL_QUEUE_INIT_SET_FULL_THREAD_AFFINITY, NULL)) { + /* Start with a single thread and a single slot. + * Each time we'll hit the "all slots are in use" case, the number of threads and + * slots will be increased. + */ + int num_slots = num_comp_hi_threads == 1 ? 64 : 1; + if (!util_queue_init(&sscreen->shader_compiler_queue, "sh", num_slots, + num_comp_hi_threads, + UTIL_QUEUE_INIT_RESIZE_IF_FULL | + UTIL_QUEUE_INIT_SCALE_THREADS | + UTIL_QUEUE_INIT_SET_FULL_THREAD_AFFINITY, NULL)) { si_destroy_shader_cache(sscreen); FREE(sscreen); glsl_type_singleton_decref(); return NULL; } - if (!util_queue_init(&sscreen->shader_compiler_queue_low_priority, "shlo", 64, + if (!util_queue_init(&sscreen->shader_compiler_queue_low_priority, "shlo", num_slots, num_comp_lo_threads, - UTIL_QUEUE_INIT_RESIZE_IF_FULL | UTIL_QUEUE_INIT_SET_FULL_THREAD_AFFINITY | + UTIL_QUEUE_INIT_RESIZE_IF_FULL | + UTIL_QUEUE_INIT_SCALE_THREADS | + UTIL_QUEUE_INIT_SET_FULL_THREAD_AFFINITY | UTIL_QUEUE_INIT_USE_MINIMUM_PRIORITY, NULL)) { si_destroy_shader_cache(sscreen); FREE(sscreen);