Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: cdavalillo on January 08, 2024, 03:10:10 am

Title: Support for OpenCL *.cl files
Post by: cdavalillo 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.
Title: Re: Support for OpenCL *.cl files
Post by: Miguel Gimenez on January 09, 2024, 01:24:30 pm
How do we support glsl?
Title: Re: Support for OpenCL *.cl files
Post by: ollydbg 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.
Title: Re: Support for OpenCL *.cl files
Post by: ollydbg on January 10, 2024, 12:22:41 am
compilation - how to compile opencl project with kernels - Stack Overflow (https://stackoverflow.com/questions/26517114/how-to-compile-opencl-project-with-kernels)

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.
Title: Re: Support for OpenCL *.cl files
Post by: cdavalillo 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  :(
Title: Re: Support for OpenCL *.cl files
Post by: cdavalillo 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.
Title: Re: Support for OpenCL *.cl files
Post by: cdavalillo on January 10, 2024, 03:56:53 pm
compilation - how to compile opencl project with kernels - Stack Overflow (https://stackoverflow.com/questions/26517114/how-to-compile-opencl-project-with-kernels)

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.
Title: Re: Support for OpenCL *.cl files
Post by: Miguel Gimenez 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.
Title: Re: Support for OpenCL *.cl files
Post by: cdavalillo 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?
Title: Re: Support for OpenCL *.cl files
Post by: Miguel Gimenez 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.
Title: Re: Support for OpenCL *.cl files
Post by: omlk 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.

 (https://forums.codeblocks.org/index.php?action=dlattach;topic=25661.0;attach=11864;image) (https://forums.codeblocks.org/index.php?action=dlattach;topic=25661.0;attach=11863;image)
 (https://forums.codeblocks.org/Themes/default/images/icons/clip.gif) cuda_highlighting1.png (https://forums.codeblocks.org/index.php?action=dlattach;topic=25661.0;attach=11863) (231.23 kB, 1280x1024 - viewed 777 times.)
 (https://forums.codeblocks.org/index.php?action=dlattach;topic=25661.0;attach=11866;image) (https://forums.codeblocks.org/index.php?action=dlattach;topic=25661.0;attach=11865;image)
 (https://forums.codeblocks.org/Themes/default/images/icons/clip.gif) cuda_highlighting2.png (https://forums.codeblocks.org/index.php?action=dlattach;topic=25661.0;attach=11865) (234.25 kB, 1280x1024 - viewed 777 times.)