Results 1 to 8 of 8

Thread: Compile for other GPU

  1. #1
    Newbie
    Join Date
    Jun 2013
    Posts
    4

    Compile for other GPU

    I got a question: is it possible to compile the source code for a different gpu? Did some tests a time ago with NVIDIA cards and different drivers, but didn't work well in both sides (old to new and new to old drivers). I can understand, that if I got an AMD card to compile the OpenCL code and the App should run on a NVIDIA that this is not working, but if both are from one manufacture (ATI or NVIDIA) this should work, shouldn't it? The target pc should not need the SDK and the source file. How does this work?

    thx for help

  2. #2
    Senior Member
    Join Date
    Dec 2011
    Posts
    124
    Yes. Everytime your application runs it submits the OpenCL kernel for compilation on the selected platform and device. So if you move from a machine with an AMD GPU to a machine with an NVIDIA GPU, the change in compiler happens automatically.

  3. #3
    Newbie
    Join Date
    Jun 2013
    Posts
    4
    Yes, i know, if you are using the source file with clCreateProgramWithSource(). But I want to create the PTX Code and use it later with clCreateProgramWithBinary(). I think it is not possible to compile the PTX Code on NVIDIA and use it (with clCreateProgramWithBinary) on AMD.

    The problem is: I got e.g. a NVIDIA GTX580 and create the PTX code with clCreateProgramWithSource. This code should run on a e.g. NVIDIA GTX690 with clCreateProgramWithBinary. Does this work and how?

  4. #4
    Senior Member
    Join Date
    Dec 2011
    Posts
    124
    Quote Originally Posted by Johannes View Post
    The problem is: I got e.g. a NVIDIA GTX580 and create the PTX code with clCreateProgramWithSource. This code should run on a e.g. NVIDIA GTX690 with clCreateProgramWithBinary. Does this work and how?
    I see. Sorry I misread your question.

    It is up to NVIDIA. Their OpenCL Programming Guide (4.1 from 1/3/2012) says:

    "Currently, the PTX intermediate representation can be obtained by calling
    clGetProgramInfo() with CL_PROGRAM_BINARIES. It can be passed to
    clCreateProgramWithBinary() to create a program object only if it is
    produced and consumed by the same driver. This will likely not be supported in
    future versions."

    So, no.

  5. #5
    Newbie
    Join Date
    Jun 2013
    Posts
    4
    Thank you so much for your answer. I see, if the GTX690 uses the same driver as the GTX580 it can work but this is also not guaranteed.

    But how can I give OpenCL code to our customers? The must not see the source code! Precompiling the code for all driver versions sounds not so funny.

  6. #6
    Senior Member
    Join Date
    Dec 2011
    Posts
    124
    OpenCL 1.2 adds some ability to ship object code (instead of source) but is not supported by NVIDIA. You don't have to ship source as files on disk, it can be compressed or encrypted in your application. However, it needs to be source in memory when passed to clBuildProgramFromSource, and it is possible to intercept that call.

  7. #7
    Newbie
    Join Date
    Jun 2013
    Posts
    4
    Quote Originally Posted by Dithermaster View Post
    OpenCL 1.2 adds some ability to ship object code (instead of source) but is not supported by NVIDIA.
    Sounds good, but we want to support AMD and NVIDIA, therefore it is not a solution for our problem.

    Quote Originally Posted by Dithermaster View Post
    However, it needs to be source in memory when passed to clBuildProgramFromSource, and it is possible to intercept that call.
    I know that and this is, why we want to use binary. So we have to compile binarys for all GPUs which are used from customers.

    However. Thousand thanks for your help.

  8. #8
    Senior Member
    Join Date
    Oct 2012
    Posts
    166
    Hi Johannes,

    you might have a look at the clusterchimp.org oclelf/oclcc/.. guide. They have worked on such a problem as well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •