eclipse / xacc

XACC - eXtreme-scale Accelerator programming framework
https://xacc.readthedocs.io
BSD 3-Clause "New" or "Revised" License
163 stars 84 forks source link

Move back MPI Init/Finalize to within HPC Virtualization #551

Open 1tnguyen opened 1 year ago

1tnguyen commented 1 year ago

A top-level MPI_Init at XACC Initialize() is not ideal since we may want to use an MPI-enabled backend (without HPC Virtualization) => a global MPI_Init at XACC::Initialize() could be problematic. Hence, move it back within the scope of HPCVirt decorator.

Fixing an MPI_Finalize race condition issue when ExaTN MPI is present within the installation. ExaTN has exatnInitializedMPI variable to determine if it should do the MPI_Finalize step, hence HPC Virt should have the same mechanism to prevent HPC Virt from finalizing MPI pre-maturely and causing MPI errors during ExaTN::Finalize() which could call MPI API's

1tnguyen commented 1 year ago

@danclaudino Could you please review this PR? This is trying to fix the MPI API usage after Finalize and an issue with double MPI_Init in some cases.