5 Replies Latest reply on May 13, 2015 4:47 AM by dipak

    clCreateKernel SIGSEGVs if used with binary image in openCL 1.2

    nibal

      Problem happens only when used with binary kernel image compiled for the same device. Building from kernel sources works fine.

      My program uses the FFT_Kernels.cl from your samples. Binary image was saved and loaded using your code in CLUtils.cpp,

      however, converted to C.

       

      Running it through the debugger, gdb, shows:

      .

      .

      .

      setupCL () at dsp.c:252

      252        fft_kernel = clCreateKernel(prog, "fft", &err);

      (gdb)

       

      Program received signal SIGSEGV, Segmentation fault.

      0x00007ffff3bc71fc in ?? () from /opt/AMDAPPSDK-2.9-1/lib/x86_64/libamdocl64.so

      (gdb) where

      #0  0x00007ffff3bc71fc in ?? ()

         from /opt/AMDAPPSDK-2.9-1/lib/x86_64/libamdocl64.so

      #1  0x00007ffff3baa8de in clCreateKernel ()

         from /opt/AMDAPPSDK-2.9-1/lib/x86_64/libamdocl64.so

      #2  0x000000000040e0da in setupCL () at dsp.c:252

      #3  0x000000000040a29f in main (argc=1, argv=0x7fffffffdd30) at sdmp.l:2097

      (gdb) p prog

      $6 = (cl_program) 0xdeacd0

       

      Using fglrx-14.501.1003 in Ubuntu 14.04 x64, with SDK 2.9.1 (opencl 1.2)

      Video card R9 200 Saphire, codename Pitcairn. CPU AMD FX(tm)-8320 Eight-Core Processor

        • Re: clCreateKernel SIGSEGVs if used with binary image in openCL 1.2
          dipak

          Did you try the command line arguments "--dump" and "--load" to generate and consume the device binary for any of SDK sample?

          Please make sure that you are providing the correct device binary during the "--load" or clCreateProgramWithBinary. Input device binary should match with the target device.


          Regards,


            • Re: clCreateKernel SIGSEGVs if used with binary image in openCL 1.2
              nibal

              I'm not sure what you mean by --load and --dump command lines. I just use the FFT_Kernels.cl from the samples to do my fft.My program doesn't take these args. I only have 1 GPU device and I save binary image under FFT_Kernels_Pitcairn, where Pitcairn is the codename of my GPU. This again my app gets it from clGetDeviceInfo->DEVICE_NAME, both when it saves it and when it loads it. Not a chance for a mistake:-(

              Bear in mind that the same mechanism works fine with kernel sources...

              file -s FFT_Kernels_Pitcairn detects "corrupted ELF32 executable"

              • Re: clCreateKernel SIGSEGVs if used with binary image in openCL 1.2
                nibal

                I finally understood that you meant running the samples using these args. Did it and it worked. So problem was in my code. I compared kernel images for FFT_Kernels.cl with the sample's and were identical. So saving image was fine. Looking at the loading part, the problem was that I was just loading the binary kernel image, not building it. I didn't suspect that a binary kernel image for a specific device needed further compilation or building :-(.

                Now everything works fine. Thank you so much:-)

                One last question. Is there a compiler option to generate 64bit kernel code? I used the example's cflags and resulting kernel image is ELF32. I tried adding the gcc option -m64, but nothing changed. I'm not even sure that the final kernel object is 32bit, since it is always built in memory.