Results 1 to 4 of 4

Thread: clCreateProgramWithSource - could be a file?

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    11

    clCreateProgramWithSource - could be a file?

    Hi there,

    I was studying opencl until I see the clCreateProgramWithSource(). This function uses, as a parameter, a string which is the kernel source code to be built. But, is there any specific reason why not get a file path and read it? Any security reason?

    Every time that I want to use a kernel program I need to read the kernel file, then pass its content to a buffer. So, it could be better if opencl has support to read files.

  2. #2
    Senior Member
    Join Date
    Oct 2012
    Posts
    166

    Re: clCreateProgramWithSource - could be a file?

    It shouldnt be that hard for you to load a file from disk on your pc. But every opencl vendor (from a like amd to z like zfx) has to write a fileload into ther opencl implementation.

  3. #3
    Junior Member
    Join Date
    Apr 2013
    Posts
    11

    Re: clCreateProgramWithSource - could be a file?

    If the opencl specification said that the parameter of clCreateProgramWithSource should be a file instead of string, all vendors should implement it. I think that use a file as a parameter will be better and simple than put a string...I know that it is simple to load a file and pass its string, but pass the file is
    more intuitive than the first option.

  4. #4

    Re: clCreateProgramWithSource - could be a file?

    This is because not everyone loads kernel sources from files.

    If clCreateProgramWithSource() only took a file name it would prevent applications from programmatically creating and using kernel source strings at run-time. The only option in that case would be to create the string, write it to a temporary file, then reload the file again (quite inefficent).

    In most programming languages it only takes a couple lines of code to open a file and read its contents into a string.

Similar Threads

  1. clCreateProgramWithSource deletes context?
    By Rizokuri in forum OpenCL
    Replies: 2
    Last Post: 12-05-2012, 11:33 PM
  2. add header file using clCreateProgramWithSource
    By opencl_JEDI in forum OpenCL
    Replies: 1
    Last Post: 03-10-2010, 10:34 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
  •