[Mesa-dev] [PATCH WIP 11/13] nvc0: add compute invocation counter

Karol Herbst kherbst at redhat.com
Mon Jul 16 04:30:15 UTC 2018


with that KHR-GL45.pipeline_statistics_query_tests_ARB.functional_compute_shader_invocations,
sometimes runs into a write fault, but a weird one:

"fifo: write fault at 000fa24000 engine 00 [GR] client 1d [DFALCON]
reason 02 [PTE] on channel 3 [017f0de000 Xorg[3116]]" and I am not
even sure that this patch is the cause of it, just noticed it within a
CTS run.

On Sun, Jul 15, 2018 at 8:15 PM, Karol Herbst <kherbst at redhat.com> wrote:
> From: Rhys Perry <pendingchaos02 at gmail.com>
>
> Signed-off-by: Karol Herbst <kherbst at redhat.com>
> ---
>  .../drivers/nouveau/nvc0/nvc0_compute.c       | 32 +++++++++++++++++++
>  .../drivers/nouveau/nvc0/nvc0_context.h       |  4 +++
>  .../drivers/nouveau/nvc0/nvc0_query_hw.c      |  7 ++--
>  .../drivers/nouveau/nvc0/nve4_compute.c       |  2 ++
>  4 files changed, 43 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c b/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c
> index 11635c94658..53134ed2c7e 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c
> @@ -498,4 +498,36 @@ nvc0_launch_grid(struct pipe_context *pipe, const struct pipe_grid_info *info)
>     nouveau_bufctx_reset(nvc0->bufctx_cp, NVC0_BIND_CP_SUF);
>     nvc0->dirty_cp |= NVC0_NEW_CP_SURFACES;
>     nvc0->images_dirty[5] |= nvc0->images_valid[5];
> +
> +   nvc0_update_compute_invocations_counter(nvc0, info);
> +}
> +
> +static void
> +nvc0_compute_update_indirect_invocations(struct nvc0_context *nvc0,
> +                                         const struct pipe_grid_info *info) {
> +   struct nv04_resource *grid_buf = nv04_resource(info->indirect);
> +
> +   struct pipe_box box;
> +   u_box_1d(info->indirect_offset, 12, &box);
> +   struct pipe_transfer *transfer;
> +
> +   uint32_t *grid = grid_buf->vtbl->transfer_map(
> +      &nvc0->base.pipe, &grid_buf->base, 0, PIPE_TRANSFER_READ, &box, &transfer);
> +
> +   nvc0->compute_invocations += grid[0] * grid[1] * grid[2] *
> +                               info->block[0] * info->block[1] * info->block[2];
> +
> +   grid_buf->vtbl->transfer_unmap(&nvc0->base.pipe, transfer);
> +}
> +
> +void
> +nvc0_update_compute_invocations_counter(struct nvc0_context *nvc0,
> +                                        const struct pipe_grid_info *info) {
> +   if (unlikely(info->indirect)) {
> +      nvc0_compute_update_indirect_invocations(nvc0, info);
> +   } else {
> +      uint64_t invocations = info->block[0] * info->block[1] * info->block[2];
> +      invocations *= info->grid[0] * info->grid[1] * info->grid[2];
> +      nvc0->compute_invocations += invocations;
> +   }
>  }
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h
> index 77237a3c0a3..c96c5f3bd04 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h
> @@ -278,6 +278,8 @@ struct nvc0_context {
>     uint16_t images_valid[6];
>
>     struct util_dynarray global_residents;
> +
> +   uint64_t compute_invocations;
>  };
>
>  static inline struct nvc0_context *
> @@ -436,5 +438,7 @@ void nve4_launch_grid(struct pipe_context *, const struct pipe_grid_info *);
>  /* nvc0_compute.c */
>  void nvc0_launch_grid(struct pipe_context *, const struct pipe_grid_info *);
>  void nvc0_compute_validate_globals(struct nvc0_context *);
> +void nvc0_update_compute_invocations_counter(struct nvc0_context *nvc0,
> +                                             const struct pipe_grid_info *info);
>
>  #endif
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c
> index a420ed4ac0d..4b114c08fac 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c
> @@ -199,6 +199,8 @@ nvc0_hw_begin_query(struct nvc0_context *nvc0, struct nvc0_query *q)
>        nvc0_hw_query_get(push, q, 0xc0 + 0x70, 0x0980a002); /* ROP, PIXELS */
>        nvc0_hw_query_get(push, q, 0xc0 + 0x80, 0x0d808002); /* TCP, LAUNCHES */
>        nvc0_hw_query_get(push, q, 0xc0 + 0x90, 0x0e809002); /* TEP, LAUNCHES */
> +      nvc0->base.push_data(&nvc0->base, hq->bo, hq->offset + 0xc0 + 0xa0,
> +                           NOUVEAU_BO_GART, 8, &nvc0->compute_invocations);
>        break;
>     default:
>        break;
> @@ -271,6 +273,8 @@ nvc0_hw_end_query(struct nvc0_context *nvc0, struct nvc0_query *q)
>        nvc0_hw_query_get(push, q, 0x70, 0x0980a002); /* ROP, PIXELS */
>        nvc0_hw_query_get(push, q, 0x80, 0x0d808002); /* TCP, LAUNCHES */
>        nvc0_hw_query_get(push, q, 0x90, 0x0e809002); /* TEP, LAUNCHES */
> +      nvc0->base.push_data(&nvc0->base, hq->bo, hq->offset + 0xa0,
> +                           NOUVEAU_BO_GART, 8, &nvc0->compute_invocations);
>        break;
>     case PIPE_QUERY_TIMESTAMP_DISJOINT:
>        /* This query is not issued on GPU because disjoint is forced to false */
> @@ -353,9 +357,8 @@ nvc0_hw_get_query_result(struct nvc0_context *nvc0, struct nvc0_query *q,
>        res64[0] = data64[1] - data64[3];
>        break;
>     case PIPE_QUERY_PIPELINE_STATISTICS:
> -      for (i = 0; i < 10; ++i)
> +      for (i = 0; i < 11; ++i)
>           res64[i] = data64[i * 2] - data64[24 + i * 2];
> -      result->pipeline_statistics.cs_invocations = 0;
>        break;
>     case NVC0_HW_QUERY_TFB_BUFFER_OFFSET:
>        res32[0] = hq->data[1];
> diff --git a/src/gallium/drivers/nouveau/nvc0/nve4_compute.c b/src/gallium/drivers/nouveau/nvc0/nve4_compute.c
> index 28460f8cbeb..9bc753e7a54 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nve4_compute.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nve4_compute.c
> @@ -748,6 +748,8 @@ nve4_launch_grid(struct pipe_context *pipe, const struct pipe_grid_info *info)
>     BEGIN_NVC0(push, SUBC_CP(NV50_GRAPH_SERIALIZE), 1);
>     PUSH_DATA (push, 0);
>
> +   nvc0_update_compute_invocations_counter(nvc0, info);
> +
>  out:
>     if (ret)
>        NOUVEAU_ERR("Failed to launch grid !\n");
> --
> 2.17.1
>


More information about the mesa-dev mailing list