13

I use the vim editor (on Ubuntu). Recently, I have been working with large cuda projects and hence would like to utilize the ctags utility for code browsing. The list of supported languages for exuberant-ctags [here] (http://ctags.sourceforge.net/languages.html) doesnt contain CUDA as of yet. If anyone knows a tweak to do the same, I'd really appreciate the help.

Thanks

EDIT 1: I found the following temporary fix.

To create the tag file for CUDA files, use ctags with the following option (assuming your current directory contains all your cuda files);

$ctags --langmap=c++:+.cu *

0

4 Answers 4

10

Since CUDA C/C++ is based on C++ you can just use C++ mode. You can add the language map using --langmap=c++:+.cu.

6
  • Thanks, I accidentally came across a similar (not entirely correct as I used C instead of C++) fix after posting the solution.
    – Abhinav
    Commented Apr 23, 2012 at 9:48
  • CUDA C/C++ is based on C++, just like in standard C++ you can restrict yourself to using the C subset if you like!
    – Tom
    Commented Apr 23, 2012 at 9:53
  • IT WORKS BEAUTIFULLY !!!! I was worried if this will be able to identify the kernel functions (the ones with <<<>>>) ... to my surprise, it works and works perfect. Thanks Tom.
    – Abhinav
    Commented Apr 23, 2012 at 10:02
  • As far as ctags is concerned the <<<>>> can be ignored, you still just want to jump to the function when you hit C-]. That's why you don't actually need a new language, it's just C++ as far as ctags is concerned.
    – Tom
    Commented Apr 23, 2012 at 10:06
  • 1
    I think you'd better include .cuh files too... : ctags --langmap=c++:+.cu.cuh
    – einpoklum
    Commented Feb 1, 2016 at 15:22
5

I don't know about taglist, but if you are using the Tagbar plugin (a redo of taglist), you can add the following line to .vim/autoload/tagbar.vim:

let s:known_types.cuda = type_cpp

Put it right after the line:

let s:known_types.cpp = type_cpp

1
  • @dalibocai au BufNewFile,BufRead *.cuh set ft=cuda in your vimrc
    – Azrael3000
    Commented Feb 7, 2015 at 18:58
2

For taglist split window, you can add following lines

" cu language
let s:tlist_def_cu_settings = 'c++;n:namespace;v:variable;d:macro;t:typedef;' .
                         \ 'c:class;g:enum;s:struct;u:union;f:function'

below

" c++ language
let s:tlist_def_cpp_settings = 'c++;n:namespace;v:variable;d:macro;t:typedef;' .
                             \ 'c:class;g:enum;s:struct;u:union;f:function'

in taglist.vim

1

universal-ctags(https://ctags.io) has built-in parser for cuda.

$ ./ctags --list-maps=CUDA
CUDA     *.cu *.cuh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.