Results 1 to 8 of 8

Thread: OCL programm without *.cl file

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Location
    Kingisepp, Russia
    Posts
    11

    OCL programm without *.cl file

    Hello there!

    Now i use code like that:
    Code :
     fp=fopen("mandel.cl", "r"); /*open file with OCL programm*/
     source_str = (char*)malloc(MAX_SOURCE_SIZE);
     source_size = fread(source_str, 1, MAX_SOURCE_SIZE, fp);
     fclose(fp);
    <some code>
     program = clCreateProgramWithSource(context, 1, (const char **)&source_str, (const size_t *)&source_size, &ret);
     clBuildProgram(program, 1, &device_id, NULL, NULL, NULL);
     kernel = clCreateKernel(program, "mandel", &ret); /*"mandel" -- __kernel function in "mandel.cl"*/
    I know that CUDA didn't need for an external file. OpenCL can do without an external source file?

  2. #2
    Member
    Join Date
    Jul 2011
    Location
    Moscow, Russia
    Posts
    41

    Re: OCL programm without *.cl file

    Of course, it can. It is obvious even from the code you supplied. Just initialize source_str the way you wish.
    Blog (in russian)

  3. #3
    Junior Member
    Join Date
    Sep 2011
    Location
    Kingisepp, Russia
    Posts
    11

    Re: OCL programm without *.cl file

    Quote Originally Posted by Maxim Milakov
    Of course, it can. It is obvious even from the code you supplied. Just initialize source_str the way you wish.
    Sorry, i little not understand you.

  4. #4
    Member
    Join Date
    Jul 2011
    Location
    Moscow, Russia
    Posts
    41

    Re: OCL programm without *.cl file

    source_str = "__kernel your_kernel_name(parameters) { code }";
    Blog (in russian)

  5. #5
    Junior Member
    Join Date
    Sep 2011
    Location
    Kingisepp, Russia
    Posts
    11

    Re: OCL programm without *.cl file

    Quote Originally Posted by Maxim Milakov
    source_str = "__kernel your_kernel_name(parameters) { code }";
    No, i mean, without source_str, without extend file. I mean something like that:
    Code :
    __kernel void mandel(<some arguments>)
    {
     <some code>
    }
     
    int main(void)
    {
     <some code>
     cl_kernel kernel = clCreateKernel(program, "mandel", &ret);
    }

  6. #6
    Member
    Join Date
    Jul 2011
    Location
    Moscow, Russia
    Posts
    41

    Re: OCL programm without *.cl file

    You don't need external file. Check clBuildProgram: It takes string as parameter.
    Blog (in russian)

  7. #7
    Junior Member
    Join Date
    Sep 2011
    Location
    Kingisepp, Russia
    Posts
    11

    Re: OCL programm without *.cl file

    Quote Originally Posted by Maxim Milakov
    You don't need external file. Check clBuildProgram: It takes string as parameter.
    ???, ? ????? ?????, ??? ???? ???????? ??????? ? ??????????????? ????????? ?? ??????. ? ????? ?? ???????? ??????? ? ???????? ???? ? ???????? ??????? ????? ???? ???????, ??????? OpenCL ????? ???????????? ??? ??????? ??????? ?? ????? ?????? ? "????????????" ??.

  8. #8
    Member
    Join Date
    Jul 2011
    Location
    Moscow, Russia
    Posts
    41

    Re: OCL programm without *.cl file

    Quote Originally Posted by BratSinot
    Quote Originally Posted by Maxim Milakov
    You don't need external file. Check clBuildProgram: It takes string as parameter.
    ???, ? ????? ?????, ??? ???? ???????? ??????? ? ??????????????? ????????? ?? ??????. ? ????? ?? ???????? ??????? ? ???????? ???? ? ???????? ??????? ????? ???? ???????, ??????? OpenCL ????? ???????????? ??? ??????? ??????? ?? ????? ?????? ? "????????????" ??.
    ???, ??? ?? ????????? (?? ??????? ???? ??? ??????-?????? ?????????? ?????????????, ? ????????????? ???????? ? ?????? ?? ????).
    Blog (in russian)

Similar Threads

  1. Question about protecting ocl code
    By BiS in forum OpenCL
    Replies: 2
    Last Post: 05-04-2012, 12:39 AM
  2. How to Include Common File into OCL file!
    By alexzhao in forum OpenCL
    Replies: 1
    Last Post: 11-09-2009, 12:23 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
  •