[Mesa-dev] [PATCH 8/8] radeonsi: add radeonsi_sync_compile option

Marek Olšák maraeo at gmail.com
Thu Apr 25 02:53:16 UTC 2019


For patches 2 - 8:

Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek

On Wed, Apr 24, 2019 at 9:15 AM Nicolai Hähnle <nhaehnle at gmail.com> wrote:

> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>
> Force the driver thread to sync immediately with a compiler thread (but
> compilation still happens in a separate thread).
>
> This can be useful to simplify debugging compiler issues.
> ---
>  src/gallium/drivers/radeonsi/si_debug_options.inc |  1 +
>  src/gallium/drivers/radeonsi/si_state_shaders.c   | 13 ++++++++++---
>  2 files changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_debug_options.inc
> b/src/gallium/drivers/radeonsi/si_debug_options.inc
> index f4c3e19ed95..019256ca1d1 100644
> --- a/src/gallium/drivers/radeonsi/si_debug_options.inc
> +++ b/src/gallium/drivers/radeonsi/si_debug_options.inc
> @@ -1,5 +1,6 @@
>  OPT_BOOL(clear_db_cache_before_clear, false, "Clear DB cache before fast
> depth clear")
>  OPT_BOOL(enable_nir, false, "Enable NIR")
>  OPT_BOOL(aux_debug, false, "Generate ddebug_dumps for the auxiliary
> context")
> +OPT_BOOL(sync_compile, false, "Always compile synchronously (will cause
> stalls)")
>
>  #undef OPT_BOOL
> diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c
> b/src/gallium/drivers/radeonsi/si_state_shaders.c
> index 5bdfd4f6ac1..f57e7730905 100644
> --- a/src/gallium/drivers/radeonsi/si_state_shaders.c
> +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
> @@ -1945,20 +1945,24 @@ current_not_ready:
>                         sel->first_variant = shader;
>                         sel->last_variant = shader;
>                 } else {
>                         sel->last_variant->next_variant = shader;
>                         sel->last_variant = shader;
>                 }
>
>                 /* Use the default (unoptimized) shader for now. */
>                 memset(&key->opt, 0, sizeof(key->opt));
>                 mtx_unlock(&sel->mutex);
> +
> +               if (sscreen->options.sync_compile)
> +                       util_queue_fence_wait(&shader->ready);
> +
>                 goto again;
>         }
>
>         /* Reset the fence before adding to the variant list. */
>         util_queue_fence_reset(&shader->ready);
>
>         if (!sel->last_variant) {
>                 sel->first_variant = shader;
>                 sel->last_variant = shader;
>         } else {
> @@ -2157,38 +2161,41 @@ static void si_init_shader_selector_async(void
> *job, int thread_index)
>  }
>
>  void si_schedule_initial_compile(struct si_context *sctx, unsigned
> processor,
>                                  struct util_queue_fence *ready_fence,
>                                  struct si_compiler_ctx_state
> *compiler_ctx_state,
>                                  void *job, util_queue_execute_func
> execute)
>  {
>         util_queue_fence_init(ready_fence);
>
>         struct util_async_debug_callback async_debug;
> -       bool wait =
> +       bool debug =
>                 (sctx->debug.debug_message && !sctx->debug.async) ||
>                 sctx->is_debug ||
>                 si_can_dump_shader(sctx->screen, processor);
>
> -       if (wait) {
> +       if (debug) {
>                 u_async_debug_init(&async_debug);
>                 compiler_ctx_state->debug = async_debug.base;
>         }
>
>         util_queue_add_job(&sctx->screen->shader_compiler_queue, job,
>                            ready_fence, execute, NULL);
>
> -       if (wait) {
> +       if (debug) {
>                 util_queue_fence_wait(ready_fence);
>                 u_async_debug_drain(&async_debug, &sctx->debug);
>                 u_async_debug_cleanup(&async_debug);
>         }
> +
> +       if (sctx->screen->options.sync_compile)
> +               util_queue_fence_wait(ready_fence);
>  }
>
>  /* Return descriptor slot usage masks from the given shader info. */
>  void si_get_active_slot_masks(const struct tgsi_shader_info *info,
>                               uint32_t *const_and_shader_buffers,
>                               uint64_t *samplers_and_images)
>  {
>         unsigned start, num_shaderbufs, num_constbufs, num_images,
> num_samplers;
>
>         num_shaderbufs = util_last_bit(info->shader_buffers_declared);
> --
> 2.20.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20190424/1c370bd3/attachment.html>


More information about the mesa-dev mailing list