Terra : simplifying high-performance programming using multi-stage programming