[Mesa-dev] [PATCH] radeon/llvm: Allocate space for kernel metadata operands\

Tom Stellard tom at stellard.net
Thu Jul 3 09:34:55 PDT 2014


On Thu, Jul 03, 2014 at 11:59:00AM -0400, Alex Deucher wrote:
> On Thu, Jul 3, 2014 at 11:46 AM, Aaron Watry <awatry at gmail.com> wrote:
> > On Thu, Jul 3, 2014 at 9:56 AM, Tom Stellard <tom at stellard.net> wrote:
> >> On Wed, Jul 02, 2014 at 04:34:24PM -0500, Aaron Watry wrote:
> >>> Previously, we were assuming that kernel metadata nodes only had 1 operand.
> >>>
> >>> Kernels which have attributes can have more than 1, e.g.:
> >>> !0 = metadata !{void (i32 addrspace(1)*)* @testKernel, metadata !1}
> >>> !1 = metadata !{metadata !"work_group_size_hint", i32 4, i32 1, i32 1}
> >>>
> >>> Attempting to get the kernel without the correct number of attributes led
> >>> to memory corruption and luxrays crashing out.
> >>>
> >>> Fixes the cl/program/execute/attributes.cl piglit test.
> >>>
> >>
> >> Thanks for tracking this down.
> >>
> >
> > no problem.  It was driving me nuts.  I've now got the luxmark kernels
> > building successfully on evergreen (followed by a machine hang and
> > loss of signal to the monitor, but that could be the kernel or the
> > fact that CEDAR seems extra crashy compared to my other EG/NI cards)
> 
> Someone mentioned stability issues with cedar with the golden register
> kernel patch.  Can you see if skipping the golden register setup
> helps?  If so can you narrow down which registers are problematic?
> 

Another possibility is that we aren't correctly implementing the
workaround for the control flow stack hw bug on Cedar.  Since
it has a different wavefront size than other GPUs the bug is not handled
the same way.

You could try using FeatureWavefrontSize64 for cedar in Processors.td,
which would force the backend to use the same work-around on cedar as
it does for other GPUs.

-Tom

> Alex
> 
> > and I'm getting an instruction selection error on radeonsi.  Haven't
> > managed to track that down yet, but at least it means that all
> > required built-ins/defines for luxrays are now present (at least with
> > my own libclc tree), at least with image support disabled in luxrays.
> >
> > If you enable image support, I believe that it is still going to fail
> > due to mismatches/oddness with the number of supported pixel formats.
> >
> > --Aaron
> >
> >> Reviewed-by: Tom Stellard <thomas.stellard at amd.com>
> >>
> >>> Signed-off-by: Aaron Watry <awatry at gmail.com>
> >>> CC: Tom Stellard <thomas.stellard at amd.com>
> >>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76223
> >>> ---
> >>>  src/gallium/drivers/radeon/radeon_llvm_util.c | 10 +++++++---
> >>>  1 file changed, 7 insertions(+), 3 deletions(-)
> >>>
> >>> diff --git a/src/gallium/drivers/radeon/radeon_llvm_util.c b/src/gallium/drivers/radeon/radeon_llvm_util.c
> >>> index 2ace91f..ec11559 100644
> >>> --- a/src/gallium/drivers/radeon/radeon_llvm_util.c
> >>> +++ b/src/gallium/drivers/radeon/radeon_llvm_util.c
> >>> @@ -100,13 +100,17 @@ LLVMModuleRef radeon_llvm_get_kernel_module(LLVMContextRef ctx, unsigned index,
> >>>       kernel_metadata = MALLOC(num_kernels * sizeof(LLVMValueRef));
> >>>       LLVMGetNamedMetadataOperands(mod, "opencl.kernels", kernel_metadata);
> >>>       for (i = 0; i < num_kernels; i++) {
> >>> -             LLVMValueRef kernel_signature, kernel_function;
> >>> +             LLVMValueRef kernel_signature, *kernel_function;
> >>> +             unsigned num_kernel_md_operands;
> >>>               if (i == index) {
> >>>                       continue;
> >>>               }
> >>>               kernel_signature = kernel_metadata[i];
> >>> -             LLVMGetMDNodeOperands(kernel_signature, &kernel_function);
> >>> -             LLVMDeleteFunction(kernel_function);
> >>> +             num_kernel_md_operands = LLVMGetMDNodeNumOperands(kernel_signature);
> >>> +             kernel_function = MALLOC(num_kernel_md_operands * sizeof (LLVMValueRef));
> >>> +             LLVMGetMDNodeOperands(kernel_signature, kernel_function);
> >>> +             LLVMDeleteFunction(*kernel_function);
> >>> +             FREE(kernel_function);
> >>>       }
> >>>       FREE(kernel_metadata);
> >>>       radeon_llvm_optimize(mod);
> >>> --
> >>> 1.9.1
> >>>
> >>> _______________________________________________
> >>> mesa-dev mailing list
> >>> mesa-dev at lists.freedesktop.org
> >>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list