4 Replies Latest reply on Aug 29, 2010 7:07 AM by timchist

    Binary Kernels

    quadboon

      Since SDK v2.2 there is support for binary ELF kernels. I read the Documentation Article on http://developer.amd.com/support/KnowledgeBase/Lists/KnowledgeBase/DispForm.aspx?ID=115 and it works fine.

      There is an example Package http://developer.amd.com/Downloads/clbinary.zip containing clbinarygen.c. This example program shows how to compile binary Kernels in "offline" Mode and it works fine, too. The program however confuses me. Here is what it produces when i execute it:

      $ ./clbinarygen
      Reading in program from kernel.cl
      Number of platforms found: 1
      Found AMD platform
      Number of devices found: 10
      DEVICE[0]: CL_DEVICE_TYPE_CPU, Name=AMD Athlon(tm) 64 X2 Dual Core Processor 4200+
      DEVICE[1]: CL_DEVICE_TYPE_GPU, Name=ATI RV770
      DEVICE[2]: CL_DEVICE_TYPE_GPU, Name=ATI RV770
      DEVICE[3]: CL_DEVICE_TYPE_GPU, Name=ATI RV770
      DEVICE[4]: CL_DEVICE_TYPE_GPU, Name=ATI RV710
      DEVICE[5]: CL_DEVICE_TYPE_GPU, Name=ATI RV730
      DEVICE[6]: CL_DEVICE_TYPE_GPU, Name=Cypress
      DEVICE[7]: CL_DEVICE_TYPE_GPU, Name=Juniper
      DEVICE[8]: CL_DEVICE_TYPE_GPU, Name=Redwood
      DEVICE[9]: CL_DEVICE_TYPE_GPU, Name=Cedar
      Writing out binary kernel to kernel.bin.0
      Writing out binary kernel to kernel.bin.1
      Writing out binary kernel to kernel.bin.2
      Writing out binary kernel to kernel.bin.3
      Writing out binary kernel to kernel.bin.4
      Writing out binary kernel to kernel.bin.5
      Writing out binary kernel to kernel.bin.6
      Writing out binary kernel to kernel.bin.7
      Writing out binary kernel to kernel.bin.8
      Writing out binary kernel to kernel.bin.9

      You can see it produces 3 times code for ATI RV770. From what  i guess what happens here is that all the Devices that are physically present on my Computer go into the compilation process as well. In my Computer the first two devices are present. Thats not an problem for me, however there are still 2 binaries left for the RV770 and this is what confuses me. When i use readelf to get their Machinecode they differ:

      $ readelf -aw kernel.bin.1 | grep Machine
        Machine:                           <unknown>: 0x3ee
      $ readelf -aw kernel.bin.2 | grep Machine
        Machine:                           <unknown>: 0x3ed
      $ readelf -aw kernel.bin.3 | grep Machine
        Machine:                           <unknown>: 0x3ee

      My programs will distribute all these binary kernels. But what about the two diffrent RV770 kernels? Do i need some special handling on RV770?

       

       

        • Binary Kernels
          MicahVillmow
          quadboon,
          One token is for the actual RV770 device, the other is for the RV7XX, which is used by I believe the x2 devices.
            • Binary Kernels
              quadboon

              Micah, thanks for your answer. So this creates a bit of a problem.

              The problem is, in the generator program, that the clGetDeviceInfo (..., CL_DEVICE_NAME, ...) function returns the same value on both RV770 and RV7XX while clBuildProgram () returns two diffrent binaries.

              The only workaround i see, in the application program, is to use the binary code of the RV770 first in clCreateProgramWithBinary () and check for errors. If there are no errors continue but if there are error try again using the binary code of the RV7XX.

              Is there any other (recommended) way? Is it better to try RV770 or RV7XX first?

            • Binary Kernels
              MicahVillmow
              quadboon,
              The binaries might be slightly different, but the actual ISA should be equivalent. This is something we are working on fixing in the upcoming release.
                • Binary Kernels
                  timchist

                   

                  Originally posted by: MicahVillmow quadboon, The binaries might be slightly different, but the actual ISA should be equivalent. This is something we are working on fixing in the upcoming release.


                  I have Mobility Radeon 4850. Only 0x3ee kernels are accepted by clBuildPrograms, 0x3ed and 0x3ef produce 'Internal error. Link failed'.

                  So now the question is, if I have 3 kernels, 0x3ed, 0x3ee, 0x3ef, device names for all of them is 'ATI RV770', how can I choose the right one in the executable? Try all of them? Is it possible to get the 'machine code' of the currently installed GPU?