Debian Codegraph @

src/thirdparty/Symforce-Caspar/generated/f64/caspar_mappings.cu

raw
1 #include "caspar_mappings.h"
2 #include <cooperative_groups.h>
3 #include <cooperative_groups/memcpy_async.h>
4 #include <stdio.h>
5
6 namespace cg = cooperative_groups;
7
8 // We use shared memory to improve the memory access.
9 // A smaller block size of 32 allows for larger nodetypes.
10 constexpr int block_size = 32;
11
12 namespace caspar {
13
14 __global__
15 __launch_bounds__(block_size, 1) void ConstPinholeFocalStackedToCaspar_kernel(
16 const double* const __restrict__ stacked_data,
17 double* const __restrict__ cas_data,
18 const unsigned int cas_stride,
19 const unsigned int cas_offset,
20 const unsigned int num_objects) {
21 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
22 __shared__ double stacked_data_local[block_size * 2];
23
24 for (unsigned int target = (blockIdx.x * blockDim.x) * 2 + threadIdx.x;
25 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 2;
26 target += blockDim.x) {
27 stacked_data_local[target - (blockIdx.x * blockDim.x) * 2] =
28 stacked_data[target];
29 }
30
31 __syncthreads();
32
33 if (global_thread_idx < num_objects) {
34 double data[4] = {0, 0, 0, 0};
35 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 2;
36 double* out_ptr;
37 data[0] = stacked_local_ptr[0];
38 data[1] = stacked_local_ptr[1];
39
40 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
41 reinterpret_cast<double2*>(out_ptr)[0] =
42 reinterpret_cast<double2*>(data)[0];
43 }
44 }
45
46 __global__
47 __launch_bounds__(block_size, 1) void ConstPinholeFocalCasparToStacked_kernel(
48 const double* const __restrict__ cas_data,
49 double* const __restrict__ stacked_data,
50 const unsigned int cas_stride,
51 const unsigned int cas_offset,
52 const unsigned int num_objects) {
53 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
54 __shared__ double stacked_data_local[block_size * 2];
55
56 if (global_thread_idx < num_objects) {
57 double data[4] = {0, 0, 0, 0};
58 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 2;
59 const double* in_ptr;
60 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
61 reinterpret_cast<double2*>(data)[0] =
62 reinterpret_cast<const double2*>(in_ptr)[0];
63 stacked_local_ptr[0] = data[0];
64 stacked_local_ptr[1] = data[1];
65 }
66
67 __syncthreads();
68
69 for (unsigned int target = (blockIdx.x * blockDim.x) * 2 + threadIdx.x;
70 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 2;
71 target += blockDim.x) {
72 stacked_data[target] =
73 stacked_data_local[target - (blockIdx.x * blockDim.x) * 2];
74 }
75 }
76
77 cudaError_t ConstPinholeFocalStackedToCaspar(const double* stacked_data,
78 double* cas_data,
79 const unsigned int cas_stride,
80 const unsigned int cas_offset,
81 const unsigned int num_objects) {
82 const int num_blocks = (num_objects + block_size - 1) / block_size;
83
84 ConstPinholeFocalStackedToCaspar_kernel<<<num_blocks, block_size>>>(
85 stacked_data, cas_data, cas_stride, cas_offset, num_objects);
86
87 return cudaGetLastError();
88 }
89
90 cudaError_t ConstPinholeFocalCasparToStacked(const double* cas_data,
91 double* stacked_data,
92 const unsigned int cas_stride,
93 const unsigned int cas_offset,
94 const unsigned int num_objects) {
95 const int num_blocks = (num_objects + block_size - 1) / block_size;
96
97 ConstPinholeFocalCasparToStacked_kernel<<<num_blocks, block_size>>>(
98 cas_data, stacked_data, cas_stride, cas_offset, num_objects);
99
100 return cudaGetLastError();
101 }
102
103 __global__
104 __launch_bounds__(block_size, 1) void ConstPinholePoseStackedToCaspar_kernel(
105 const double* const __restrict__ stacked_data,
106 double* const __restrict__ cas_data,
107 const unsigned int cas_stride,
108 const unsigned int cas_offset,
109 const unsigned int num_objects) {
110 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
111 __shared__ double stacked_data_local[block_size * 7];
112
113 for (unsigned int target = (blockIdx.x * blockDim.x) * 7 + threadIdx.x;
114 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 7;
115 target += blockDim.x) {
116 stacked_data_local[target - (blockIdx.x * blockDim.x) * 7] =
117 stacked_data[target];
118 }
119
120 __syncthreads();
121
122 if (global_thread_idx < num_objects) {
123 double data[4] = {0, 0, 0, 0};
124 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 7;
125 double* out_ptr;
126 data[0] = stacked_local_ptr[0];
127 data[1] = stacked_local_ptr[1];
128
129 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
130 reinterpret_cast<double2*>(out_ptr)[0] =
131 reinterpret_cast<double2*>(data)[0];
132 data[0] = stacked_local_ptr[2];
133 data[1] = stacked_local_ptr[3];
134
135 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 2 * cas_stride;
136 reinterpret_cast<double2*>(out_ptr)[0] =
137 reinterpret_cast<double2*>(data)[0];
138 data[0] = stacked_local_ptr[4];
139 data[1] = stacked_local_ptr[5];
140
141 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 4 * cas_stride;
142 reinterpret_cast<double2*>(out_ptr)[0] =
143 reinterpret_cast<double2*>(data)[0];
144 data[0] = stacked_local_ptr[6];
145
146 out_ptr = cas_data + 1 * (global_thread_idx + cas_offset) + 6 * cas_stride;
147 out_ptr[0] = data[0];
148 }
149 }
150
151 __global__
152 __launch_bounds__(block_size, 1) void ConstPinholePoseCasparToStacked_kernel(
153 const double* const __restrict__ cas_data,
154 double* const __restrict__ stacked_data,
155 const unsigned int cas_stride,
156 const unsigned int cas_offset,
157 const unsigned int num_objects) {
158 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
159 __shared__ double stacked_data_local[block_size * 7];
160
161 if (global_thread_idx < num_objects) {
162 double data[4] = {0, 0, 0, 0};
163 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 7;
164 const double* in_ptr;
165 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
166 reinterpret_cast<double2*>(data)[0] =
167 reinterpret_cast<const double2*>(in_ptr)[0];
168 stacked_local_ptr[0] = data[0];
169 stacked_local_ptr[1] = data[1];
170 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 2 * cas_stride;
171 reinterpret_cast<double2*>(data)[0] =
172 reinterpret_cast<const double2*>(in_ptr)[0];
173 stacked_local_ptr[2] = data[0];
174 stacked_local_ptr[3] = data[1];
175 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 4 * cas_stride;
176 reinterpret_cast<double2*>(data)[0] =
177 reinterpret_cast<const double2*>(in_ptr)[0];
178 stacked_local_ptr[4] = data[0];
179 stacked_local_ptr[5] = data[1];
180 in_ptr = cas_data + 1 * (global_thread_idx + cas_offset) + 6 * cas_stride;
181 data[0] = in_ptr[0];
182 stacked_local_ptr[6] = data[0];
183 }
184
185 __syncthreads();
186
187 for (unsigned int target = (blockIdx.x * blockDim.x) * 7 + threadIdx.x;
188 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 7;
189 target += blockDim.x) {
190 stacked_data[target] =
191 stacked_data_local[target - (blockIdx.x * blockDim.x) * 7];
192 }
193 }
194
195 cudaError_t ConstPinholePoseStackedToCaspar(const double* stacked_data,
196 double* cas_data,
197 const unsigned int cas_stride,
198 const unsigned int cas_offset,
199 const unsigned int num_objects) {
200 const int num_blocks = (num_objects + block_size - 1) / block_size;
201
202 ConstPinholePoseStackedToCaspar_kernel<<<num_blocks, block_size>>>(
203 stacked_data, cas_data, cas_stride, cas_offset, num_objects);
204
205 return cudaGetLastError();
206 }
207
208 cudaError_t ConstPinholePoseCasparToStacked(const double* cas_data,
209 double* stacked_data,
210 const unsigned int cas_stride,
211 const unsigned int cas_offset,
212 const unsigned int num_objects) {
213 const int num_blocks = (num_objects + block_size - 1) / block_size;
214
215 ConstPinholePoseCasparToStacked_kernel<<<num_blocks, block_size>>>(
216 cas_data, stacked_data, cas_stride, cas_offset, num_objects);
217
218 return cudaGetLastError();
219 }
220
221 __global__
222 __launch_bounds__(block_size, 1) void ConstPinholePrincipalPointStackedToCaspar_kernel(
223 const double* const __restrict__ stacked_data,
224 double* const __restrict__ cas_data,
225 const unsigned int cas_stride,
226 const unsigned int cas_offset,
227 const unsigned int num_objects) {
228 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
229 __shared__ double stacked_data_local[block_size * 2];
230
231 for (unsigned int target = (blockIdx.x * blockDim.x) * 2 + threadIdx.x;
232 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 2;
233 target += blockDim.x) {
234 stacked_data_local[target - (blockIdx.x * blockDim.x) * 2] =
235 stacked_data[target];
236 }
237
238 __syncthreads();
239
240 if (global_thread_idx < num_objects) {
241 double data[4] = {0, 0, 0, 0};
242 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 2;
243 double* out_ptr;
244 data[0] = stacked_local_ptr[0];
245 data[1] = stacked_local_ptr[1];
246
247 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
248 reinterpret_cast<double2*>(out_ptr)[0] =
249 reinterpret_cast<double2*>(data)[0];
250 }
251 }
252
253 __global__
254 __launch_bounds__(block_size, 1) void ConstPinholePrincipalPointCasparToStacked_kernel(
255 const double* const __restrict__ cas_data,
256 double* const __restrict__ stacked_data,
257 const unsigned int cas_stride,
258 const unsigned int cas_offset,
259 const unsigned int num_objects) {
260 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
261 __shared__ double stacked_data_local[block_size * 2];
262
263 if (global_thread_idx < num_objects) {
264 double data[4] = {0, 0, 0, 0};
265 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 2;
266 const double* in_ptr;
267 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
268 reinterpret_cast<double2*>(data)[0] =
269 reinterpret_cast<const double2*>(in_ptr)[0];
270 stacked_local_ptr[0] = data[0];
271 stacked_local_ptr[1] = data[1];
272 }
273
274 __syncthreads();
275
276 for (unsigned int target = (blockIdx.x * blockDim.x) * 2 + threadIdx.x;
277 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 2;
278 target += blockDim.x) {
279 stacked_data[target] =
280 stacked_data_local[target - (blockIdx.x * blockDim.x) * 2];
281 }
282 }
283
284 cudaError_t ConstPinholePrincipalPointStackedToCaspar(
285 const double* stacked_data,
286 double* cas_data,
287 const unsigned int cas_stride,
288 const unsigned int cas_offset,
289 const unsigned int num_objects) {
290 const int num_blocks = (num_objects + block_size - 1) / block_size;
291
292 ConstPinholePrincipalPointStackedToCaspar_kernel<<<num_blocks, block_size>>>(
293 stacked_data, cas_data, cas_stride, cas_offset, num_objects);
294
295 return cudaGetLastError();
296 }
297
298 cudaError_t ConstPinholePrincipalPointCasparToStacked(
299 const double* cas_data,
300 double* stacked_data,
301 const unsigned int cas_stride,
302 const unsigned int cas_offset,
303 const unsigned int num_objects) {
304 const int num_blocks = (num_objects + block_size - 1) / block_size;
305
306 ConstPinholePrincipalPointCasparToStacked_kernel<<<num_blocks, block_size>>>(
307 cas_data, stacked_data, cas_stride, cas_offset, num_objects);
308
309 return cudaGetLastError();
310 }
311
312 __global__
313 __launch_bounds__(block_size, 1) void ConstPinholeSensorFromRigStackedToCaspar_kernel(
314 const double* const __restrict__ stacked_data,
315 double* const __restrict__ cas_data,
316 const unsigned int cas_stride,
317 const unsigned int cas_offset,
318 const unsigned int num_objects) {
319 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
320 __shared__ double stacked_data_local[block_size * 7];
321
322 for (unsigned int target = (blockIdx.x * blockDim.x) * 7 + threadIdx.x;
323 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 7;
324 target += blockDim.x) {
325 stacked_data_local[target - (blockIdx.x * blockDim.x) * 7] =
326 stacked_data[target];
327 }
328
329 __syncthreads();
330
331 if (global_thread_idx < num_objects) {
332 double data[4] = {0, 0, 0, 0};
333 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 7;
334 double* out_ptr;
335 data[0] = stacked_local_ptr[0];
336 data[1] = stacked_local_ptr[1];
337
338 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
339 reinterpret_cast<double2*>(out_ptr)[0] =
340 reinterpret_cast<double2*>(data)[0];
341 data[0] = stacked_local_ptr[2];
342 data[1] = stacked_local_ptr[3];
343
344 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 2 * cas_stride;
345 reinterpret_cast<double2*>(out_ptr)[0] =
346 reinterpret_cast<double2*>(data)[0];
347 data[0] = stacked_local_ptr[4];
348 data[1] = stacked_local_ptr[5];
349
350 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 4 * cas_stride;
351 reinterpret_cast<double2*>(out_ptr)[0] =
352 reinterpret_cast<double2*>(data)[0];
353 data[0] = stacked_local_ptr[6];
354
355 out_ptr = cas_data + 1 * (global_thread_idx + cas_offset) + 6 * cas_stride;
356 out_ptr[0] = data[0];
357 }
358 }
359
360 __global__
361 __launch_bounds__(block_size, 1) void ConstPinholeSensorFromRigCasparToStacked_kernel(
362 const double* const __restrict__ cas_data,
363 double* const __restrict__ stacked_data,
364 const unsigned int cas_stride,
365 const unsigned int cas_offset,
366 const unsigned int num_objects) {
367 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
368 __shared__ double stacked_data_local[block_size * 7];
369
370 if (global_thread_idx < num_objects) {
371 double data[4] = {0, 0, 0, 0};
372 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 7;
373 const double* in_ptr;
374 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
375 reinterpret_cast<double2*>(data)[0] =
376 reinterpret_cast<const double2*>(in_ptr)[0];
377 stacked_local_ptr[0] = data[0];
378 stacked_local_ptr[1] = data[1];
379 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 2 * cas_stride;
380 reinterpret_cast<double2*>(data)[0] =
381 reinterpret_cast<const double2*>(in_ptr)[0];
382 stacked_local_ptr[2] = data[0];
383 stacked_local_ptr[3] = data[1];
384 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 4 * cas_stride;
385 reinterpret_cast<double2*>(data)[0] =
386 reinterpret_cast<const double2*>(in_ptr)[0];
387 stacked_local_ptr[4] = data[0];
388 stacked_local_ptr[5] = data[1];
389 in_ptr = cas_data + 1 * (global_thread_idx + cas_offset) + 6 * cas_stride;
390 data[0] = in_ptr[0];
391 stacked_local_ptr[6] = data[0];
392 }
393
394 __syncthreads();
395
396 for (unsigned int target = (blockIdx.x * blockDim.x) * 7 + threadIdx.x;
397 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 7;
398 target += blockDim.x) {
399 stacked_data[target] =
400 stacked_data_local[target - (blockIdx.x * blockDim.x) * 7];
401 }
402 }
403
404 cudaError_t ConstPinholeSensorFromRigStackedToCaspar(
405 const double* stacked_data,
406 double* cas_data,
407 const unsigned int cas_stride,
408 const unsigned int cas_offset,
409 const unsigned int num_objects) {
410 const int num_blocks = (num_objects + block_size - 1) / block_size;
411
412 ConstPinholeSensorFromRigStackedToCaspar_kernel<<<num_blocks, block_size>>>(
413 stacked_data, cas_data, cas_stride, cas_offset, num_objects);
414
415 return cudaGetLastError();
416 }
417
418 cudaError_t ConstPinholeSensorFromRigCasparToStacked(
419 const double* cas_data,
420 double* stacked_data,
421 const unsigned int cas_stride,
422 const unsigned int cas_offset,
423 const unsigned int num_objects) {
424 const int num_blocks = (num_objects + block_size - 1) / block_size;
425
426 ConstPinholeSensorFromRigCasparToStacked_kernel<<<num_blocks, block_size>>>(
427 cas_data, stacked_data, cas_stride, cas_offset, num_objects);
428
429 return cudaGetLastError();
430 }
431
432 __global__
433 __launch_bounds__(block_size, 1) void ConstPixelStackedToCaspar_kernel(
434 const double* const __restrict__ stacked_data,
435 double* const __restrict__ cas_data,
436 const unsigned int cas_stride,
437 const unsigned int cas_offset,
438 const unsigned int num_objects) {
439 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
440 __shared__ double stacked_data_local[block_size * 2];
441
442 for (unsigned int target = (blockIdx.x * blockDim.x) * 2 + threadIdx.x;
443 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 2;
444 target += blockDim.x) {
445 stacked_data_local[target - (blockIdx.x * blockDim.x) * 2] =
446 stacked_data[target];
447 }
448
449 __syncthreads();
450
451 if (global_thread_idx < num_objects) {
452 double data[4] = {0, 0, 0, 0};
453 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 2;
454 double* out_ptr;
455 data[0] = stacked_local_ptr[0];
456 data[1] = stacked_local_ptr[1];
457
458 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
459 reinterpret_cast<double2*>(out_ptr)[0] =
460 reinterpret_cast<double2*>(data)[0];
461 }
462 }
463
464 __global__
465 __launch_bounds__(block_size, 1) void ConstPixelCasparToStacked_kernel(
466 const double* const __restrict__ cas_data,
467 double* const __restrict__ stacked_data,
468 const unsigned int cas_stride,
469 const unsigned int cas_offset,
470 const unsigned int num_objects) {
471 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
472 __shared__ double stacked_data_local[block_size * 2];
473
474 if (global_thread_idx < num_objects) {
475 double data[4] = {0, 0, 0, 0};
476 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 2;
477 const double* in_ptr;
478 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
479 reinterpret_cast<double2*>(data)[0] =
480 reinterpret_cast<const double2*>(in_ptr)[0];
481 stacked_local_ptr[0] = data[0];
482 stacked_local_ptr[1] = data[1];
483 }
484
485 __syncthreads();
486
487 for (unsigned int target = (blockIdx.x * blockDim.x) * 2 + threadIdx.x;
488 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 2;
489 target += blockDim.x) {
490 stacked_data[target] =
491 stacked_data_local[target - (blockIdx.x * blockDim.x) * 2];
492 }
493 }
494
495 cudaError_t ConstPixelStackedToCaspar(const double* stacked_data,
496 double* cas_data,
497 const unsigned int cas_stride,
498 const unsigned int cas_offset,
499 const unsigned int num_objects) {
500 const int num_blocks = (num_objects + block_size - 1) / block_size;
501
502 ConstPixelStackedToCaspar_kernel<<<num_blocks, block_size>>>(
503 stacked_data, cas_data, cas_stride, cas_offset, num_objects);
504
505 return cudaGetLastError();
506 }
507
508 cudaError_t ConstPixelCasparToStacked(const double* cas_data,
509 double* stacked_data,
510 const unsigned int cas_stride,
511 const unsigned int cas_offset,
512 const unsigned int num_objects) {
513 const int num_blocks = (num_objects + block_size - 1) / block_size;
514
515 ConstPixelCasparToStacked_kernel<<<num_blocks, block_size>>>(
516 cas_data, stacked_data, cas_stride, cas_offset, num_objects);
517
518 return cudaGetLastError();
519 }
520
521 __global__
522 __launch_bounds__(block_size, 1) void ConstPointStackedToCaspar_kernel(
523 const double* const __restrict__ stacked_data,
524 double* const __restrict__ cas_data,
525 const unsigned int cas_stride,
526 const unsigned int cas_offset,
527 const unsigned int num_objects) {
528 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
529 __shared__ double stacked_data_local[block_size * 3];
530
531 for (unsigned int target = (blockIdx.x * blockDim.x) * 3 + threadIdx.x;
532 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 3;
533 target += blockDim.x) {
534 stacked_data_local[target - (blockIdx.x * blockDim.x) * 3] =
535 stacked_data[target];
536 }
537
538 __syncthreads();
539
540 if (global_thread_idx < num_objects) {
541 double data[4] = {0, 0, 0, 0};
542 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 3;
543 double* out_ptr;
544 data[0] = stacked_local_ptr[0];
545 data[1] = stacked_local_ptr[1];
546
547 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
548 reinterpret_cast<double2*>(out_ptr)[0] =
549 reinterpret_cast<double2*>(data)[0];
550 data[0] = stacked_local_ptr[2];
551
552 out_ptr = cas_data + 1 * (global_thread_idx + cas_offset) + 2 * cas_stride;
553 out_ptr[0] = data[0];
554 }
555 }
556
557 __global__
558 __launch_bounds__(block_size, 1) void ConstPointCasparToStacked_kernel(
559 const double* const __restrict__ cas_data,
560 double* const __restrict__ stacked_data,
561 const unsigned int cas_stride,
562 const unsigned int cas_offset,
563 const unsigned int num_objects) {
564 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
565 __shared__ double stacked_data_local[block_size * 3];
566
567 if (global_thread_idx < num_objects) {
568 double data[4] = {0, 0, 0, 0};
569 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 3;
570 const double* in_ptr;
571 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
572 reinterpret_cast<double2*>(data)[0] =
573 reinterpret_cast<const double2*>(in_ptr)[0];
574 stacked_local_ptr[0] = data[0];
575 stacked_local_ptr[1] = data[1];
576 in_ptr = cas_data + 1 * (global_thread_idx + cas_offset) + 2 * cas_stride;
577 data[0] = in_ptr[0];
578 stacked_local_ptr[2] = data[0];
579 }
580
581 __syncthreads();
582
583 for (unsigned int target = (blockIdx.x * blockDim.x) * 3 + threadIdx.x;
584 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 3;
585 target += blockDim.x) {
586 stacked_data[target] =
587 stacked_data_local[target - (blockIdx.x * blockDim.x) * 3];
588 }
589 }
590
591 cudaError_t ConstPointStackedToCaspar(const double* stacked_data,
592 double* cas_data,
593 const unsigned int cas_stride,
594 const unsigned int cas_offset,
595 const unsigned int num_objects) {
596 const int num_blocks = (num_objects + block_size - 1) / block_size;
597
598 ConstPointStackedToCaspar_kernel<<<num_blocks, block_size>>>(
599 stacked_data, cas_data, cas_stride, cas_offset, num_objects);
600
601 return cudaGetLastError();
602 }
603
604 cudaError_t ConstPointCasparToStacked(const double* cas_data,
605 double* stacked_data,
606 const unsigned int cas_stride,
607 const unsigned int cas_offset,
608 const unsigned int num_objects) {
609 const int num_blocks = (num_objects + block_size - 1) / block_size;
610
611 ConstPointCasparToStacked_kernel<<<num_blocks, block_size>>>(
612 cas_data, stacked_data, cas_stride, cas_offset, num_objects);
613
614 return cudaGetLastError();
615 }
616
617 __global__
618 __launch_bounds__(block_size, 1) void ConstSimpleRadialFocalAndExtraStackedToCaspar_kernel(
619 const double* const __restrict__ stacked_data,
620 double* const __restrict__ cas_data,
621 const unsigned int cas_stride,
622 const unsigned int cas_offset,
623 const unsigned int num_objects) {
624 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
625 __shared__ double stacked_data_local[block_size * 2];
626
627 for (unsigned int target = (blockIdx.x * blockDim.x) * 2 + threadIdx.x;
628 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 2;
629 target += blockDim.x) {
630 stacked_data_local[target - (blockIdx.x * blockDim.x) * 2] =
631 stacked_data[target];
632 }
633
634 __syncthreads();
635
636 if (global_thread_idx < num_objects) {
637 double data[4] = {0, 0, 0, 0};
638 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 2;
639 double* out_ptr;
640 data[0] = stacked_local_ptr[0];
641 data[1] = stacked_local_ptr[1];
642
643 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
644 reinterpret_cast<double2*>(out_ptr)[0] =
645 reinterpret_cast<double2*>(data)[0];
646 }
647 }
648
649 __global__
650 __launch_bounds__(block_size, 1) void ConstSimpleRadialFocalAndExtraCasparToStacked_kernel(
651 const double* const __restrict__ cas_data,
652 double* const __restrict__ stacked_data,
653 const unsigned int cas_stride,
654 const unsigned int cas_offset,
655 const unsigned int num_objects) {
656 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
657 __shared__ double stacked_data_local[block_size * 2];
658
659 if (global_thread_idx < num_objects) {
660 double data[4] = {0, 0, 0, 0};
661 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 2;
662 const double* in_ptr;
663 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
664 reinterpret_cast<double2*>(data)[0] =
665 reinterpret_cast<const double2*>(in_ptr)[0];
666 stacked_local_ptr[0] = data[0];
667 stacked_local_ptr[1] = data[1];
668 }
669
670 __syncthreads();
671
672 for (unsigned int target = (blockIdx.x * blockDim.x) * 2 + threadIdx.x;
673 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 2;
674 target += blockDim.x) {
675 stacked_data[target] =
676 stacked_data_local[target - (blockIdx.x * blockDim.x) * 2];
677 }
678 }
679
680 cudaError_t ConstSimpleRadialFocalAndExtraStackedToCaspar(
681 const double* stacked_data,
682 double* cas_data,
683 const unsigned int cas_stride,
684 const unsigned int cas_offset,
685 const unsigned int num_objects) {
686 const int num_blocks = (num_objects + block_size - 1) / block_size;
687
688 ConstSimpleRadialFocalAndExtraStackedToCaspar_kernel<<<num_blocks,
689 block_size>>>(
690 stacked_data, cas_data, cas_stride, cas_offset, num_objects);
691
692 return cudaGetLastError();
693 }
694
695 cudaError_t ConstSimpleRadialFocalAndExtraCasparToStacked(
696 const double* cas_data,
697 double* stacked_data,
698 const unsigned int cas_stride,
699 const unsigned int cas_offset,
700 const unsigned int num_objects) {
701 const int num_blocks = (num_objects + block_size - 1) / block_size;
702
703 ConstSimpleRadialFocalAndExtraCasparToStacked_kernel<<<num_blocks,
704 block_size>>>(
705 cas_data, stacked_data, cas_stride, cas_offset, num_objects);
706
707 return cudaGetLastError();
708 }
709
710 __global__
711 __launch_bounds__(block_size, 1) void ConstSimpleRadialPoseStackedToCaspar_kernel(
712 const double* const __restrict__ stacked_data,
713 double* const __restrict__ cas_data,
714 const unsigned int cas_stride,
715 const unsigned int cas_offset,
716 const unsigned int num_objects) {
717 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
718 __shared__ double stacked_data_local[block_size * 7];
719
720 for (unsigned int target = (blockIdx.x * blockDim.x) * 7 + threadIdx.x;
721 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 7;
722 target += blockDim.x) {
723 stacked_data_local[target - (blockIdx.x * blockDim.x) * 7] =
724 stacked_data[target];
725 }
726
727 __syncthreads();
728
729 if (global_thread_idx < num_objects) {
730 double data[4] = {0, 0, 0, 0};
731 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 7;
732 double* out_ptr;
733 data[0] = stacked_local_ptr[0];
734 data[1] = stacked_local_ptr[1];
735
736 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
737 reinterpret_cast<double2*>(out_ptr)[0] =
738 reinterpret_cast<double2*>(data)[0];
739 data[0] = stacked_local_ptr[2];
740 data[1] = stacked_local_ptr[3];
741
742 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 2 * cas_stride;
743 reinterpret_cast<double2*>(out_ptr)[0] =
744 reinterpret_cast<double2*>(data)[0];
745 data[0] = stacked_local_ptr[4];
746 data[1] = stacked_local_ptr[5];
747
748 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 4 * cas_stride;
749 reinterpret_cast<double2*>(out_ptr)[0] =
750 reinterpret_cast<double2*>(data)[0];
751 data[0] = stacked_local_ptr[6];
752
753 out_ptr = cas_data + 1 * (global_thread_idx + cas_offset) + 6 * cas_stride;
754 out_ptr[0] = data[0];
755 }
756 }
757
758 __global__
759 __launch_bounds__(block_size, 1) void ConstSimpleRadialPoseCasparToStacked_kernel(
760 const double* const __restrict__ cas_data,
761 double* const __restrict__ stacked_data,
762 const unsigned int cas_stride,
763 const unsigned int cas_offset,
764 const unsigned int num_objects) {
765 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
766 __shared__ double stacked_data_local[block_size * 7];
767
768 if (global_thread_idx < num_objects) {
769 double data[4] = {0, 0, 0, 0};
770 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 7;
771 const double* in_ptr;
772 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
773 reinterpret_cast<double2*>(data)[0] =
774 reinterpret_cast<const double2*>(in_ptr)[0];
775 stacked_local_ptr[0] = data[0];
776 stacked_local_ptr[1] = data[1];
777 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 2 * cas_stride;
778 reinterpret_cast<double2*>(data)[0] =
779 reinterpret_cast<const double2*>(in_ptr)[0];
780 stacked_local_ptr[2] = data[0];
781 stacked_local_ptr[3] = data[1];
782 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 4 * cas_stride;
783 reinterpret_cast<double2*>(data)[0] =
784 reinterpret_cast<const double2*>(in_ptr)[0];
785 stacked_local_ptr[4] = data[0];
786 stacked_local_ptr[5] = data[1];
787 in_ptr = cas_data + 1 * (global_thread_idx + cas_offset) + 6 * cas_stride;
788 data[0] = in_ptr[0];
789 stacked_local_ptr[6] = data[0];
790 }
791
792 __syncthreads();
793
794 for (unsigned int target = (blockIdx.x * blockDim.x) * 7 + threadIdx.x;
795 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 7;
796 target += blockDim.x) {
797 stacked_data[target] =
798 stacked_data_local[target - (blockIdx.x * blockDim.x) * 7];
799 }
800 }
801
802 cudaError_t ConstSimpleRadialPoseStackedToCaspar(
803 const double* stacked_data,
804 double* cas_data,
805 const unsigned int cas_stride,
806 const unsigned int cas_offset,
807 const unsigned int num_objects) {
808 const int num_blocks = (num_objects + block_size - 1) / block_size;
809
810 ConstSimpleRadialPoseStackedToCaspar_kernel<<<num_blocks, block_size>>>(
811 stacked_data, cas_data, cas_stride, cas_offset, num_objects);
812
813 return cudaGetLastError();
814 }
815
816 cudaError_t ConstSimpleRadialPoseCasparToStacked(
817 const double* cas_data,
818 double* stacked_data,
819 const unsigned int cas_stride,
820 const unsigned int cas_offset,
821 const unsigned int num_objects) {
822 const int num_blocks = (num_objects + block_size - 1) / block_size;
823
824 ConstSimpleRadialPoseCasparToStacked_kernel<<<num_blocks, block_size>>>(
825 cas_data, stacked_data, cas_stride, cas_offset, num_objects);
826
827 return cudaGetLastError();
828 }
829
830 __global__
831 __launch_bounds__(block_size, 1) void ConstSimpleRadialPrincipalPointStackedToCaspar_kernel(
832 const double* const __restrict__ stacked_data,
833 double* const __restrict__ cas_data,
834 const unsigned int cas_stride,
835 const unsigned int cas_offset,
836 const unsigned int num_objects) {
837 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
838 __shared__ double stacked_data_local[block_size * 2];
839
840 for (unsigned int target = (blockIdx.x * blockDim.x) * 2 + threadIdx.x;
841 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 2;
842 target += blockDim.x) {
843 stacked_data_local[target - (blockIdx.x * blockDim.x) * 2] =
844 stacked_data[target];
845 }
846
847 __syncthreads();
848
849 if (global_thread_idx < num_objects) {
850 double data[4] = {0, 0, 0, 0};
851 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 2;
852 double* out_ptr;
853 data[0] = stacked_local_ptr[0];
854 data[1] = stacked_local_ptr[1];
855
856 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
857 reinterpret_cast<double2*>(out_ptr)[0] =
858 reinterpret_cast<double2*>(data)[0];
859 }
860 }
861
862 __global__
863 __launch_bounds__(block_size, 1) void ConstSimpleRadialPrincipalPointCasparToStacked_kernel(
864 const double* const __restrict__ cas_data,
865 double* const __restrict__ stacked_data,
866 const unsigned int cas_stride,
867 const unsigned int cas_offset,
868 const unsigned int num_objects) {
869 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
870 __shared__ double stacked_data_local[block_size * 2];
871
872 if (global_thread_idx < num_objects) {
873 double data[4] = {0, 0, 0, 0};
874 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 2;
875 const double* in_ptr;
876 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
877 reinterpret_cast<double2*>(data)[0] =
878 reinterpret_cast<const double2*>(in_ptr)[0];
879 stacked_local_ptr[0] = data[0];
880 stacked_local_ptr[1] = data[1];
881 }
882
883 __syncthreads();
884
885 for (unsigned int target = (blockIdx.x * blockDim.x) * 2 + threadIdx.x;
886 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 2;
887 target += blockDim.x) {
888 stacked_data[target] =
889 stacked_data_local[target - (blockIdx.x * blockDim.x) * 2];
890 }
891 }
892
893 cudaError_t ConstSimpleRadialPrincipalPointStackedToCaspar(
894 const double* stacked_data,
895 double* cas_data,
896 const unsigned int cas_stride,
897 const unsigned int cas_offset,
898 const unsigned int num_objects) {
899 const int num_blocks = (num_objects + block_size - 1) / block_size;
900
901 ConstSimpleRadialPrincipalPointStackedToCaspar_kernel<<<num_blocks,
902 block_size>>>(
903 stacked_data, cas_data, cas_stride, cas_offset, num_objects);
904
905 return cudaGetLastError();
906 }
907
908 cudaError_t ConstSimpleRadialPrincipalPointCasparToStacked(
909 const double* cas_data,
910 double* stacked_data,
911 const unsigned int cas_stride,
912 const unsigned int cas_offset,
913 const unsigned int num_objects) {
914 const int num_blocks = (num_objects + block_size - 1) / block_size;
915
916 ConstSimpleRadialPrincipalPointCasparToStacked_kernel<<<num_blocks,
917 block_size>>>(
918 cas_data, stacked_data, cas_stride, cas_offset, num_objects);
919
920 return cudaGetLastError();
921 }
922
923 __global__
924 __launch_bounds__(block_size, 1) void ConstSimpleRadialSensorFromRigStackedToCaspar_kernel(
925 const double* const __restrict__ stacked_data,
926 double* const __restrict__ cas_data,
927 const unsigned int cas_stride,
928 const unsigned int cas_offset,
929 const unsigned int num_objects) {
930 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
931 __shared__ double stacked_data_local[block_size * 7];
932
933 for (unsigned int target = (blockIdx.x * blockDim.x) * 7 + threadIdx.x;
934 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 7;
935 target += blockDim.x) {
936 stacked_data_local[target - (blockIdx.x * blockDim.x) * 7] =
937 stacked_data[target];
938 }
939
940 __syncthreads();
941
942 if (global_thread_idx < num_objects) {
943 double data[4] = {0, 0, 0, 0};
944 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 7;
945 double* out_ptr;
946 data[0] = stacked_local_ptr[0];
947 data[1] = stacked_local_ptr[1];
948
949 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
950 reinterpret_cast<double2*>(out_ptr)[0] =
951 reinterpret_cast<double2*>(data)[0];
952 data[0] = stacked_local_ptr[2];
953 data[1] = stacked_local_ptr[3];
954
955 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 2 * cas_stride;
956 reinterpret_cast<double2*>(out_ptr)[0] =
957 reinterpret_cast<double2*>(data)[0];
958 data[0] = stacked_local_ptr[4];
959 data[1] = stacked_local_ptr[5];
960
961 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 4 * cas_stride;
962 reinterpret_cast<double2*>(out_ptr)[0] =
963 reinterpret_cast<double2*>(data)[0];
964 data[0] = stacked_local_ptr[6];
965
966 out_ptr = cas_data + 1 * (global_thread_idx + cas_offset) + 6 * cas_stride;
967 out_ptr[0] = data[0];
968 }
969 }
970
971 __global__
972 __launch_bounds__(block_size, 1) void ConstSimpleRadialSensorFromRigCasparToStacked_kernel(
973 const double* const __restrict__ cas_data,
974 double* const __restrict__ stacked_data,
975 const unsigned int cas_stride,
976 const unsigned int cas_offset,
977 const unsigned int num_objects) {
978 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
979 __shared__ double stacked_data_local[block_size * 7];
980
981 if (global_thread_idx < num_objects) {
982 double data[4] = {0, 0, 0, 0};
983 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 7;
984 const double* in_ptr;
985 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
986 reinterpret_cast<double2*>(data)[0] =
987 reinterpret_cast<const double2*>(in_ptr)[0];
988 stacked_local_ptr[0] = data[0];
989 stacked_local_ptr[1] = data[1];
990 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 2 * cas_stride;
991 reinterpret_cast<double2*>(data)[0] =
992 reinterpret_cast<const double2*>(in_ptr)[0];
993 stacked_local_ptr[2] = data[0];
994 stacked_local_ptr[3] = data[1];
995 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 4 * cas_stride;
996 reinterpret_cast<double2*>(data)[0] =
997 reinterpret_cast<const double2*>(in_ptr)[0];
998 stacked_local_ptr[4] = data[0];
999 stacked_local_ptr[5] = data[1];
1000 in_ptr = cas_data + 1 * (global_thread_idx + cas_offset) + 6 * cas_stride;
1001 data[0] = in_ptr[0];
1002 stacked_local_ptr[6] = data[0];
1003 }
1004
1005 __syncthreads();
1006
1007 for (unsigned int target = (blockIdx.x * blockDim.x) * 7 + threadIdx.x;
1008 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 7;
1009 target += blockDim.x) {
1010 stacked_data[target] =
1011 stacked_data_local[target - (blockIdx.x * blockDim.x) * 7];
1012 }
1013 }
1014
1015 cudaError_t ConstSimpleRadialSensorFromRigStackedToCaspar(
1016 const double* stacked_data,
1017 double* cas_data,
1018 const unsigned int cas_stride,
1019 const unsigned int cas_offset,
1020 const unsigned int num_objects) {
1021 const int num_blocks = (num_objects + block_size - 1) / block_size;
1022
1023 ConstSimpleRadialSensorFromRigStackedToCaspar_kernel<<<num_blocks,
1024 block_size>>>(
1025 stacked_data, cas_data, cas_stride, cas_offset, num_objects);
1026
1027 return cudaGetLastError();
1028 }
1029
1030 cudaError_t ConstSimpleRadialSensorFromRigCasparToStacked(
1031 const double* cas_data,
1032 double* stacked_data,
1033 const unsigned int cas_stride,
1034 const unsigned int cas_offset,
1035 const unsigned int num_objects) {
1036 const int num_blocks = (num_objects + block_size - 1) / block_size;
1037
1038 ConstSimpleRadialSensorFromRigCasparToStacked_kernel<<<num_blocks,
1039 block_size>>>(
1040 cas_data, stacked_data, cas_stride, cas_offset, num_objects);
1041
1042 return cudaGetLastError();
1043 }
1044
1045 __global__
1046 __launch_bounds__(block_size, 1) void PinholeCalibStackedToCaspar_kernel(
1047 const double* const __restrict__ stacked_data,
1048 double* const __restrict__ cas_data,
1049 const unsigned int cas_stride,
1050 const unsigned int cas_offset,
1051 const unsigned int num_objects) {
1052 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
1053 __shared__ double stacked_data_local[block_size * 4];
1054
1055 for (unsigned int target = (blockIdx.x * blockDim.x) * 4 + threadIdx.x;
1056 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 4;
1057 target += blockDim.x) {
1058 stacked_data_local[target - (blockIdx.x * blockDim.x) * 4] =
1059 stacked_data[target];
1060 }
1061
1062 __syncthreads();
1063
1064 if (global_thread_idx < num_objects) {
1065 double data[4] = {0, 0, 0, 0};
1066 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 4;
1067 double* out_ptr;
1068 data[0] = stacked_local_ptr[0];
1069 data[1] = stacked_local_ptr[1];
1070
1071 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
1072 reinterpret_cast<double2*>(out_ptr)[0] =
1073 reinterpret_cast<double2*>(data)[0];
1074 data[0] = stacked_local_ptr[2];
1075 data[1] = stacked_local_ptr[3];
1076
1077 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 2 * cas_stride;
1078 reinterpret_cast<double2*>(out_ptr)[0] =
1079 reinterpret_cast<double2*>(data)[0];
1080 }
1081 }
1082
1083 __global__
1084 __launch_bounds__(block_size, 1) void PinholeCalibCasparToStacked_kernel(
1085 const double* const __restrict__ cas_data,
1086 double* const __restrict__ stacked_data,
1087 const unsigned int cas_stride,
1088 const unsigned int cas_offset,
1089 const unsigned int num_objects) {
1090 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
1091 __shared__ double stacked_data_local[block_size * 4];
1092
1093 if (global_thread_idx < num_objects) {
1094 double data[4] = {0, 0, 0, 0};
1095 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 4;
1096 const double* in_ptr;
1097 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
1098 reinterpret_cast<double2*>(data)[0] =
1099 reinterpret_cast<const double2*>(in_ptr)[0];
1100 stacked_local_ptr[0] = data[0];
1101 stacked_local_ptr[1] = data[1];
1102 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 2 * cas_stride;
1103 reinterpret_cast<double2*>(data)[0] =
1104 reinterpret_cast<const double2*>(in_ptr)[0];
1105 stacked_local_ptr[2] = data[0];
1106 stacked_local_ptr[3] = data[1];
1107 }
1108
1109 __syncthreads();
1110
1111 for (unsigned int target = (blockIdx.x * blockDim.x) * 4 + threadIdx.x;
1112 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 4;
1113 target += blockDim.x) {
1114 stacked_data[target] =
1115 stacked_data_local[target - (blockIdx.x * blockDim.x) * 4];
1116 }
1117 }
1118
1119 cudaError_t PinholeCalibStackedToCaspar(const double* stacked_data,
1120 double* cas_data,
1121 const unsigned int cas_stride,
1122 const unsigned int cas_offset,
1123 const unsigned int num_objects) {
1124 const int num_blocks = (num_objects + block_size - 1) / block_size;
1125
1126 PinholeCalibStackedToCaspar_kernel<<<num_blocks, block_size>>>(
1127 stacked_data, cas_data, cas_stride, cas_offset, num_objects);
1128
1129 return cudaGetLastError();
1130 }
1131
1132 cudaError_t PinholeCalibCasparToStacked(const double* cas_data,
1133 double* stacked_data,
1134 const unsigned int cas_stride,
1135 const unsigned int cas_offset,
1136 const unsigned int num_objects) {
1137 const int num_blocks = (num_objects + block_size - 1) / block_size;
1138
1139 PinholeCalibCasparToStacked_kernel<<<num_blocks, block_size>>>(
1140 cas_data, stacked_data, cas_stride, cas_offset, num_objects);
1141
1142 return cudaGetLastError();
1143 }
1144
1145 __global__
1146 __launch_bounds__(block_size, 1) void PinholeFocalStackedToCaspar_kernel(
1147 const double* const __restrict__ stacked_data,
1148 double* const __restrict__ cas_data,
1149 const unsigned int cas_stride,
1150 const unsigned int cas_offset,
1151 const unsigned int num_objects) {
1152 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
1153 __shared__ double stacked_data_local[block_size * 2];
1154
1155 for (unsigned int target = (blockIdx.x * blockDim.x) * 2 + threadIdx.x;
1156 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 2;
1157 target += blockDim.x) {
1158 stacked_data_local[target - (blockIdx.x * blockDim.x) * 2] =
1159 stacked_data[target];
1160 }
1161
1162 __syncthreads();
1163
1164 if (global_thread_idx < num_objects) {
1165 double data[4] = {0, 0, 0, 0};
1166 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 2;
1167 double* out_ptr;
1168 data[0] = stacked_local_ptr[0];
1169 data[1] = stacked_local_ptr[1];
1170
1171 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
1172 reinterpret_cast<double2*>(out_ptr)[0] =
1173 reinterpret_cast<double2*>(data)[0];
1174 }
1175 }
1176
1177 __global__
1178 __launch_bounds__(block_size, 1) void PinholeFocalCasparToStacked_kernel(
1179 const double* const __restrict__ cas_data,
1180 double* const __restrict__ stacked_data,
1181 const unsigned int cas_stride,
1182 const unsigned int cas_offset,
1183 const unsigned int num_objects) {
1184 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
1185 __shared__ double stacked_data_local[block_size * 2];
1186
1187 if (global_thread_idx < num_objects) {
1188 double data[4] = {0, 0, 0, 0};
1189 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 2;
1190 const double* in_ptr;
1191 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
1192 reinterpret_cast<double2*>(data)[0] =
1193 reinterpret_cast<const double2*>(in_ptr)[0];
1194 stacked_local_ptr[0] = data[0];
1195 stacked_local_ptr[1] = data[1];
1196 }
1197
1198 __syncthreads();
1199
1200 for (unsigned int target = (blockIdx.x * blockDim.x) * 2 + threadIdx.x;
1201 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 2;
1202 target += blockDim.x) {
1203 stacked_data[target] =
1204 stacked_data_local[target - (blockIdx.x * blockDim.x) * 2];
1205 }
1206 }
1207
1208 cudaError_t PinholeFocalStackedToCaspar(const double* stacked_data,
1209 double* cas_data,
1210 const unsigned int cas_stride,
1211 const unsigned int cas_offset,
1212 const unsigned int num_objects) {
1213 const int num_blocks = (num_objects + block_size - 1) / block_size;
1214
1215 PinholeFocalStackedToCaspar_kernel<<<num_blocks, block_size>>>(
1216 stacked_data, cas_data, cas_stride, cas_offset, num_objects);
1217
1218 return cudaGetLastError();
1219 }
1220
1221 cudaError_t PinholeFocalCasparToStacked(const double* cas_data,
1222 double* stacked_data,
1223 const unsigned int cas_stride,
1224 const unsigned int cas_offset,
1225 const unsigned int num_objects) {
1226 const int num_blocks = (num_objects + block_size - 1) / block_size;
1227
1228 PinholeFocalCasparToStacked_kernel<<<num_blocks, block_size>>>(
1229 cas_data, stacked_data, cas_stride, cas_offset, num_objects);
1230
1231 return cudaGetLastError();
1232 }
1233
1234 __global__
1235 __launch_bounds__(block_size, 1) void PinholePoseStackedToCaspar_kernel(
1236 const double* const __restrict__ stacked_data,
1237 double* const __restrict__ cas_data,
1238 const unsigned int cas_stride,
1239 const unsigned int cas_offset,
1240 const unsigned int num_objects) {
1241 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
1242 __shared__ double stacked_data_local[block_size * 7];
1243
1244 for (unsigned int target = (blockIdx.x * blockDim.x) * 7 + threadIdx.x;
1245 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 7;
1246 target += blockDim.x) {
1247 stacked_data_local[target - (blockIdx.x * blockDim.x) * 7] =
1248 stacked_data[target];
1249 }
1250
1251 __syncthreads();
1252
1253 if (global_thread_idx < num_objects) {
1254 double data[4] = {0, 0, 0, 0};
1255 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 7;
1256 double* out_ptr;
1257 data[0] = stacked_local_ptr[0];
1258 data[1] = stacked_local_ptr[1];
1259
1260 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
1261 reinterpret_cast<double2*>(out_ptr)[0] =
1262 reinterpret_cast<double2*>(data)[0];
1263 data[0] = stacked_local_ptr[2];
1264 data[1] = stacked_local_ptr[3];
1265
1266 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 2 * cas_stride;
1267 reinterpret_cast<double2*>(out_ptr)[0] =
1268 reinterpret_cast<double2*>(data)[0];
1269 data[0] = stacked_local_ptr[4];
1270 data[1] = stacked_local_ptr[5];
1271
1272 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 4 * cas_stride;
1273 reinterpret_cast<double2*>(out_ptr)[0] =
1274 reinterpret_cast<double2*>(data)[0];
1275 data[0] = stacked_local_ptr[6];
1276
1277 out_ptr = cas_data + 1 * (global_thread_idx + cas_offset) + 6 * cas_stride;
1278 out_ptr[0] = data[0];
1279 }
1280 }
1281
1282 __global__
1283 __launch_bounds__(block_size, 1) void PinholePoseCasparToStacked_kernel(
1284 const double* const __restrict__ cas_data,
1285 double* const __restrict__ stacked_data,
1286 const unsigned int cas_stride,
1287 const unsigned int cas_offset,
1288 const unsigned int num_objects) {
1289 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
1290 __shared__ double stacked_data_local[block_size * 7];
1291
1292 if (global_thread_idx < num_objects) {
1293 double data[4] = {0, 0, 0, 0};
1294 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 7;
1295 const double* in_ptr;
1296 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
1297 reinterpret_cast<double2*>(data)[0] =
1298 reinterpret_cast<const double2*>(in_ptr)[0];
1299 stacked_local_ptr[0] = data[0];
1300 stacked_local_ptr[1] = data[1];
1301 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 2 * cas_stride;
1302 reinterpret_cast<double2*>(data)[0] =
1303 reinterpret_cast<const double2*>(in_ptr)[0];
1304 stacked_local_ptr[2] = data[0];
1305 stacked_local_ptr[3] = data[1];
1306 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 4 * cas_stride;
1307 reinterpret_cast<double2*>(data)[0] =
1308 reinterpret_cast<const double2*>(in_ptr)[0];
1309 stacked_local_ptr[4] = data[0];
1310 stacked_local_ptr[5] = data[1];
1311 in_ptr = cas_data + 1 * (global_thread_idx + cas_offset) + 6 * cas_stride;
1312 data[0] = in_ptr[0];
1313 stacked_local_ptr[6] = data[0];
1314 }
1315
1316 __syncthreads();
1317
1318 for (unsigned int target = (blockIdx.x * blockDim.x) * 7 + threadIdx.x;
1319 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 7;
1320 target += blockDim.x) {
1321 stacked_data[target] =
1322 stacked_data_local[target - (blockIdx.x * blockDim.x) * 7];
1323 }
1324 }
1325
1326 cudaError_t PinholePoseStackedToCaspar(const double* stacked_data,
1327 double* cas_data,
1328 const unsigned int cas_stride,
1329 const unsigned int cas_offset,
1330 const unsigned int num_objects) {
1331 const int num_blocks = (num_objects + block_size - 1) / block_size;
1332
1333 PinholePoseStackedToCaspar_kernel<<<num_blocks, block_size>>>(
1334 stacked_data, cas_data, cas_stride, cas_offset, num_objects);
1335
1336 return cudaGetLastError();
1337 }
1338
1339 cudaError_t PinholePoseCasparToStacked(const double* cas_data,
1340 double* stacked_data,
1341 const unsigned int cas_stride,
1342 const unsigned int cas_offset,
1343 const unsigned int num_objects) {
1344 const int num_blocks = (num_objects + block_size - 1) / block_size;
1345
1346 PinholePoseCasparToStacked_kernel<<<num_blocks, block_size>>>(
1347 cas_data, stacked_data, cas_stride, cas_offset, num_objects);
1348
1349 return cudaGetLastError();
1350 }
1351
1352 __global__
1353 __launch_bounds__(block_size, 1) void PinholePrincipalPointStackedToCaspar_kernel(
1354 const double* const __restrict__ stacked_data,
1355 double* const __restrict__ cas_data,
1356 const unsigned int cas_stride,
1357 const unsigned int cas_offset,
1358 const unsigned int num_objects) {
1359 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
1360 __shared__ double stacked_data_local[block_size * 2];
1361
1362 for (unsigned int target = (blockIdx.x * blockDim.x) * 2 + threadIdx.x;
1363 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 2;
1364 target += blockDim.x) {
1365 stacked_data_local[target - (blockIdx.x * blockDim.x) * 2] =
1366 stacked_data[target];
1367 }
1368
1369 __syncthreads();
1370
1371 if (global_thread_idx < num_objects) {
1372 double data[4] = {0, 0, 0, 0};
1373 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 2;
1374 double* out_ptr;
1375 data[0] = stacked_local_ptr[0];
1376 data[1] = stacked_local_ptr[1];
1377
1378 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
1379 reinterpret_cast<double2*>(out_ptr)[0] =
1380 reinterpret_cast<double2*>(data)[0];
1381 }
1382 }
1383
1384 __global__
1385 __launch_bounds__(block_size, 1) void PinholePrincipalPointCasparToStacked_kernel(
1386 const double* const __restrict__ cas_data,
1387 double* const __restrict__ stacked_data,
1388 const unsigned int cas_stride,
1389 const unsigned int cas_offset,
1390 const unsigned int num_objects) {
1391 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
1392 __shared__ double stacked_data_local[block_size * 2];
1393
1394 if (global_thread_idx < num_objects) {
1395 double data[4] = {0, 0, 0, 0};
1396 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 2;
1397 const double* in_ptr;
1398 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
1399 reinterpret_cast<double2*>(data)[0] =
1400 reinterpret_cast<const double2*>(in_ptr)[0];
1401 stacked_local_ptr[0] = data[0];
1402 stacked_local_ptr[1] = data[1];
1403 }
1404
1405 __syncthreads();
1406
1407 for (unsigned int target = (blockIdx.x * blockDim.x) * 2 + threadIdx.x;
1408 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 2;
1409 target += blockDim.x) {
1410 stacked_data[target] =
1411 stacked_data_local[target - (blockIdx.x * blockDim.x) * 2];
1412 }
1413 }
1414
1415 cudaError_t PinholePrincipalPointStackedToCaspar(
1416 const double* stacked_data,
1417 double* cas_data,
1418 const unsigned int cas_stride,
1419 const unsigned int cas_offset,
1420 const unsigned int num_objects) {
1421 const int num_blocks = (num_objects + block_size - 1) / block_size;
1422
1423 PinholePrincipalPointStackedToCaspar_kernel<<<num_blocks, block_size>>>(
1424 stacked_data, cas_data, cas_stride, cas_offset, num_objects);
1425
1426 return cudaGetLastError();
1427 }
1428
1429 cudaError_t PinholePrincipalPointCasparToStacked(
1430 const double* cas_data,
1431 double* stacked_data,
1432 const unsigned int cas_stride,
1433 const unsigned int cas_offset,
1434 const unsigned int num_objects) {
1435 const int num_blocks = (num_objects + block_size - 1) / block_size;
1436
1437 PinholePrincipalPointCasparToStacked_kernel<<<num_blocks, block_size>>>(
1438 cas_data, stacked_data, cas_stride, cas_offset, num_objects);
1439
1440 return cudaGetLastError();
1441 }
1442
1443 __global__ __launch_bounds__(block_size, 1) void PointStackedToCaspar_kernel(
1444 const double* const __restrict__ stacked_data,
1445 double* const __restrict__ cas_data,
1446 const unsigned int cas_stride,
1447 const unsigned int cas_offset,
1448 const unsigned int num_objects) {
1449 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
1450 __shared__ double stacked_data_local[block_size * 3];
1451
1452 for (unsigned int target = (blockIdx.x * blockDim.x) * 3 + threadIdx.x;
1453 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 3;
1454 target += blockDim.x) {
1455 stacked_data_local[target - (blockIdx.x * blockDim.x) * 3] =
1456 stacked_data[target];
1457 }
1458
1459 __syncthreads();
1460
1461 if (global_thread_idx < num_objects) {
1462 double data[4] = {0, 0, 0, 0};
1463 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 3;
1464 double* out_ptr;
1465 data[0] = stacked_local_ptr[0];
1466 data[1] = stacked_local_ptr[1];
1467
1468 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
1469 reinterpret_cast<double2*>(out_ptr)[0] =
1470 reinterpret_cast<double2*>(data)[0];
1471 data[0] = stacked_local_ptr[2];
1472
1473 out_ptr = cas_data + 1 * (global_thread_idx + cas_offset) + 2 * cas_stride;
1474 out_ptr[0] = data[0];
1475 }
1476 }
1477
1478 __global__ __launch_bounds__(block_size, 1) void PointCasparToStacked_kernel(
1479 const double* const __restrict__ cas_data,
1480 double* const __restrict__ stacked_data,
1481 const unsigned int cas_stride,
1482 const unsigned int cas_offset,
1483 const unsigned int num_objects) {
1484 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
1485 __shared__ double stacked_data_local[block_size * 3];
1486
1487 if (global_thread_idx < num_objects) {
1488 double data[4] = {0, 0, 0, 0};
1489 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 3;
1490 const double* in_ptr;
1491 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
1492 reinterpret_cast<double2*>(data)[0] =
1493 reinterpret_cast<const double2*>(in_ptr)[0];
1494 stacked_local_ptr[0] = data[0];
1495 stacked_local_ptr[1] = data[1];
1496 in_ptr = cas_data + 1 * (global_thread_idx + cas_offset) + 2 * cas_stride;
1497 data[0] = in_ptr[0];
1498 stacked_local_ptr[2] = data[0];
1499 }
1500
1501 __syncthreads();
1502
1503 for (unsigned int target = (blockIdx.x * blockDim.x) * 3 + threadIdx.x;
1504 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 3;
1505 target += blockDim.x) {
1506 stacked_data[target] =
1507 stacked_data_local[target - (blockIdx.x * blockDim.x) * 3];
1508 }
1509 }
1510
1511 cudaError_t PointStackedToCaspar(const double* stacked_data,
1512 double* cas_data,
1513 const unsigned int cas_stride,
1514 const unsigned int cas_offset,
1515 const unsigned int num_objects) {
1516 const int num_blocks = (num_objects + block_size - 1) / block_size;
1517
1518 PointStackedToCaspar_kernel<<<num_blocks, block_size>>>(
1519 stacked_data, cas_data, cas_stride, cas_offset, num_objects);
1520
1521 return cudaGetLastError();
1522 }
1523
1524 cudaError_t PointCasparToStacked(const double* cas_data,
1525 double* stacked_data,
1526 const unsigned int cas_stride,
1527 const unsigned int cas_offset,
1528 const unsigned int num_objects) {
1529 const int num_blocks = (num_objects + block_size - 1) / block_size;
1530
1531 PointCasparToStacked_kernel<<<num_blocks, block_size>>>(
1532 cas_data, stacked_data, cas_stride, cas_offset, num_objects);
1533
1534 return cudaGetLastError();
1535 }
1536
1537 __global__
1538 __launch_bounds__(block_size, 1) void SimpleRadialCalibStackedToCaspar_kernel(
1539 const double* const __restrict__ stacked_data,
1540 double* const __restrict__ cas_data,
1541 const unsigned int cas_stride,
1542 const unsigned int cas_offset,
1543 const unsigned int num_objects) {
1544 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
1545 __shared__ double stacked_data_local[block_size * 4];
1546
1547 for (unsigned int target = (blockIdx.x * blockDim.x) * 4 + threadIdx.x;
1548 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 4;
1549 target += blockDim.x) {
1550 stacked_data_local[target - (blockIdx.x * blockDim.x) * 4] =
1551 stacked_data[target];
1552 }
1553
1554 __syncthreads();
1555
1556 if (global_thread_idx < num_objects) {
1557 double data[4] = {0, 0, 0, 0};
1558 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 4;
1559 double* out_ptr;
1560 data[0] = stacked_local_ptr[0];
1561 data[1] = stacked_local_ptr[1];
1562
1563 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
1564 reinterpret_cast<double2*>(out_ptr)[0] =
1565 reinterpret_cast<double2*>(data)[0];
1566 data[0] = stacked_local_ptr[2];
1567 data[1] = stacked_local_ptr[3];
1568
1569 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 2 * cas_stride;
1570 reinterpret_cast<double2*>(out_ptr)[0] =
1571 reinterpret_cast<double2*>(data)[0];
1572 }
1573 }
1574
1575 __global__
1576 __launch_bounds__(block_size, 1) void SimpleRadialCalibCasparToStacked_kernel(
1577 const double* const __restrict__ cas_data,
1578 double* const __restrict__ stacked_data,
1579 const unsigned int cas_stride,
1580 const unsigned int cas_offset,
1581 const unsigned int num_objects) {
1582 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
1583 __shared__ double stacked_data_local[block_size * 4];
1584
1585 if (global_thread_idx < num_objects) {
1586 double data[4] = {0, 0, 0, 0};
1587 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 4;
1588 const double* in_ptr;
1589 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
1590 reinterpret_cast<double2*>(data)[0] =
1591 reinterpret_cast<const double2*>(in_ptr)[0];
1592 stacked_local_ptr[0] = data[0];
1593 stacked_local_ptr[1] = data[1];
1594 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 2 * cas_stride;
1595 reinterpret_cast<double2*>(data)[0] =
1596 reinterpret_cast<const double2*>(in_ptr)[0];
1597 stacked_local_ptr[2] = data[0];
1598 stacked_local_ptr[3] = data[1];
1599 }
1600
1601 __syncthreads();
1602
1603 for (unsigned int target = (blockIdx.x * blockDim.x) * 4 + threadIdx.x;
1604 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 4;
1605 target += blockDim.x) {
1606 stacked_data[target] =
1607 stacked_data_local[target - (blockIdx.x * blockDim.x) * 4];
1608 }
1609 }
1610
1611 cudaError_t SimpleRadialCalibStackedToCaspar(const double* stacked_data,
1612 double* cas_data,
1613 const unsigned int cas_stride,
1614 const unsigned int cas_offset,
1615 const unsigned int num_objects) {
1616 const int num_blocks = (num_objects + block_size - 1) / block_size;
1617
1618 SimpleRadialCalibStackedToCaspar_kernel<<<num_blocks, block_size>>>(
1619 stacked_data, cas_data, cas_stride, cas_offset, num_objects);
1620
1621 return cudaGetLastError();
1622 }
1623
1624 cudaError_t SimpleRadialCalibCasparToStacked(const double* cas_data,
1625 double* stacked_data,
1626 const unsigned int cas_stride,
1627 const unsigned int cas_offset,
1628 const unsigned int num_objects) {
1629 const int num_blocks = (num_objects + block_size - 1) / block_size;
1630
1631 SimpleRadialCalibCasparToStacked_kernel<<<num_blocks, block_size>>>(
1632 cas_data, stacked_data, cas_stride, cas_offset, num_objects);
1633
1634 return cudaGetLastError();
1635 }
1636
1637 __global__
1638 __launch_bounds__(block_size, 1) void SimpleRadialFocalAndExtraStackedToCaspar_kernel(
1639 const double* const __restrict__ stacked_data,
1640 double* const __restrict__ cas_data,
1641 const unsigned int cas_stride,
1642 const unsigned int cas_offset,
1643 const unsigned int num_objects) {
1644 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
1645 __shared__ double stacked_data_local[block_size * 2];
1646
1647 for (unsigned int target = (blockIdx.x * blockDim.x) * 2 + threadIdx.x;
1648 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 2;
1649 target += blockDim.x) {
1650 stacked_data_local[target - (blockIdx.x * blockDim.x) * 2] =
1651 stacked_data[target];
1652 }
1653
1654 __syncthreads();
1655
1656 if (global_thread_idx < num_objects) {
1657 double data[4] = {0, 0, 0, 0};
1658 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 2;
1659 double* out_ptr;
1660 data[0] = stacked_local_ptr[0];
1661 data[1] = stacked_local_ptr[1];
1662
1663 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
1664 reinterpret_cast<double2*>(out_ptr)[0] =
1665 reinterpret_cast<double2*>(data)[0];
1666 }
1667 }
1668
1669 __global__
1670 __launch_bounds__(block_size, 1) void SimpleRadialFocalAndExtraCasparToStacked_kernel(
1671 const double* const __restrict__ cas_data,
1672 double* const __restrict__ stacked_data,
1673 const unsigned int cas_stride,
1674 const unsigned int cas_offset,
1675 const unsigned int num_objects) {
1676 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
1677 __shared__ double stacked_data_local[block_size * 2];
1678
1679 if (global_thread_idx < num_objects) {
1680 double data[4] = {0, 0, 0, 0};
1681 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 2;
1682 const double* in_ptr;
1683 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
1684 reinterpret_cast<double2*>(data)[0] =
1685 reinterpret_cast<const double2*>(in_ptr)[0];
1686 stacked_local_ptr[0] = data[0];
1687 stacked_local_ptr[1] = data[1];
1688 }
1689
1690 __syncthreads();
1691
1692 for (unsigned int target = (blockIdx.x * blockDim.x) * 2 + threadIdx.x;
1693 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 2;
1694 target += blockDim.x) {
1695 stacked_data[target] =
1696 stacked_data_local[target - (blockIdx.x * blockDim.x) * 2];
1697 }
1698 }
1699
1700 cudaError_t SimpleRadialFocalAndExtraStackedToCaspar(
1701 const double* stacked_data,
1702 double* cas_data,
1703 const unsigned int cas_stride,
1704 const unsigned int cas_offset,
1705 const unsigned int num_objects) {
1706 const int num_blocks = (num_objects + block_size - 1) / block_size;
1707
1708 SimpleRadialFocalAndExtraStackedToCaspar_kernel<<<num_blocks, block_size>>>(
1709 stacked_data, cas_data, cas_stride, cas_offset, num_objects);
1710
1711 return cudaGetLastError();
1712 }
1713
1714 cudaError_t SimpleRadialFocalAndExtraCasparToStacked(
1715 const double* cas_data,
1716 double* stacked_data,
1717 const unsigned int cas_stride,
1718 const unsigned int cas_offset,
1719 const unsigned int num_objects) {
1720 const int num_blocks = (num_objects + block_size - 1) / block_size;
1721
1722 SimpleRadialFocalAndExtraCasparToStacked_kernel<<<num_blocks, block_size>>>(
1723 cas_data, stacked_data, cas_stride, cas_offset, num_objects);
1724
1725 return cudaGetLastError();
1726 }
1727
1728 __global__
1729 __launch_bounds__(block_size, 1) void SimpleRadialPoseStackedToCaspar_kernel(
1730 const double* const __restrict__ stacked_data,
1731 double* const __restrict__ cas_data,
1732 const unsigned int cas_stride,
1733 const unsigned int cas_offset,
1734 const unsigned int num_objects) {
1735 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
1736 __shared__ double stacked_data_local[block_size * 7];
1737
1738 for (unsigned int target = (blockIdx.x * blockDim.x) * 7 + threadIdx.x;
1739 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 7;
1740 target += blockDim.x) {
1741 stacked_data_local[target - (blockIdx.x * blockDim.x) * 7] =
1742 stacked_data[target];
1743 }
1744
1745 __syncthreads();
1746
1747 if (global_thread_idx < num_objects) {
1748 double data[4] = {0, 0, 0, 0};
1749 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 7;
1750 double* out_ptr;
1751 data[0] = stacked_local_ptr[0];
1752 data[1] = stacked_local_ptr[1];
1753
1754 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
1755 reinterpret_cast<double2*>(out_ptr)[0] =
1756 reinterpret_cast<double2*>(data)[0];
1757 data[0] = stacked_local_ptr[2];
1758 data[1] = stacked_local_ptr[3];
1759
1760 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 2 * cas_stride;
1761 reinterpret_cast<double2*>(out_ptr)[0] =
1762 reinterpret_cast<double2*>(data)[0];
1763 data[0] = stacked_local_ptr[4];
1764 data[1] = stacked_local_ptr[5];
1765
1766 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 4 * cas_stride;
1767 reinterpret_cast<double2*>(out_ptr)[0] =
1768 reinterpret_cast<double2*>(data)[0];
1769 data[0] = stacked_local_ptr[6];
1770
1771 out_ptr = cas_data + 1 * (global_thread_idx + cas_offset) + 6 * cas_stride;
1772 out_ptr[0] = data[0];
1773 }
1774 }
1775
1776 __global__
1777 __launch_bounds__(block_size, 1) void SimpleRadialPoseCasparToStacked_kernel(
1778 const double* const __restrict__ cas_data,
1779 double* const __restrict__ stacked_data,
1780 const unsigned int cas_stride,
1781 const unsigned int cas_offset,
1782 const unsigned int num_objects) {
1783 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
1784 __shared__ double stacked_data_local[block_size * 7];
1785
1786 if (global_thread_idx < num_objects) {
1787 double data[4] = {0, 0, 0, 0};
1788 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 7;
1789 const double* in_ptr;
1790 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
1791 reinterpret_cast<double2*>(data)[0] =
1792 reinterpret_cast<const double2*>(in_ptr)[0];
1793 stacked_local_ptr[0] = data[0];
1794 stacked_local_ptr[1] = data[1];
1795 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 2 * cas_stride;
1796 reinterpret_cast<double2*>(data)[0] =
1797 reinterpret_cast<const double2*>(in_ptr)[0];
1798 stacked_local_ptr[2] = data[0];
1799 stacked_local_ptr[3] = data[1];
1800 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 4 * cas_stride;
1801 reinterpret_cast<double2*>(data)[0] =
1802 reinterpret_cast<const double2*>(in_ptr)[0];
1803 stacked_local_ptr[4] = data[0];
1804 stacked_local_ptr[5] = data[1];
1805 in_ptr = cas_data + 1 * (global_thread_idx + cas_offset) + 6 * cas_stride;
1806 data[0] = in_ptr[0];
1807 stacked_local_ptr[6] = data[0];
1808 }
1809
1810 __syncthreads();
1811
1812 for (unsigned int target = (blockIdx.x * blockDim.x) * 7 + threadIdx.x;
1813 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 7;
1814 target += blockDim.x) {
1815 stacked_data[target] =
1816 stacked_data_local[target - (blockIdx.x * blockDim.x) * 7];
1817 }
1818 }
1819
1820 cudaError_t SimpleRadialPoseStackedToCaspar(const double* stacked_data,
1821 double* cas_data,
1822 const unsigned int cas_stride,
1823 const unsigned int cas_offset,
1824 const unsigned int num_objects) {
1825 const int num_blocks = (num_objects + block_size - 1) / block_size;
1826
1827 SimpleRadialPoseStackedToCaspar_kernel<<<num_blocks, block_size>>>(
1828 stacked_data, cas_data, cas_stride, cas_offset, num_objects);
1829
1830 return cudaGetLastError();
1831 }
1832
1833 cudaError_t SimpleRadialPoseCasparToStacked(const double* cas_data,
1834 double* stacked_data,
1835 const unsigned int cas_stride,
1836 const unsigned int cas_offset,
1837 const unsigned int num_objects) {
1838 const int num_blocks = (num_objects + block_size - 1) / block_size;
1839
1840 SimpleRadialPoseCasparToStacked_kernel<<<num_blocks, block_size>>>(
1841 cas_data, stacked_data, cas_stride, cas_offset, num_objects);
1842
1843 return cudaGetLastError();
1844 }
1845
1846 __global__
1847 __launch_bounds__(block_size, 1) void SimpleRadialPrincipalPointStackedToCaspar_kernel(
1848 const double* const __restrict__ stacked_data,
1849 double* const __restrict__ cas_data,
1850 const unsigned int cas_stride,
1851 const unsigned int cas_offset,
1852 const unsigned int num_objects) {
1853 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
1854 __shared__ double stacked_data_local[block_size * 2];
1855
1856 for (unsigned int target = (blockIdx.x * blockDim.x) * 2 + threadIdx.x;
1857 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 2;
1858 target += blockDim.x) {
1859 stacked_data_local[target - (blockIdx.x * blockDim.x) * 2] =
1860 stacked_data[target];
1861 }
1862
1863 __syncthreads();
1864
1865 if (global_thread_idx < num_objects) {
1866 double data[4] = {0, 0, 0, 0};
1867 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 2;
1868 double* out_ptr;
1869 data[0] = stacked_local_ptr[0];
1870 data[1] = stacked_local_ptr[1];
1871
1872 out_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
1873 reinterpret_cast<double2*>(out_ptr)[0] =
1874 reinterpret_cast<double2*>(data)[0];
1875 }
1876 }
1877
1878 __global__
1879 __launch_bounds__(block_size, 1) void SimpleRadialPrincipalPointCasparToStacked_kernel(
1880 const double* const __restrict__ cas_data,
1881 double* const __restrict__ stacked_data,
1882 const unsigned int cas_stride,
1883 const unsigned int cas_offset,
1884 const unsigned int num_objects) {
1885 const unsigned int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
1886 __shared__ double stacked_data_local[block_size * 2];
1887
1888 if (global_thread_idx < num_objects) {
1889 double data[4] = {0, 0, 0, 0};
1890 double* stacked_local_ptr = stacked_data_local + threadIdx.x * 2;
1891 const double* in_ptr;
1892 in_ptr = cas_data + 2 * (global_thread_idx + cas_offset) + 0 * cas_stride;
1893 reinterpret_cast<double2*>(data)[0] =
1894 reinterpret_cast<const double2*>(in_ptr)[0];
1895 stacked_local_ptr[0] = data[0];
1896 stacked_local_ptr[1] = data[1];
1897 }
1898
1899 __syncthreads();
1900
1901 for (unsigned int target = (blockIdx.x * blockDim.x) * 2 + threadIdx.x;
1902 target < min(num_objects, (blockIdx.x + 1) * blockDim.x) * 2;
1903 target += blockDim.x) {
1904 stacked_data[target] =
1905 stacked_data_local[target - (blockIdx.x * blockDim.x) * 2];
1906 }
1907 }
1908
1909 cudaError_t SimpleRadialPrincipalPointStackedToCaspar(
1910 const double* stacked_data,
1911 double* cas_data,
1912 const unsigned int cas_stride,
1913 const unsigned int cas_offset,
1914 const unsigned int num_objects) {
1915 const int num_blocks = (num_objects + block_size - 1) / block_size;
1916
1917 SimpleRadialPrincipalPointStackedToCaspar_kernel<<<num_blocks, block_size>>>(
1918 stacked_data, cas_data, cas_stride, cas_offset, num_objects);
1919
1920 return cudaGetLastError();
1921 }
1922
1923 cudaError_t SimpleRadialPrincipalPointCasparToStacked(
1924 const double* cas_data,
1925 double* stacked_data,
1926 const unsigned int cas_stride,
1927 const unsigned int cas_offset,
1928 const unsigned int num_objects) {
1929 const int num_blocks = (num_objects + block_size - 1) / block_size;
1930
1931 SimpleRadialPrincipalPointCasparToStacked_kernel<<<num_blocks, block_size>>>(
1932 cas_data, stacked_data, cas_stride, cas_offset, num_objects);
1933
1934 return cudaGetLastError();
1935 }
1936
1937 } // namespace caspar