Updated version of heat_stencil and matmul_optimized