Implement a CUDA function that computes the sum of all elements in a float array using a parallel reduction. Your kernel must use shared memory and __syncthreads() to reduce each block's data, and combine block results into a single total.
Write:
__global__ kernel that performs the reduction.void solve(const float* input, float* output, int N) where input and output are HOST pointers. output points to a single float that must receive the total sum. The host function must allocate device memory, copy data to the device, launch the kernel, copy the result back, and free device memory.Do not write a main() in your solution.