D2P: From recursive formulations to distributed-memory codes