| 1 |
#include "kernel_Point_pred_decrease_times_two.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 |
PointPredDecreaseTimesTwoKernel(float* Point_step, |
| 15 |
unsigned int Point_step_num_alloc, |
| 16 |
float* Point_precond_diag, |
| 17 |
unsigned int Point_precond_diag_num_alloc, |
| 18 |
const float* const diag, |
| 19 |
float* Point_njtr, |
| 20 |
unsigned int Point_njtr_num_alloc, |
| 21 |
float* const out_Point_pred_dec, |
| 22 |
size_t problem_size) { |
| 23 |
const int global_thread_idx = blockIdx.x * blockDim.x + threadIdx.x; |
| 24 |
__shared__ uint8_t inout_shared[4096]; |
| 25 |
|
| 26 |
__shared__ float out_Point_pred_dec_local[1]; |
| 27 |
|
| 28 |
float r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10; |
| 29 |
|
| 30 |
if (global_thread_idx < problem_size) { |
| 31 |
ReadIdx3<1024, float, float, float4>( |
| 32 |
Point_step, 0 * Point_step_num_alloc, global_thread_idx, r0, r1, r2); |
| 33 |
ReadIdx3<1024, float, float, float4>( |
| 34 |
Point_njtr, 0 * Point_njtr_num_alloc, global_thread_idx, r3, r4, r5); |
| 35 |
ReadIdx3<1024, float, float, float4>(Point_precond_diag, |
| 36 |
0 * Point_precond_diag_num_alloc, |
| 37 |
global_thread_idx, |
| 38 |
r6, |
| 39 |
r7, |
| 40 |
r8); |
| 41 |
r9 = r2 * r8; |
| 42 |
}; |
| 43 |
LoadUnique<1, float, float>(diag, 0, (float*)inout_shared); |
| 44 |
if (global_thread_idx < problem_size) { |
| 45 |
ReadShared1<float>((float*)inout_shared, 0, r10); |
| 46 |
}; |
| 47 |
__syncthreads(); |
| 48 |
if (global_thread_idx < problem_size) { |
| 49 |
r9 = fmaf(r10, r9, r5); |
| 50 |
r5 = r0 * r6; |
| 51 |
r5 = fmaf(r10, r5, r3); |
| 52 |
r5 = fmaf(r0, r5, r2 * r9); |
| 53 |
r9 = r1 * r7; |
| 54 |
r9 = fmaf(r10, r9, r4); |
| 55 |
r5 = fmaf(r1, r9, r5); |
| 56 |
}; |
| 57 |
SumStore<float>(out_Point_pred_dec_local, |
| 58 |
(float*)inout_shared, |
| 59 |
0, |
| 60 |
global_thread_idx < problem_size, |
| 61 |
r5); |
| 62 |
SumFlushFinal<float>(out_Point_pred_dec_local, out_Point_pred_dec, 1); |
| 63 |
} |
| 64 |
|
| 65 |
void PointPredDecreaseTimesTwo(float* Point_step, |
| 66 |
unsigned int Point_step_num_alloc, |
| 67 |
float* Point_precond_diag, |
| 68 |
unsigned int Point_precond_diag_num_alloc, |
| 69 |
const float* const diag, |
| 70 |
float* Point_njtr, |
| 71 |
unsigned int Point_njtr_num_alloc, |
| 72 |
float* const out_Point_pred_dec, |
| 73 |
size_t problem_size) { |
| 74 |
if (problem_size == 0) { |
| 75 |
return; |
| 76 |
} |
| 77 |
|
| 78 |
const int n_blocks = (problem_size + 1024 - 1) / 1024; |
| 79 |
PointPredDecreaseTimesTwoKernel<<<n_blocks, 1024>>>( |
| 80 |
Point_step, |
| 81 |
Point_step_num_alloc, |
| 82 |
Point_precond_diag, |
| 83 |
Point_precond_diag_num_alloc, |
| 84 |
diag, |
| 85 |
Point_njtr, |
| 86 |
Point_njtr_num_alloc, |
| 87 |
out_Point_pred_dec, |
| 88 |
problem_size); |
| 89 |
} |
| 90 |
|
| 91 |
} // namespace caspar |