Compute a same-length 1-D convolution with zero padding on the GPU. Given an input vector x of length n and a symmetric kernel of radius R (so the kernel has 2*R + 1 taps), produce y of length n where
and whenever or .
Each output needs a neighborhood of inputs. Your kernel must load that neighborhood through shared memory, including a halo of elements on each side of the block, so interior values are fetched from global memory once per block rather than once per neighbor.
Complete:
__global__ kernel that performs the halo-loaded convolution.void solve(const float* input, const float* kernel, float* output, int n, int radius) where every pointer is a host pointer. input and output have n elements; kernel has 2*radius+1 elements. Allocate, copy in, launch, copy out, and free.Constraints: 1 <= n <= 1024, 1 <= radius <= 8. Do not write a main() in your solution.