Transpose an matrix into an matrix on the GPU:
Both matrices are stored row-major as flat float arrays: is at index i * N + j, and is at index j * M + i.
A naive one-thread-per-element write turns a coalesced row read into a strided column write. Your kernel must restage each tile through shared memory so that both the load from and the store to are coalesced. Handle shapes that are not multiples of the tile size; out-of-range threads must not read or write.
Complete:
__global__ kernel that performs the tiled transpose.void solve(const float* A, float* B, int M, int N) where A and B are host pointers (A has M * N elements, B has N * M). Allocate device memory, copy in, launch, copy out, and free.Constraints: 1 <= M, N <= 64. Do not write a main() in your solution.