Mesa (main): radeonsi: scale the number of shader compiler threads

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri May 13 15:08:34 UTC 2022


Module: Mesa
Branch: main
Commit: e549b6fe42c45efa6e2625cef7c328cb6a6a4319
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e549b6fe42c45efa6e2625cef7c328cb6a6a4319

Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date:   Mon May  2 09:27:59 2022 +0200

radeonsi: scale the number of shader compiler threads

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 <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16273>

---

 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);



More information about the mesa-commit mailing list