| 1 |
#include "kernel_Point_retract.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 |
PointRetractKernel(float* Point, |
| 15 |
unsigned int Point_num_alloc, |
| 16 |
float* delta, |
| 17 |
unsigned int delta_num_alloc, |
| 18 |
float* out_Point_retracted, |
| 19 |
unsigned int out_Point_retracted_num_alloc, |
| 20 |
size_t problem_size) { |
| 21 |
const int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x; |
| 22 |
|
| 23 |
float r0, r1, r2, r3, r4, r5; |
| 24 |
|
| 25 |
if (global_thread_idx < problem_size) { |
| 26 |
ReadIdx3<1024, float, float, float4>( |
| 27 |
Point, 0 * Point_num_alloc, global_thread_idx, r0, r1, r2); |
| 28 |
ReadIdx3<1024, float, float, float4>( |
| 29 |
delta, 0 * delta_num_alloc, global_thread_idx, r3, r4, r5); |
| 30 |
r3 = r0 + r3; |
| 31 |
r4 = r1 + r4; |
| 32 |
r5 = r2 + r5; |
| 33 |
WriteIdx3<1024, float, float, float4>(out_Point_retracted, |
| 34 |
0 * out_Point_retracted_num_alloc, |
| 35 |
global_thread_idx, |
| 36 |
r3, |
| 37 |
r4, |
| 38 |
r5); |
| 39 |
}; |
| 40 |
} |
| 41 |
|
| 42 |
void PointRetract(float* Point, |
| 43 |
unsigned int Point_num_alloc, |
| 44 |
float* delta, |
| 45 |
unsigned int delta_num_alloc, |
| 46 |
float* out_Point_retracted, |
| 47 |
unsigned int out_Point_retracted_num_alloc, |
| 48 |
size_t problem_size) { |
| 49 |
if (problem_size == 0) { |
| 50 |
return; |
| 51 |
} |
| 52 |
|
| 53 |
const int n_blocks = (problem_size + 1024 - 1) / 1024; |
| 54 |
PointRetractKernel<<<n_blocks, 1024>>>(Point, |
| 55 |
Point_num_alloc, |
| 56 |
delta, |
| 57 |
delta_num_alloc, |
| 58 |
out_Point_retracted, |
| 59 |
out_Point_retracted_num_alloc, |
| 60 |
problem_size); |
| 61 |
} |
| 62 |
|
| 63 |
} // namespace caspar |