On Thu, 2014-07-31 at 14:58 -0400, Tom Stellard wrote: > On Thu, Jul 31, 2014 at 01:28:45PM -0400, Jan Vesely wrote: > > On Thu, 2014-07-31 at 11:02 -0400, Tom Stellard wrote: > > > On Wed, Jul 30, 2014 at 07:11:35PM -0400, Jan Vesely wrote: > > > > Make the function static. > > > > > > > > > > No need to cc llvm-commits on these mesa patches. Reviewers follow both > > > lists. > > > > sorry about that > > > > > > > > > This needs corresponding change in LLVM otherwise it breaks parameter > > > > passing > > > > > > > > CC: Tom Stellard <[email protected]> > > > > CC: Matt Arsenault <[email protected]> > > > > > > > > Signed-off-by: Jan Vesely <[email protected]> > > > > --- > > > > src/gallium/drivers/r600/evergreen_compute.c | 26 > > > > +++++++++++++++++++++----- > > > > src/gallium/drivers/r600/evergreen_compute.h | 1 - > > > > 2 files changed, 21 insertions(+), 6 deletions(-) > > > > > > > > diff --git a/src/gallium/drivers/r600/evergreen_compute.c > > > > b/src/gallium/drivers/r600/evergreen_compute.c > > > > index 3928676..150bc5c 100644 > > > > --- a/src/gallium/drivers/r600/evergreen_compute.c > > > > +++ b/src/gallium/drivers/r600/evergreen_compute.c > > > > @@ -266,24 +266,31 @@ static void evergreen_bind_compute_state(struct > > > > pipe_context *ctx_, void *state) > > > > * DWORDS 3-5: Number of global work items in each dimension (x,y,z) > > > > * DWORDS 6-8: Number of work items within each work group in each > > > > dimension > > > > * (x,y,z) > > > > - * DWORDS 9+ : Kernel parameters > > > > + * DWORD 9 : work dimension (needs new enough llvm) > > > > + * DWORDS 10+: Kernel parameters > > > > > > I would prefer to add new parameters after the kernel arguments, so we > > > don't need to break compatibility with LLVM every time we add a new > > > parameter. > > > > How would this work with multiple kernel in one module? Is it possible > > to know what kernel is the lowered code going to end up in? or did you > > have a static offset in mind? > > > > I was thinking of using a static offset from the end of the kernel > arguments. So KernelArgSize + 0 would be number of dimensions > and it would be available to all kernels. > > Then the compiler could lower any use of get_dims to a load > from the input buffer at the correct offset.
Would that work with things like one kernel calling another kernel? If
we had a function called from two kernels how would it know where to
look?
Can we ask llvm about the offset at runtime? and then do:
memcpy( , , min(sizeof(mesa_values), llvm_provided_offset));
pad 0 if necessary
copy args
jan
>
> -Tom
>
> > jan
> >
> >
> >
> > >
> > >
> > > -Tom
> > >
> > > > */
> > > > -void evergreen_compute_upload_input(
> > > > +static void evergreen_compute_upload_input(
> > > > struct pipe_context *ctx_,
> > > > const uint *block_layout,
> > > > const uint *grid_layout,
> > > > - const void *input)
> > > > + const void *input,
> > > > + unsigned dimensions)
> > > > {
> > > > struct r600_context *ctx = (struct r600_context *)ctx_;
> > > > struct r600_pipe_compute *shader = ctx->cs_shader_state.shader;
> > > > unsigned i;
> > > > - /* We need to reserve 9 dwords (36 bytes) for implicit kernel
> > > > + /* We need to reserve 10 dwords (40 bytes) for implicit kernel
> > > > * parameters.
> > > > */
> > > > +#if HAVE_LLVM >= 0x0306
> > > > + unsigned input_size = shader->input_size + 40;
> > > > +#else
> > > > unsigned input_size = shader->input_size + 36;
> > > > +#endif
> > > > uint32_t * num_work_groups_start;
> > > > uint32_t * global_size_start;
> > > > uint32_t * local_size_start;
> > > > + uint32_t * work_dim;
> > > > uint32_t * kernel_parameters_start;
> > > > struct pipe_box box;
> > > > struct pipe_transfer *transfer = NULL;
> > > > @@ -306,7 +313,14 @@ void evergreen_compute_upload_input(
> > > > &box, &transfer);
> > > > global_size_start = num_work_groups_start + (3 * (sizeof(uint)
> > > > /4));
> > > > local_size_start = global_size_start + (3 * (sizeof(uint)) / 4);
> > > > +#if HAVE_LLVM >= 0x0306
> > > > + work_dim = local_size_start + (3 * (sizeof(uint)) / 4);
> > > > + work_dim[0] = dimensions;
> > > > +
> > > > + kernel_parameters_start = work_dim + (1 * (sizeof(uint)) / 4);
> > > > +#else
> > > > kernel_parameters_start = local_size_start + (3 *
> > > > (sizeof(uint)) / 4);
> > > > +#endif
> > > >
> > > > /* Copy the work group size */
> > > > memcpy(num_work_groups_start, grid_layout, 3 * sizeof(uint));
> > > > @@ -319,6 +333,7 @@ void evergreen_compute_upload_input(
> > > > /* Copy the local dimensions */
> > > > memcpy(local_size_start, block_layout, 3 * sizeof(uint));
> > > >
> > > > +
> > > > /* Copy the kernel inputs */
> > > > memcpy(kernel_parameters_start, input, shader->input_size);
> > > >
> > > > @@ -584,7 +599,8 @@ static void evergreen_launch_grid(
> > > > #endif
> > > > shader->active_kernel = kernel;
> > > > ctx->cs_shader_state.kernel_index = pc;
> > > > - evergreen_compute_upload_input(ctx_, block_layout, grid_layout,
> > > > input);
> > > > + evergreen_compute_upload_input(ctx_, block_layout, grid_layout,
> > > > input,
> > > > + dimensions);
> > > > compute_emit_cs(ctx, block_layout, grid_layout);
> > > > }
> > > >
> > > > diff --git a/src/gallium/drivers/r600/evergreen_compute.h
> > > > b/src/gallium/drivers/r600/evergreen_compute.h
> > > > index 4fb53a1..570ab2a 100644
> > > > --- a/src/gallium/drivers/r600/evergreen_compute.h
> > > > +++ b/src/gallium/drivers/r600/evergreen_compute.h
> > > > @@ -40,7 +40,6 @@ struct r600_resource_global {
> > > >
> > > > void *evergreen_create_compute_state(struct pipe_context *ctx, const
> > > > struct pipe_compute_state *cso);
> > > > void evergreen_delete_compute_state(struct pipe_context *ctx, void
> > > > *state);
> > > > -void evergreen_compute_upload_input(struct pipe_context *context,
> > > > const uint *block_layout, const uint *grid_layout, const void *input);
> > > > void evergreen_init_atom_start_compute_cs(struct r600_context *rctx);
> > > > void evergreen_init_compute_state_functions(struct r600_context *rctx);
> > > > void evergreen_emit_cs_shader(struct r600_context *rctx, struct
> > > > r600_atom * atom);
> > > > --
> > > > 1.9.3
> > > >
> >
> > --
> > Jan Vesely <[email protected]>
>
>
--
Jan Vesely <[email protected]>
signature.asc
Description: This is a digitally signed message part
_______________________________________________ mesa-dev mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-dev
