Debian Codegraph @

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