-
Notifications
You must be signed in to change notification settings - Fork 0
/
regionaddv_wrapper.go
352 lines (311 loc) · 8.44 KB
/
regionaddv_wrapper.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
package cuda
/*
THIS FILE IS AUTO-GENERATED BY CUDA2GO.
EDITING IS FUTILE.
*/
import (
"github.com/barnex/cuda5/cu"
"unsafe"
)
var regionaddv_code cu.Function
type regionaddv_args struct {
arg_dstx unsafe.Pointer
arg_dsty unsafe.Pointer
arg_dstz unsafe.Pointer
arg_LUTx unsafe.Pointer
arg_LUTy unsafe.Pointer
arg_LUTz unsafe.Pointer
arg_regions unsafe.Pointer
arg_N int
argptr [8]unsafe.Pointer
}
// Wrapper for regionaddv CUDA kernel, asynchronous.
func k_regionaddv_async(dstx unsafe.Pointer, dsty unsafe.Pointer, dstz unsafe.Pointer, LUTx unsafe.Pointer, LUTy unsafe.Pointer, LUTz unsafe.Pointer, regions unsafe.Pointer, N int, cfg *config, str cu.Stream) {
if regionaddv_code == 0 {
regionaddv_code = fatbinLoad(regionaddv_map, "regionaddv")
}
var _a_ regionaddv_args
_a_.arg_dstx = dstx
_a_.argptr[0] = unsafe.Pointer(&_a_.arg_dstx)
_a_.arg_dsty = dsty
_a_.argptr[1] = unsafe.Pointer(&_a_.arg_dsty)
_a_.arg_dstz = dstz
_a_.argptr[2] = unsafe.Pointer(&_a_.arg_dstz)
_a_.arg_LUTx = LUTx
_a_.argptr[3] = unsafe.Pointer(&_a_.arg_LUTx)
_a_.arg_LUTy = LUTy
_a_.argptr[4] = unsafe.Pointer(&_a_.arg_LUTy)
_a_.arg_LUTz = LUTz
_a_.argptr[5] = unsafe.Pointer(&_a_.arg_LUTz)
_a_.arg_regions = regions
_a_.argptr[6] = unsafe.Pointer(&_a_.arg_regions)
_a_.arg_N = N
_a_.argptr[7] = unsafe.Pointer(&_a_.arg_N)
args := _a_.argptr[:]
cu.LaunchKernel(regionaddv_code, cfg.Grid.X, cfg.Grid.Y, cfg.Grid.Z, cfg.Block.X, cfg.Block.Y, cfg.Block.Z, 0, str, args)
}
// Wrapper for regionaddv CUDA kernel, synchronized.
func k_regionaddv(dstx unsafe.Pointer, dsty unsafe.Pointer, dstz unsafe.Pointer, LUTx unsafe.Pointer, LUTy unsafe.Pointer, LUTz unsafe.Pointer, regions unsafe.Pointer, N int, cfg *config) {
str := stream()
k_regionaddv_async(dstx, dsty, dstz, LUTx, LUTy, LUTz, regions, N, cfg, str)
syncAndRecycle(str)
}
var regionaddv_map = map[int]string{0: "",
20: regionaddv_ptx_20,
30: regionaddv_ptx_30,
35: regionaddv_ptx_35}
const (
regionaddv_ptx_20 = `
.version 3.1
.target sm_20
.address_size 64
.visible .entry regionaddv(
.param .u64 regionaddv_param_0,
.param .u64 regionaddv_param_1,
.param .u64 regionaddv_param_2,
.param .u64 regionaddv_param_3,
.param .u64 regionaddv_param_4,
.param .u64 regionaddv_param_5,
.param .u64 regionaddv_param_6,
.param .u32 regionaddv_param_7
)
{
.reg .pred %p<2>;
.reg .s32 %r<19>;
.reg .f32 %f<10>;
.reg .s64 %rd<26>;
ld.param.u64 %rd8, [regionaddv_param_0];
ld.param.u64 %rd9, [regionaddv_param_1];
ld.param.u64 %rd10, [regionaddv_param_2];
ld.param.u64 %rd11, [regionaddv_param_3];
ld.param.u64 %rd12, [regionaddv_param_4];
ld.param.u64 %rd13, [regionaddv_param_5];
ld.param.u64 %rd14, [regionaddv_param_6];
ld.param.u32 %r2, [regionaddv_param_7];
cvta.to.global.u64 %rd1, %rd10;
cvta.to.global.u64 %rd2, %rd13;
cvta.to.global.u64 %rd3, %rd9;
cvta.to.global.u64 %rd4, %rd12;
cvta.to.global.u64 %rd5, %rd8;
cvta.to.global.u64 %rd6, %rd11;
cvta.to.global.u64 %rd7, %rd14;
.loc 2 9 1
mov.u32 %r3, %nctaid.x;
mov.u32 %r4, %ctaid.y;
mov.u32 %r5, %ctaid.x;
mad.lo.s32 %r6, %r3, %r4, %r5;
mov.u32 %r7, %ntid.x;
mov.u32 %r8, %tid.x;
mad.lo.s32 %r1, %r6, %r7, %r8;
.loc 2 10 1
setp.ge.s32 %p1, %r1, %r2;
@%p1 bra BB0_2;
.loc 2 12 1
cvt.s64.s32 %rd15, %r1;
add.s64 %rd16, %rd7, %rd15;
.loc 2 13 1
ld.global.s8 %rd17, [%rd16];
shl.b64 %rd18, %rd17, 2;
add.s64 %rd19, %rd6, %rd18;
mul.wide.s32 %rd20, %r1, 4;
add.s64 %rd21, %rd5, %rd20;
ld.global.f32 %f1, [%rd21];
ld.global.f32 %f2, [%rd19];
add.f32 %f3, %f1, %f2;
st.global.f32 [%rd21], %f3;
.loc 2 14 1
add.s64 %rd22, %rd4, %rd18;
add.s64 %rd23, %rd3, %rd20;
ld.global.f32 %f4, [%rd23];
ld.global.f32 %f5, [%rd22];
add.f32 %f6, %f4, %f5;
st.global.f32 [%rd23], %f6;
.loc 2 15 1
add.s64 %rd24, %rd2, %rd18;
add.s64 %rd25, %rd1, %rd20;
ld.global.f32 %f7, [%rd25];
ld.global.f32 %f8, [%rd24];
add.f32 %f9, %f7, %f8;
st.global.f32 [%rd25], %f9;
BB0_2:
.loc 2 17 2
ret;
}
`
regionaddv_ptx_30 = `
.version 3.1
.target sm_30
.address_size 64
.visible .entry regionaddv(
.param .u64 regionaddv_param_0,
.param .u64 regionaddv_param_1,
.param .u64 regionaddv_param_2,
.param .u64 regionaddv_param_3,
.param .u64 regionaddv_param_4,
.param .u64 regionaddv_param_5,
.param .u64 regionaddv_param_6,
.param .u32 regionaddv_param_7
)
{
.reg .pred %p<2>;
.reg .s32 %r<19>;
.reg .f32 %f<10>;
.reg .s64 %rd<26>;
ld.param.u64 %rd8, [regionaddv_param_0];
ld.param.u64 %rd9, [regionaddv_param_1];
ld.param.u64 %rd10, [regionaddv_param_2];
ld.param.u64 %rd11, [regionaddv_param_3];
ld.param.u64 %rd12, [regionaddv_param_4];
ld.param.u64 %rd13, [regionaddv_param_5];
ld.param.u64 %rd14, [regionaddv_param_6];
ld.param.u32 %r2, [regionaddv_param_7];
cvta.to.global.u64 %rd1, %rd10;
cvta.to.global.u64 %rd2, %rd13;
cvta.to.global.u64 %rd3, %rd9;
cvta.to.global.u64 %rd4, %rd12;
cvta.to.global.u64 %rd5, %rd8;
cvta.to.global.u64 %rd6, %rd11;
cvta.to.global.u64 %rd7, %rd14;
.loc 2 9 1
mov.u32 %r3, %nctaid.x;
mov.u32 %r4, %ctaid.y;
mov.u32 %r5, %ctaid.x;
mad.lo.s32 %r6, %r3, %r4, %r5;
mov.u32 %r7, %ntid.x;
mov.u32 %r8, %tid.x;
mad.lo.s32 %r1, %r6, %r7, %r8;
.loc 2 10 1
setp.ge.s32 %p1, %r1, %r2;
@%p1 bra BB0_2;
.loc 2 12 1
cvt.s64.s32 %rd15, %r1;
add.s64 %rd16, %rd7, %rd15;
.loc 2 13 1
ld.global.s8 %rd17, [%rd16];
shl.b64 %rd18, %rd17, 2;
add.s64 %rd19, %rd6, %rd18;
mul.wide.s32 %rd20, %r1, 4;
add.s64 %rd21, %rd5, %rd20;
ld.global.f32 %f1, [%rd21];
ld.global.f32 %f2, [%rd19];
add.f32 %f3, %f1, %f2;
st.global.f32 [%rd21], %f3;
.loc 2 14 1
add.s64 %rd22, %rd4, %rd18;
add.s64 %rd23, %rd3, %rd20;
ld.global.f32 %f4, [%rd23];
ld.global.f32 %f5, [%rd22];
add.f32 %f6, %f4, %f5;
st.global.f32 [%rd23], %f6;
.loc 2 15 1
add.s64 %rd24, %rd2, %rd18;
add.s64 %rd25, %rd1, %rd20;
ld.global.f32 %f7, [%rd25];
ld.global.f32 %f8, [%rd24];
add.f32 %f9, %f7, %f8;
st.global.f32 [%rd25], %f9;
BB0_2:
.loc 2 17 2
ret;
}
`
regionaddv_ptx_35 = `
.version 3.1
.target sm_35
.address_size 64
.weak .func (.param .b32 func_retval0) cudaMalloc(
.param .b64 cudaMalloc_param_0,
.param .b64 cudaMalloc_param_1
)
{
.reg .s32 %r<2>;
mov.u32 %r1, 30;
st.param.b32 [func_retval0+0], %r1;
.loc 2 66 3
ret;
}
.weak .func (.param .b32 func_retval0) cudaFuncGetAttributes(
.param .b64 cudaFuncGetAttributes_param_0,
.param .b64 cudaFuncGetAttributes_param_1
)
{
.reg .s32 %r<2>;
mov.u32 %r1, 30;
st.param.b32 [func_retval0+0], %r1;
.loc 2 71 3
ret;
}
.visible .entry regionaddv(
.param .u64 regionaddv_param_0,
.param .u64 regionaddv_param_1,
.param .u64 regionaddv_param_2,
.param .u64 regionaddv_param_3,
.param .u64 regionaddv_param_4,
.param .u64 regionaddv_param_5,
.param .u64 regionaddv_param_6,
.param .u32 regionaddv_param_7
)
{
.reg .pred %p<2>;
.reg .s32 %r<13>;
.reg .f32 %f<10>;
.reg .s64 %rd<26>;
ld.param.u64 %rd8, [regionaddv_param_0];
ld.param.u64 %rd9, [regionaddv_param_1];
ld.param.u64 %rd10, [regionaddv_param_2];
ld.param.u64 %rd11, [regionaddv_param_3];
ld.param.u64 %rd12, [regionaddv_param_4];
ld.param.u64 %rd13, [regionaddv_param_5];
ld.param.u64 %rd14, [regionaddv_param_6];
ld.param.u32 %r2, [regionaddv_param_7];
cvta.to.global.u64 %rd1, %rd10;
cvta.to.global.u64 %rd2, %rd13;
cvta.to.global.u64 %rd3, %rd9;
cvta.to.global.u64 %rd4, %rd12;
cvta.to.global.u64 %rd5, %rd8;
cvta.to.global.u64 %rd6, %rd11;
cvta.to.global.u64 %rd7, %rd14;
.loc 3 9 1
mov.u32 %r3, %nctaid.x;
mov.u32 %r4, %ctaid.y;
mov.u32 %r5, %ctaid.x;
mad.lo.s32 %r6, %r3, %r4, %r5;
mov.u32 %r7, %ntid.x;
mov.u32 %r8, %tid.x;
mad.lo.s32 %r1, %r6, %r7, %r8;
.loc 3 10 1
setp.ge.s32 %p1, %r1, %r2;
@%p1 bra BB2_2;
.loc 3 12 1
cvt.s64.s32 %rd15, %r1;
add.s64 %rd16, %rd7, %rd15;
.loc 3 13 1
ld.global.s8 %rd17, [%rd16];
shl.b64 %rd18, %rd17, 2;
add.s64 %rd19, %rd6, %rd18;
ld.global.nc.f32 %f1, [%rd19];
mul.wide.s32 %rd20, %r1, 4;
add.s64 %rd21, %rd5, %rd20;
ld.global.nc.f32 %f2, [%rd21];
add.f32 %f3, %f2, %f1;
st.global.f32 [%rd21], %f3;
.loc 3 14 1
add.s64 %rd22, %rd4, %rd18;
ld.global.nc.f32 %f4, [%rd22];
add.s64 %rd23, %rd3, %rd20;
ld.global.nc.f32 %f5, [%rd23];
add.f32 %f6, %f5, %f4;
st.global.f32 [%rd23], %f6;
.loc 3 15 1
add.s64 %rd24, %rd2, %rd18;
ld.global.nc.f32 %f7, [%rd24];
add.s64 %rd25, %rd1, %rd20;
ld.global.nc.f32 %f8, [%rd25];
add.f32 %f9, %f8, %f7;
st.global.f32 [%rd25], %f9;
BB2_2:
.loc 3 17 2
ret;
}
`
)