compute residuals in parallel