Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: remove comm_2D from Parallel_2D (Useful Information: BLACS encapsulates MPI and maintains its own internal data structure for MPI communicators) #4658

Merged
merged 10 commits into from
Jul 12, 2024

Conversation

jinzx10
Copy link
Collaborator

@jinzx10 jinzx10 commented Jul 11, 2024

BLACS encapsulates MPI and maintains its own internal data structure for MPI communicators, and it is inadvisable to have MPI and BLACS functions intertwined. Given a BLACS context, one can always obtain its underlying MPI communicator via blacs_get followed by blacs2sys_handle. So, in theory, in the presence of a BLACS context, there's no need to hold its underlying MPI communicator explicitly. Maintaining both the BLACS context and its underlying MPI communicator within the same class not only cause confusion, but also make it bug-prone if not synchronized appropriately. This is particularly troublesome given that they are both public members and widely used in the code.

What's changed?

  • comm_2D, a former member of class Parallel_2D (hence also a member of Parallel_Orbitals), is removed from the code. Users who really need the MPI communicator upon which the BLACS grid is built may call the comm() function to obtain the underlying communicator associated with blacs_ctxt held by the class.
  • a few BLACS utility functions for broadcasting data is added to the header "blacs_connector.h" and a generic interface is provided.

@jinzx10 jinzx10 marked this pull request as ready for review July 12, 2024 16:33
@mohanchen mohanchen changed the title Refactor: remove comm_2D from Parallel_2D Refactor: remove comm_2D from Parallel_2D (Useful Information: BLACS encapsulates MPI and maintains its own internal data structure for MPI communicators) Jul 12, 2024
@mohanchen mohanchen added the Useful Information Useful information for others to learn/study label Jul 12, 2024
@mohanchen mohanchen merged commit 3deedee into deepmodeling:develop Jul 12, 2024
13 checks passed
@jinzx10 jinzx10 deleted the parallel_2d_remove_comm branch July 13, 2024 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Useful Information Useful information for others to learn/study
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants