Explain the difference between shared memory and global memory in a GPU, and how would you leverage them to optimize a matrix multiplication kernel?