ctags+taglist for .cu (CUDA) files
Asked Answered
T

4

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 *

Taddeo answered 23/4, 2012 at 9:25 Comment(0)
G
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.

Ga answered 23/4, 2012 at 9:45 Comment(6)
Thanks, I accidentally came across a similar (not entirely correct as I used C instead of C++) fix after posting the solution.Taddeo
CUDA C/C++ is based on C++, just like in standard C++ you can restrict yourself to using the C subset if you like!Ga
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.Taddeo
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.Ga
Yes, C-] works. But there is nothing shown in the taglist split window. Did you figure out how to use taglist with cuda codes?Tarsus
I think you'd better include .cuh files too... : ctags --langmap=c++:+.cu.cuhNuclease
V
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

Verticillate answered 14/9, 2012 at 8:53 Comment(1)
@Tarsus au BufNewFile,BufRead *.cuh set ft=cuda in your vimrcVolley
S
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

Superstition answered 16/4, 2013 at 6:6 Comment(0)
F
1

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

$ ./ctags --list-maps=CUDA
CUDA     *.cu *.cuh
Floppy answered 12/1, 2017 at 3:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.