Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncrustify command for CUDA kernel

I would like to apply uncrustify (via beautify in the Atom editor and a config file) to CUDA code. However, I don't know how to tell uncrustify to recognize CUDA kernel calls which have the following structure:

kernelName <<<N,M>>> (arg0,arg1,...);

However, uncrustify has problems with the <<< >>> and applying it gives the following unpleasant result

kernelName << < N, M >> >
    (arg0,arg1,...);

I would like to have it look more like a function call and also avoid the formatting of <<< to << <. Ideally, the result would look like

kernelName <<< N, M >>> (arg0,arg1,
      ...); // line break if argument list is too long

Which arguments can I add to my config.cfg to achieve the above result?

Thank you very much.

like image 372
Thomas Avatar asked Jul 10 '15 08:07

Thomas


1 Answers

Looking through whole documentation of uncrustify, I have found 2 arguments that could influence in your CUDA kernel style:

sp_compare                                { Ignore, Add, Remove, Force     }
 Add or remove space around compare operator '<', '>', '==', etc

And:

align_left_shift                          { False, True }
  Align lines that start with '<<' with previous '<<'. Default=true

You can try to play around with these parameters to be more closely to the solution although I would try something like:

sp_compare     =   Remove
align_left_shift   = False
like image 125
juanmajmjr Avatar answered Nov 15 '22 16:11

juanmajmjr