Debian Codegraph @

src/thirdparty/Symforce-Caspar/generated/f32/kernel_PinholeFocal_update_step.cu

raw
1 #include "kernel_PinholeFocal_update_step.h"
2 #include "memops.cuh"
3 #include <cooperative_groups.h>
4 #include <cooperative_groups/details/partitioning.h>
5 #include <cooperative_groups/memcpy_async.h>
6 #include <cooperative_groups/reduce.h>
7 #include <cuda_runtime.h>
8
9 namespace cg = cooperative_groups;
10
11 namespace caspar {
12
13 __global__ void __launch_bounds__(1024, 1) PinholeFocalUpdateStepKernel(
14 float* PinholeFocal_step_k,
15 unsigned int PinholeFocal_step_k_num_alloc,
16 float* PinholeFocal_p_kp1,
17 unsigned int PinholeFocal_p_kp1_num_alloc,
18 const float* const alpha,
19 float* out_PinholeFocal_step_kp1,
20 unsigned int out_PinholeFocal_step_kp1_num_alloc,
21 size_t problem_size) {
22 const int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x;
23 __shared__ uint8_t inout_shared[4096];
24
25 float r0, r1, r2, r3, r4;
26
27 if (global_thread_idx < problem_size) {
28 ReadIdx2<1024, float, float, float2>(PinholeFocal_step_k,
29 0 * PinholeFocal_step_k_num_alloc,
30 global_thread_idx,
31 r0,
32 r1);
33 ReadIdx2<1024, float, float, float2>(PinholeFocal_p_kp1,
34 0 * PinholeFocal_p_kp1_num_alloc,
35 global_thread_idx,
36 r2,
37 r3);
38 };
39 LoadUnique<1, float, float>(alpha, 0, (float*)inout_shared);
40 if (global_thread_idx < problem_size) {
41 ReadShared1<float>((float*)inout_shared, 0, r4);
42 };
43 __syncthreads();
44 if (global_thread_idx < problem_size) {
45 r2 = fmaf(r2, r4, r0);
46 r4 = fmaf(r3, r4, r1);
47 WriteIdx2<1024, float, float, float2>(
48 out_PinholeFocal_step_kp1,
49 0 * out_PinholeFocal_step_kp1_num_alloc,
50 global_thread_idx,
51 r2,
52 r4);
53 };
54 }
55
56 void PinholeFocalUpdateStep(float* PinholeFocal_step_k,
57 unsigned int PinholeFocal_step_k_num_alloc,
58 float* PinholeFocal_p_kp1,
59 unsigned int PinholeFocal_p_kp1_num_alloc,
60 const float* const alpha,
61 float* out_PinholeFocal_step_kp1,
62 unsigned int out_PinholeFocal_step_kp1_num_alloc,
63 size_t problem_size) {
64 if (problem_size == 0) {
65 return;
66 }
67
68 const int n_blocks = (problem_size + 1024 - 1) / 1024;
69 PinholeFocalUpdateStepKernel<<<n_blocks, 1024>>>(
70 PinholeFocal_step_k,
71 PinholeFocal_step_k_num_alloc,
72 PinholeFocal_p_kp1,
73 PinholeFocal_p_kp1_num_alloc,
74 alpha,
75 out_PinholeFocal_step_kp1,
76 out_PinholeFocal_step_kp1_num_alloc,
77 problem_size);
78 }
79
80 } // namespace caspar