Code Generation and Optimization of Graph Programs on a Manycore Architecture