[Mesa-dev] [PATCH] radv/ac: enable loop unrolling.
Marek Olšák
maraeo at gmail.com
Fri Feb 24 09:45:54 UTC 2017
On Fri, Feb 24, 2017 at 5:36 AM, Matt Arsenault <arsenm2 at gmail.com> wrote:
>
> On Feb 23, 2017, at 19:44, Dave Airlie <airlied at gmail.com> wrote:
>
> On 24 February 2017 at 13:36, Matt Arsenault <arsenm2 at gmail.com> wrote:
>
>
> On Feb 23, 2017, at 19:27, Dave Airlie <airlied at gmail.com> wrote:
>
> +static void set_unroll_metadata(struct nir_to_llvm_context *ctx,
> + LLVMValueRef br)
> +{
> + unsigned kind = LLVMGetMDKindIDInContext(ctx->context, "llvm.loop", 9);
> + LLVMValueRef md_unroll;
> + LLVMValueRef full_arg = LLVMMDStringInContext(ctx->context,
> "llvm.loop.unroll.full", 21);
> + LLVMValueRef full = LLVMMDNodeInContext(ctx->context, &full_arg, 1);
> +
> + LLVMValueRef md_args[] = {NULL, full};
> + md_unroll = LLVMMDNodeInContext(ctx->context, md_args, 2);
> + ac_metadata_point_op0_to_itself(md_unroll);
> +
> + LLVMSetMetadata(br, kind, md_unroll);
> +}
> +
>
>
> Why are you forcing full unrolling of all loops?
>
>
> Because I copied Marek's code with little idea of what llvm does.
>
> Should I just drop the full bits, perhaps set a llvm.loop.unroll.count = 32?
>
> Dave.
>
>
> The question is more why are you using the unroll metadata at all? It’s for
> implementing user hints like pragma unroll. By default the backend
> heuristics should be making these decisions. If this is helping benchmarks
> then that’s a datapoint that we need to play with those and increase the
> thresholds or something.
The main requirement is that if there is indirect indexing inside a
loop, we always want to unroll the whole loop to get rid of the
indexing, which can decrease scratch usage.
Marek
More information about the mesa-dev
mailing list