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@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16273>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2022-05-02 09:27:59 +02:00 committed by Marge Bot
parent b75b9d5cb4
commit e549b6fe42

View file

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