Multiply an matrix by a vector of length on the GPU:
A is stored row-major as a flat float array: is at index i * N + j. Assign one thread per output row: thread walks row of and accumulates the dot product with in a register, then writes once.
Complete:
__global__ kernel with one thread per row and a bounds check on i < M.void matvec(const float* A, const float* x, float* y, int M, int N) where all pointers are host pointers (A has M * N elements, x has N, y has M). Allocate, copy in, launch with enough blocks to cover M rows, copy y back and free.. Do not write a main() in your solution.