Sum a float array on the GPU and return the total in a single output scalar. Unlike a shared-memory tree reduction, the intra-warp combination must use the warp shuffle intrinsic __shfl_down_sync so neighboring lanes exchange values through registers rather than through shared memory.
A warp has 32 lanes. A down-shuffle with offset lets lane receive the register value from lane (inactive / out-of-range lanes contribute as if the source were itself). Repeating with reduces 32 values onto lane 0 of that warp. Multiple warps in a block still need a small shared-memory staging step so their warp totals can be combined; multiple blocks must combine into one global sum (an atomicAdd onto a zeroed device scalar is enough).
Complete:
__global__ kernel that reduces with __shfl_down_sync inside each warp.void solve(const float* x, float* out, int n) where x and out are host pointers. out is a single float. Allocate, copy in, launch, copy out, and free.Constraints: 1 <= n <= 4096. Do not write a main() in your solution.