Automated Runtime Analysis And Adaptation For Scalable Heterogeneous Computing