Static and dynamic approaches to data mapping optimization in heterogeneous programs