optimize the warmup using mpi and some refactoring