Results 1 to 3 of 3

Thread: clCreateProgramWithBinary on Mac OSX

  1. #1
    Junior Member
    Join Date
    Mar 2012

    clCreateProgramWithBinary on Mac OSX

    Hi, I think I have discovered something really weired:

    I'm running OpenCL 1.1 on OSX 10.7 Lion, and trying to use a pre-compiled kernel using the "clCreateProgramWithBinary" function.
    According to the reference, ( ... inary.html)
    the 5th argument "binaries" should be an array of pointers to the contents of the binary, but it seems that the Apple's implementation is different:
    "binaries" is an array of the file paths of the pre-compiled binaries.

    Actually, Apple's sample code "Offline Compilation Using the OpenCL Compiler" is calling clCreateProgramWithBinary with file paths. Like this:

    Code :
    size_t len = strlen(file_path);
    program = clCreateProgramWithBinary(context, 1, &device, &len, (const unsigned char**)&file_path, NULL, &err);

    Any ideas what is going on?


  2. #2
    Senior Member
    Join Date
    May 2010
    Toronto, Canada

    Re: clCreateProgramWithBinary on Mac OSX

    The contents of a precompiled binary are implementation-dependent. Maybe Apple chose them to be paths to temporary files.

    All that OpenCL requires is that whatever you obtain when you call clGetProgramInfo(..., CL_PROGRAM_BINARIES, ...) can later be reloaded using clCreateProgramWithBinary(). Also, note that clCreateProgramWithBinary() may fail for any reason so your application must always have be ready to fall-back and recompile the program from source.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  3. #3
    Junior Member
    Join Date
    Jan 2011

    Re: clCreateProgramWithBinary on Mac OSX

    This is an extension which allows a developer to compile their CL source code into a bitcode file (using the openclc compiler, or automatically in Xcode), and then ship that with their app instead of the original source.

    The standard usage of clCreateProgramWithBinary, where a device specific binary is passed instead of the path to a bitcode file, works too.

Similar Threads

  1. clCreateProgramWithBinary
    By luizdrumond in forum OpenCL
    Replies: 0
    Last Post: 10-02-2012, 10:47 AM
  2. Replies: 1
    Last Post: 04-21-2012, 04:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean