| 1 |
#include "kernel_Point_update_step_first.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) |
| 14 |
PointUpdateStepFirstKernel(float* Point_p_kp1, |
| 15 |
unsigned int Point_p_kp1_num_alloc, |
| 16 |
const float* const alpha, |
| 17 |
float* out_Point_step_kp1, |
| 18 |
unsigned int out_Point_step_kp1_num_alloc, |
| 19 |
size_t problem_size) { |
| 20 |
const int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x; |
| 21 |
__shared__ uint8_t inout_shared[4096]; |
| 22 |
|
| 23 |
float r0, r1, r2, r3; |
| 24 |
|
| 25 |
if (global_thread_idx < problem_size) { |
| 26 |
ReadIdx3<1024, float, float, float4>( |
| 27 |
Point_p_kp1, 0 * Point_p_kp1_num_alloc, global_thread_idx, r0, r1, r2); |
| 28 |
}; |
| 29 |
LoadUnique<1, float, float>(alpha, 0, (float*)inout_shared); |
| 30 |
if (global_thread_idx < problem_size) { |
| 31 |
ReadShared1<float>((float*)inout_shared, 0, r3); |
| 32 |
}; |
| 33 |
__syncthreads(); |
| 34 |
if (global_thread_idx < problem_size) { |
| 35 |
r0 = r0 * r3; |
| 36 |
r1 = r1 * r3; |
| 37 |
r3 = r2 * r3; |
| 38 |
WriteIdx3<1024, float, float, float4>(out_Point_step_kp1, |
| 39 |
0 * out_Point_step_kp1_num_alloc, |
| 40 |
global_thread_idx, |
| 41 |
r0, |
| 42 |
r1, |
| 43 |
r3); |
| 44 |
}; |
| 45 |
} |
| 46 |
|
| 47 |
void PointUpdateStepFirst(float* Point_p_kp1, |
| 48 |
unsigned int Point_p_kp1_num_alloc, |
| 49 |
const float* const alpha, |
| 50 |
float* out_Point_step_kp1, |
| 51 |
unsigned int out_Point_step_kp1_num_alloc, |
| 52 |
size_t problem_size) { |
| 53 |
if (problem_size == 0) { |
| 54 |
return; |
| 55 |
} |
| 56 |
|
| 57 |
const int n_blocks = (problem_size + 1024 - 1) / 1024; |
| 58 |
PointUpdateStepFirstKernel<<<n_blocks, 1024>>>(Point_p_kp1, |
| 59 |
Point_p_kp1_num_alloc, |
| 60 |
alpha, |
| 61 |
out_Point_step_kp1, |
| 62 |
out_Point_step_kp1_num_alloc, |
| 63 |
problem_size); |
| 64 |
} |
| 65 |
|
| 66 |
} // namespace caspar |