radeonsi: initialize shader compilers in threads on demand

It takes a noticable amount of time with piglit.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
This commit is contained in:
Marek Olšák 2019-10-25 20:25:59 -04:00
parent 1380db9fa8
commit 4d1e43badb
4 changed files with 14 additions and 8 deletions

View file

@ -121,6 +121,9 @@ static void si_create_compute_state_async(void *job, int thread_index)
assert(thread_index < ARRAY_SIZE(sscreen->compiler));
compiler = &sscreen->compiler[thread_index];
if (!compiler->passes)
si_init_compiler(sscreen, compiler);
if (program->ir_type == PIPE_SHADER_IR_TGSI) {
tgsi_scan_shader(sel->tokens, &sel->info);
} else {

View file

@ -127,8 +127,7 @@ static const struct debug_named_value debug_options[] = {
DEBUG_NAMED_VALUE_END /* must be last */
};
static void si_init_compiler(struct si_screen *sscreen,
struct ac_llvm_compiler *compiler)
void si_init_compiler(struct si_screen *sscreen, struct ac_llvm_compiler *compiler)
{
/* Only create the less-optimizing version of the compiler on APUs
* predating Ryzen (Raven). */
@ -938,7 +937,7 @@ radeonsi_screen_create_impl(struct radeon_winsys *ws,
const struct pipe_screen_config *config)
{
struct si_screen *sscreen = CALLOC_STRUCT(si_screen);
unsigned hw_threads, num_comp_hi_threads, num_comp_lo_threads, i;
unsigned hw_threads, num_comp_hi_threads, num_comp_lo_threads;
if (!sscreen) {
return NULL;
@ -1224,11 +1223,6 @@ radeonsi_screen_create_impl(struct radeon_winsys *ws,
}
}
for (i = 0; i < num_comp_hi_threads; i++)
si_init_compiler(sscreen, &sscreen->compiler[i]);
for (i = 0; i < num_comp_lo_threads; i++)
si_init_compiler(sscreen, &sscreen->compiler_lowp[i]);
sscreen->ge_wave_size = 64;
sscreen->ps_wave_size = 64;
sscreen->compute_wave_size = 64;

View file

@ -1426,6 +1426,9 @@ void si_dispatch_prim_discard_cs_and_draw(struct si_context *sctx,
unsigned input_indexbuf_max_elements);
void si_initialize_prim_discard_tunables(struct si_context *sctx);
/* si_pipe.c */
void si_init_compiler(struct si_screen *sscreen, struct ac_llvm_compiler *compiler);
/* si_perfcounters.c */
void si_init_perfcounters(struct si_screen *screen);
void si_destroy_perfcounters(struct si_screen *screen);

View file

@ -2105,6 +2105,9 @@ static void si_build_shader_variant(struct si_shader *shader,
compiler = shader->compiler_ctx_state.compiler;
}
if (!compiler->passes)
si_init_compiler(sscreen, compiler);
if (unlikely(!si_shader_create(sscreen, compiler, shader, debug))) {
PRINT_ERR("Failed to build shader variant (type=%u)\n",
sel->type);
@ -2472,6 +2475,9 @@ static void si_init_shader_selector_async(void *job, int thread_index)
assert(thread_index < ARRAY_SIZE(sscreen->compiler));
compiler = &sscreen->compiler[thread_index];
if (!compiler->passes)
si_init_compiler(sscreen, compiler);
/* Compile the main shader part for use with a prolog and/or epilog.
* If this fails, the driver will try to compile a monolithic shader
* on demand.