Optimizing Data-Parallel Programs Using the BSP Cost Model