diff options
author | Marek Olšák <[email protected]> | 2017-05-31 13:18:53 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-06-07 18:43:42 +0200 |
commit | 86cc8097266c2bd9d8a6ccc3d7f61391f13119be (patch) | |
tree | 48944a4f56f14aef32e56a73915595b16aab0e49 /src/gallium/drivers/radeonsi/si_pipe.c | |
parent | 89b6c93ae3135a44b1aa2ce9285502a3898920bc (diff) |
radeonsi: use a compiler queue with a low priority for optimized shaders
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/gallium/drivers/radeonsi/si_pipe.c')
-rw-r--r-- | src/gallium/drivers/radeonsi/si_pipe.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 47426b41da6..805392d7132 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -742,11 +742,16 @@ static void si_destroy_screen(struct pipe_screen* pscreen) return; util_queue_destroy(&sscreen->shader_compiler_queue); + util_queue_destroy(&sscreen->shader_compiler_queue_low_priority); for (i = 0; i < ARRAY_SIZE(sscreen->tm); i++) if (sscreen->tm[i]) LLVMDisposeTargetMachine(sscreen->tm[i]); + for (i = 0; i < ARRAY_SIZE(sscreen->tm_low_priority); i++) + if (sscreen->tm_low_priority[i]) + LLVMDisposeTargetMachine(sscreen->tm_low_priority[i]); + /* Free shader parts. */ for (i = 0; i < ARRAY_SIZE(parts); i++) { while (parts[i]) { @@ -860,7 +865,7 @@ static void si_test_vmfault(struct si_screen *sscreen) struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws) { struct si_screen *sscreen = CALLOC_STRUCT(si_screen); - unsigned num_cpus, num_compiler_threads, i; + unsigned num_threads, num_compiler_threads, num_compiler_threads_lowprio, i; if (!sscreen) { return NULL; @@ -885,9 +890,11 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws) /* Only enable as many threads as we have target machines, but at most * the number of CPUs - 1 if there is more than one. */ - num_cpus = sysconf(_SC_NPROCESSORS_ONLN); - num_cpus = MAX2(1, num_cpus - 1); - num_compiler_threads = MIN2(num_cpus, ARRAY_SIZE(sscreen->tm)); + num_threads = sysconf(_SC_NPROCESSORS_ONLN); + num_threads = MAX2(1, num_threads - 1); + num_compiler_threads = MIN2(num_threads, ARRAY_SIZE(sscreen->tm)); + num_compiler_threads_lowprio = + MIN2(num_threads, ARRAY_SIZE(sscreen->tm_low_priority)); if (!util_queue_init(&sscreen->shader_compiler_queue, "si_shader", 32, num_compiler_threads, 0)) { @@ -896,6 +903,20 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws) return NULL; } + /* The queue must be large enough so that adding optimized shaders + * doesn't stall draw calls when the queue is full. Especially varying + * packing generates a very high volume of optimized shader compilation + * jobs. + */ + if (!util_queue_init(&sscreen->shader_compiler_queue_low_priority, + "si_shader_low", + 1024, num_compiler_threads, + UTIL_QUEUE_INIT_USE_MINIMUM_PRIORITY)) { + si_destroy_shader_cache(sscreen); + FREE(sscreen); + return NULL; + } + si_handle_env_var_force_family(sscreen); if (!debug_get_bool_option("RADEON_DISABLE_PERFCOUNTERS", false)) @@ -959,6 +980,8 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws) for (i = 0; i < num_compiler_threads; i++) sscreen->tm[i] = si_create_llvm_target_machine(sscreen); + for (i = 0; i < num_compiler_threads_lowprio; i++) + sscreen->tm_low_priority[i] = si_create_llvm_target_machine(sscreen); /* Create the auxiliary context. This must be done last. */ sscreen->b.aux_context = si_create_context(&sscreen->b.b, 0); |