Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1801505
  • 博文数量: 290
  • 博客积分: 10653
  • 博客等级: 上将
  • 技术积分: 3178
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-24 23:08
文章存档

2013年(6)

2012年(15)

2011年(25)

2010年(86)

2009年(52)

2008年(66)

2007年(40)

分类: LINUX

2010-01-28 11:54:06

Using Vim for CUDA

Since I began using Vim, I have been using it for CUDA development in Ubuntu.

To get Vim to highlight your code like C++, execute the following:
cd /usr/share/vim/vim*/syntax; sudo cp cpp.vim cu.vim
echo "au BufNewFile,BufRead *.cu set ft=cu" >> ~/.vimrc

If you want proper cuda highlighting, check out.

You can compile and run without leaving Vim. I was amazed to discover this, it's so useful! Here is an example:
cd ~/NVIDIA_CUDA_SDK/projects/template/
vim template_kernel.cu
:!make && ~/NVIDIA_CUDA_SDK/bin/linux/release/template

" Vim syntax file
2" Language:     CUDA (NVIDIA Compute Unified Device Architecture)
3" Maintainer:   Timothy B. Terriberry
4" Last Change:  2007 Oct 13
5
6" For version 5.x: Clear all syntax items
7" For version 6.x: Quit when a syntax file was already loaded
8if version < 600
9  syntax clear
10elseif exists("b:current_syntax")
11  finish
12endif
13
14" Read the C syntax to start with
15if version < 600
16  source :p:h/c.vim
17else
18  runtime! syntax/c.vim
19endif
20
21" CUDA extentions
22syn keyword cudaStorageClass    __device__ __global__ __host__
23syn keyword cudaStorageClass    __constant__ __shared__
24syn keyword cudaStorageClass    __inline__ __align__ __thread__
25"syn keyword cudaStorageClass   __import__ __export__ __location__
26syn keyword cudaStructure       template
27syn keyword cudaType            char1 char2 char3 char4
28syn keyword cudaType            uchar1 uchar2 uchar3 uchar4
29syn keyword cudaType            short1 short2 short3 short4
30syn keyword cudaType            ushort1 ushort2 ushort3 ushort4
31syn keyword cudaType            int1 int2 int3 int4
32syn keyword cudaType            uint1 uint2 uint3 uint4
33syn keyword cudaType            long1 long2 long3 long4
34syn keyword cudaType            ulong1 ulong2 ulong3 ulong4
35syn keyword cudaType            float1 float2 float3 float4
36syn keyword cudaType            ufloat1 ufloat2 ufloat3 ufloat4
37syn keyword cudaType            dim3 texture textureReference
38syn keyword cudaType            cudaError_t cudaDeviceProp cudaMemcpyKind
39syn keyword cudaType            cudaArray cudaChannelFormatKind
40syn keyword cudaType            cudaChannelFormatDesc cudaTextureAddressMode
41syn keyword cudaType            cudaTextureFilterMode cudaTextureReadMode
42syn keyword cudaVariable        gridDim blockIdx blockDim threadIdx
43syn keyword cudaConstant        __DEVICE_EMULATION__
44syn keyword cudaConstant        cudaSuccess
45" Many more errors are defined, but only these are listed in the maunal
46syn keyword cudaConstant        cudaErrorMemoryAllocation
47syn keyword cudaConstant        cudaErrorInvalidDevicePointer
48syn keyword cudaConstant        cudaErrorInvalidSymbol
49syn keyword cudaConstant        cudaErrorMixedDeviceExecution
50syn keyword cudaConstant        cudaMemcpyHostToHost
51syn keyword cudaConstant        cudaMemcpyHostToDevice
52syn keyword cudaConstant        cudaMemcpyDeviceToHost
53syn keyword cudaConstant        cudaMemcpyDeviceToDevice
54syn keyword cudaConstant        cudaReadModeElementType
55syn keyword cudaConstant        cudaReadModeNormalizedFloat
56syn keyword cudaConstant        cudaFilterModePoint
57syn keyword cudaConstant        cudaFilterModeLinear
58syn keyword cudaConstant        cudaAddressModeClamp
59syn keyword cudaConstant        cudaAddressModeWrap
60syn keyword cudaConstant        cudaChannelFormatKindSigned
61syn keyword cudaConstant        cudaChannelFormatKindUnsigned
62syn keyword cudaConstant        cudaChannelFormatKindFloat
63
64hi def link cudaStorageClass    StorageClass
65hi def link cudaStructure       Structure
66hi def link cudaType            Type
67hi def link cudaVariable        Identifier
68hi def link cudaConstant        Constant
69
70let b:current_syntax = "cuda"
71
72" vim: ts=8

阅读(1424) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~