Compacting compute grid code into macro