Author Topic: Support for OpenCL *.cl files  (Read 6798 times)

Offline cdavalillo

  • Multiple posting newcomer
  • *
  • Posts: 23
Support for OpenCL *.cl files
« on: January 08, 2024, 03:10:10 am »
I'm a happy user of Code::Blocks and I wonder if there is any support for OpenCL *.cl files as there is for glsl files? If there is such support please tell me where can use it. If not please tell me how to send that suggestion to the Code::Blocks development team.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1563
Re: Support for OpenCL *.cl files
« Reply #1 on: January 09, 2024, 01:24:30 pm »
How do we support glsl?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Support for OpenCL *.cl files
« Reply #2 on: January 10, 2024, 12:17:20 am »
How do we support glsl?

glsl is normally a text file. We don't need to "support" or "compile" it under C::B's build system.

For me, I just drag the glsl file into the cbp, and consider this file as an external resource files, the file is loaded by my other shader classes.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Support for OpenCL *.cl files
« Reply #3 on: January 10, 2024, 12:22:41 am »
compilation - how to compile opencl project with kernels - Stack Overflow

I just looked at the above link, and found that .cl file is similar like glsl file, and C::B does not need to compile it.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline cdavalillo

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Support for OpenCL *.cl files
« Reply #4 on: January 10, 2024, 03:13:07 pm »
No, I don't mean a compilation, off course you can compile applications for OpenCL using a compiler as NVCC. I mean with the syntax highlighting, I use Code::Blocks to edit GLSL files and when open it, it shows a c/c++ style syntax highlight with no error or whatsoever. But when I try to do the same with .cl files from where the kernels for OpenCL compiles it simply shows a black text full of errors  :(
« Last Edit: January 10, 2024, 03:37:54 pm by cdavalillo »

Offline cdavalillo

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Support for OpenCL *.cl files
« Reply #5 on: January 10, 2024, 03:47:16 pm »
How do we support glsl?

I thought that you would know. But just see the pictures that I posted, I'm not lying to you. Now we are on the matter I suggest to add support to CUDA files too which has the file extension .cu and has a similar syntax to c.
« Last Edit: January 10, 2024, 03:49:44 pm by cdavalillo »

Offline cdavalillo

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Support for OpenCL *.cl files
« Reply #6 on: January 10, 2024, 03:56:53 pm »
compilation - how to compile opencl project with kernels - Stack Overflow

I just looked at the above link, and found that .cl file is similar like glsl file, and C::B does not need to compile it.

I think you can compile this type of file through a OpenCL API compliant compiler as for example NVCC. I only have written .cu files for CUDA programs and they compile just fine using NVCC in Code::Blocks IDE, but I don't know if is the same as with .cl files.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1563
Re: Support for OpenCL *.cl files
« Reply #7 on: January 10, 2024, 05:13:22 pm »
I asked because I really did not know. Before asking I looked at the lexers from wxScintilla and did not find glsl, later I found lexer_glsl.xml at sdk\resources\lexers. There is one for CUDA and none for OpenCL.

If you know OpenCL you could write a lexer for it based on lexer_cpp.xml and the corresponding .sample, there are instructions in README.txt.

Offline cdavalillo

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: Support for OpenCL *.cl files
« Reply #8 on: January 11, 2024, 02:47:04 am »
I read those files of lexers that you did mention but I honestly don't know how to write one. I know XML but I don't know the specific structure that Code::Blocks needs. Where I can read more about how to create these lexer files?

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1563
Re: Support for OpenCL *.cl files
« Reply #9 on: January 11, 2024, 08:39:37 am »
- Copy lexer_cpp.xml to lexer_cl.xml, remove unsupported keywords and add CL-specific ones to indexes 0 and 1.
- Edit filemasks in line 6.
- The "wxSmith block identifiers" part (index 6) can be removed completely.
- The SampleCode value must be changed to lexer_cl.sample, the line numbers can be changed if needed.
- Language attributes should be the same AFAIK.
- Copy lexer_cpp.sample to lexer_cl.sample and edit it so it is CL-compliant and representative.

Once finished, attach both files here (or in the ticket page) so we can add them to trunk.

Offline omlk

  • Multiple posting newcomer
  • *
  • Posts: 110
Re: Support for OpenCL *.cl files
« Reply #10 on: January 11, 2024, 04:47:32 pm »
There are two steps you can take to remove error highlighting (using a spelling dictionary) and to enable programming language syntax highlighting. If I understood your problem correctly, then take a look at the screenshots attached to the post.

 
 * cuda_highlighting1.png (231.23 kB, 1280x1024 - viewed 777 times.)
 
 * cuda_highlighting2.png (234.25 kB, 1280x1024 - viewed 777 times.)
 
« Last Edit: January 11, 2024, 04:55:57 pm by omlk »