Customize syntax highlighting for CUDA in Kate/KDevelop

June 6, 2008

CUDA is a minimal extension of C/C++ to support programming on newer NVIDIA GPUs. It introduces dozens of new keywords that are frequently used in CUDA programs. Adding syntax highlighting in KDevelop (Kate) only requires several simple steps:

1. Get keywords from “usertype.dat” provided by any Windows version of CUDA SDK, this is a text file. It should be found under $(NVIDIA_CUDA_SDK)\doc\syntax_highlighting.

2. Under your Linux account, cd ~/.kde/share/apps/katepart/syntax/, there should be two xml files regarding C/C++, cpp.xml and c.xml. Make a copy of both and name them properly, e.g. cpp_cuda.xml & c_cuda.xml.

3. Perform a replace operation on each keyword in “usertype.dat” so they match the keyword format in target xml files, and then copy them into the keyword lists of target files.

4. Modify xml header, which includes language description, file extensions and other information. You probably want to add “*.cu” to the file extension list. Remember to distinguish them from the original C/C++ language tag. Save the xml files after you are done.

5. Open Kate/KDevelop, under Tools->Highlighting->Sources you should see two new entries below C++ and C, respectively.

Enjoy.

Entry Filed under: All, Tools. .

3 Comments Add your own

  • 1. robin  |  January 26, 2009 at 11:20 am

    hi, thanks for your blog. that’s really nice article for me. now i am doing my master project with GNU and CUDA.
    but i can not get cpp.xml and c.xml under ~/.kde/share/apps/katepart/syntax/. i dont even have /syntax under ~/.kde/share/apps/katepart/, so i just wanna know what should i do now?
    please give me some advice. thanks a lot!

    Reply
  • 2. thinkingfish  |  January 27, 2009 at 4:51 pm

    Hi, I do not have a Kate installed at hand and therefore am not sure about a solution. I believe syntax highlighting is included by default in Kate, so it must be somewhere. You can do a search in your file system to determine the location of the syntax file folder.

    Reply
  • 3. chris  |  March 11, 2009 at 6:21 pm

    have a look to:
    /usr/share/apps/katepart/syntax
    or:
    /opt/kde3/share/apps/katepart/syntax/
    Actually it depends on your distribution and KDE installation

    Reply

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

June 2008
M T W T F S S
« May   Apr »
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Most Recent Posts