From 408475f98550c7f92fc46d608a945a2497f4b6a8 Mon Sep 17 00:00:00 2001 From: Tomas Farago Date: Thu, 5 Mar 2020 15:12:02 +0100 Subject: complex: add c_abs_squared kernel --- src/kernels/complex.cl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/kernels/complex.cl b/src/kernels/complex.cl index 93c0f02..26cc180 100644 --- a/src/kernels/complex.cl +++ b/src/kernels/complex.cl @@ -71,6 +71,19 @@ c_conj (global float *data, out[idx+1] = -data[idx+1]; } +kernel void +c_abs_squared (global float *data, + global float *out) +{ + int y = get_global_id (1) * 2 * get_global_size (0); + int in_idx = y + 2 * get_global_id(0); + int out_idx = y + get_global_id(0); + + /* Store the results in the horizontally first half of the complex *out* + * array, so the result of this should be cropped to half the input width. */ + out[out_idx] = data[in_idx] * data[in_idx] + data[in_idx + 1] * data[in_idx + 1]; +} + /** * c_mul_real_sym: * @frequencies: complex Fourier transform frequencies with interleaved -- cgit v1.2.1