Skip to content

Commit 24a9bf9

Browse files
luisbaldisseralpil
authored andcommitted
Added cuda snippets
1 parent b1c7ea8 commit 24a9bf9

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

snippets/cuda.snippets

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,59 @@
11
extends cpp
2+
3+
snippet kern "Kernel definition"
4+
__global__ void ${1:kernel}(${2:void}) {
5+
${0:// TODO: Implement}
6+
}
7+
8+
snippet dev "Device function definition"
9+
__device__ ${1:int} ${2:foo}(${3:void}) {
10+
${0:// TODO: Implement}
11+
return 0;
12+
}
13+
14+
snippet call "Kernel call"
15+
${1:kernel}<<<${2:args}>>>(${3});${0}
16+
17+
snippet sync "Synchonize threads"
18+
__syncthreads();
19+
20+
snippet tid "Thread Index"
21+
threadIdx.${0}
22+
23+
snippet bid "Block Index"
24+
blockIdx.${0}
25+
26+
snippet bdim "Block Dimension"
27+
blockDim.${0}
28+
29+
snippet ii "Get current index (1D)"
30+
int ${1:index} = threadIdx.${2:x} + blockIdx.$2 * blockDim.$2;
31+
32+
snippet ix "Get current X index (1D)"
33+
int ${1:x} = threadIdx.x + blockIdx.x * blockDim.x;
34+
35+
snippet iy "Get current Y index (1D)"
36+
int ${1:y} = threadIdx.y + blockIdx.y * blockDim.y;
37+
38+
snippet iz "Get current Z index (1D)"
39+
int ${1:z} = threadIdx.z + blockIdx.z * blockDim.z;
40+
41+
snippet ixy "Get current X,Y index (2D)"
42+
int ${1:x} = threadIdx.x + blockIdx.x * blockDim.x;
43+
int ${2:y} = threadIdx.y + blockIdx.y * blockDim.y;
44+
45+
snippet ixz "Get current X,Z index (2D)"
46+
int ${1:x} = threadIdx.x + blockIdx.x * blockDim.x;
47+
int ${3:z} = threadIdx.z + blockIdx.z * blockDim.z;
48+
49+
snippet iyz "Get current Y,Z index (2D)"
50+
int ${2:y} = threadIdx.y + blockIdx.y * blockDim.y;
51+
int ${3:z} = threadIdx.z + blockIdx.z * blockDim.z;
52+
53+
snippet ixyz "Get current X,Y,Z index (3D)"
54+
int ${1:x} = threadIdx.x + blockIdx.x * blockDim.x;
55+
int ${2:y} = threadIdx.y + blockIdx.y * blockDim.y;
56+
int ${3:z} = threadIdx.z + blockIdx.z * blockDim.z;
57+
58+
snippet share "Shared memory declaration"
59+
__shared__ ${1:int} ${2:memo}[${3:SIZE}];${0}

0 commit comments

Comments
 (0)