Parallel apply function using MPI