emacs configuration for cuda

Hello,

Does anyone have their emacs configured for cuda with syntax highlighting and the other bells and whistles? Would they mind sharing their configuration with the community?

I found one here (http://www.emacswiki.org/emacs/CudaMode) but simply copying and pasting it in my emacs file did not work. It complained about the use of defconst. I am using emacs 23.

Cheers,
Luca

Although not all that elegant, I get around this issue by creating various .c modules
which I edit with emacs and which get the normal C support. Then I have a single, short
.cu file that just includes the .c files. My Makefile points to the .cu file.
Its just a kludge so I didnt have to figure out how to deal with emacs, which has so many
features that its documentation is unusable (another problem for a different forum, I would
think).

MW

Much simpler to just put following in your .emacs file:

(add-to-list 'auto-mode-alist '("\.cu$" . c++-mode))

Or alternatively, on a per .cu file basis, you could say just put following in the first line of your .cu files:

// -*- c++ -*-

This is not a bad work-around. cuda-mode does not work v23. but I think cc-mode is already changed quite big making many incompatible.

I often apply c-mode or c+±mode to the .cu buffer

M-x c++-mode

I have added

(add-to-list 'auto-mode-alist '("\.cu$" . c+±mode))

to my ~/.emacs and that seems to work fine.

                            Bill

    Dr. W. B. Langdon,
    Department of Computer Science, 
    King's College London,
    Strand, London, WC2R 2LS, UK
    [url="http://www.dcs.kcl.ac.uk/staff/W.Langdon/"]http://www.dcs.kcl.ac.uk/staff/W.Langdon/[/url]

FOGA 2011 http://www.sigevo.org/foga-2011/
CIGPU 2010 http://www.cs.ucl.ac.uk/external/W.Langdon/cigpu
A Field Guide to Genetic Programming
http://www.gp-field-guide.org.uk/
RNAnet http://bioinformatics.essex.ac.uk/users/wlangdon/rnanet
GP EM http://www.springer.com/10710
GP Bibliography http://www.cs.bham.ac.uk/~wbl/biblio/

xargon,

If you want to use that mode, you have to copy-paste it in another file, such as cuda-mode.el (somewhere in your load-path). You can then add the following to your .emacs:

(autoload 'cuda-mode "cuda-mode.el" "Cuda mode." t)

(setq auto-mode-alist (append '(("/*.\.cu$" . cuda-mode)) auto-mode-alist))

Little tip: in cuda-mode.el, change the line

(c-add-language 'cuda-mode 'c-mode))

to

(c-add-language 'cuda-mode 'c++-mode))

to have C++ syntax highlighting (useful for namespaces, templates, …).

Can you confirm the suggestion works in emacs 23?

I’ve downloaded the cuda-mode.el from http://www.emacswiki.org/emacs/CudaMode then added to where .emacs file is.

But I can’t highlight the .cu$ file.

Can you confirm the suggestion works in emacs 23?

I’ve downloaded the cuda-mode.el from http://www.emacswiki.org/emacs/CudaMode then added to where .emacs file is.

But I can’t highlight the .cu$ file.

I have an updated cuda-mode.el in my Git repository. You can see it here or download it here. It uses C++ instead of C, and works fine on my Emacs 23.2.

Be careful to add the cuda-mode.el file in a directory that is in your load-path, or Emacs won’t be able to find it! (you can check it with C-h v load-path RET). I store all my emacs config files in ~/.config/emacs, and have the following line in my ~/.emacs:

(add-to-list 'load-path "~/.config/emacs")

(autoload 'cuda-mode "cuda-mode.el" "Cuda mode." t)

(setq auto-mode-alist (append '(("\.cu$" . cuda-mode)) auto-mode-alist))

I have an updated cuda-mode.el in my Git repository. You can see it here or download it here. It uses C++ instead of C, and works fine on my Emacs 23.2.

Be careful to add the cuda-mode.el file in a directory that is in your load-path, or Emacs won’t be able to find it! (you can check it with C-h v load-path RET). I store all my emacs config files in ~/.config/emacs, and have the following line in my ~/.emacs:

(add-to-list 'load-path "~/.config/emacs")

(autoload 'cuda-mode "cuda-mode.el" "Cuda mode." t)

(setq auto-mode-alist (append '(("\.cu$" . cuda-mode)) auto-mode-alist))

Thanks for the reply and I’m using emacs 23.2 and ubuntu 10.04.

I’ve copied your file under /.emacs.d/ so I changed the first line to (add-to-list 'load-path “~/.emacs.d”).

But I had no luck yet. I got following error;

[i]Loading cc-langs…done

Eval error in the c-lang-defconst' for c-primitive-type-kwds’ in cuda-mode:

Eval error in the c-lang-defconst' for c-keywords’ in cuda-mode:

Eval error in the c-lang-defconst' for c-regular-keywords-regexp’ in cuda-mode:

Eval error in the c-lang-defconst' for c-basic-matchers-before’ in cuda-mode:

Eval error in the c-lang-defconst' for c-matchers-2’ in cuda-mode:

File mode specification error: (error “`c-primitive-type-kwds’ got no (prior) value in cuda-mode (might be a cyclic reference)”)

byte-code: Beginning of buffer[/i]

Am I missing cc-mode package? I can see c/C++ hightlight on cxx or hxx files.

Thanks for the reply and I’m using emacs 23.2 and ubuntu 10.04.

I’ve copied your file under /.emacs.d/ so I changed the first line to (add-to-list 'load-path “~/.emacs.d”).

But I had no luck yet. I got following error;

[i]Loading cc-langs…done

Eval error in the c-lang-defconst' for c-primitive-type-kwds’ in cuda-mode:

Eval error in the c-lang-defconst' for c-keywords’ in cuda-mode:

Eval error in the c-lang-defconst' for c-regular-keywords-regexp’ in cuda-mode:

Eval error in the c-lang-defconst' for c-basic-matchers-before’ in cuda-mode:

Eval error in the c-lang-defconst' for c-matchers-2’ in cuda-mode:

File mode specification error: (error “`c-primitive-type-kwds’ got no (prior) value in cuda-mode (might be a cyclic reference)”)

byte-code: Beginning of buffer[/i]

Am I missing cc-mode package? I can see c/C++ hightlight on cxx or hxx files.

I was able to make this work with xemacs by putting the configuration code into my .xemacs/init.el file, changing the load path to point to ~/.xemacs, and putting the cuda-mode.el file in ~/.xemacs

I tried the elisp code linked above (http://www.emacswiki.org/emacs/CudaMode) on GNU Emacs in Ubuntu 10.10, then in openSUSE 12.12 and finally in Windows XP, and it works fine everywhere. I copied the code as it is in the .emacs init file. For Windows, I happened to have an msys installation, and the HOME environment variable was set because of that installation, so I copied .emacs there. For Linux, it has to be just the home directory of the current user.