Skip to content

Commit 648aff5

Browse files
19helloFei Yangmohanchen
authored
feat: add distributed MdCell domain decomposition (#7768)
* feat: add distributed MdCell domain decomposition * fix: update NeighborAtom test construction * refactor: generalize distributed MDCell reader * fix: restore distributed MDCell build integration * fix: preserve MDCell build and MPI ownership * refactor: simplify MDCell construction * refactor: pass MD communication domain * fix: pass communication domain to LJ solver * fix: restore neighbor search serial initialization * refactor: restore serial neighbor list implementation --------- Co-authored-by: Fei Yang <2501213217@stu.pku.edu.cn> Co-authored-by: Mohan Chen <mohanchen@pku.edu.cn>
1 parent 3b22343 commit 648aff5

32 files changed

Lines changed: 1911 additions & 1505 deletions

source/Makefile.Objects

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ OBJS_CELL=atom_pseudo.o\
217217
read_pp_ucell.o\
218218
cal_wfc.o\
219219
cal_ux.o\
220+
distributed_mdcell_reader.o\
221+
md_cell.o\
220222
cif_io.o\
221223
ucell_io.o\
222224

@@ -437,7 +439,6 @@ OBJS_NEIGHBOR_SEARCH=neighbor_search.o\
437439
bin_manager.o\
438440
domain_decomposition.o\
439441
page_allocator.o\
440-
unitcell_lite.o\
441442

442443

443444
OBJS_ORBITAL=orb_atomic.o\

source/source_base/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ add_library(
5151
tool_title.cpp
5252
ylm.cpp
5353
parallel_common.cpp
54+
communication_domain.cpp
5455
parallel_global.cpp
5556
parallel_comm.cpp
5657
parallel_reduce.cpp
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include "source_base/communication_domain.h"
2+
3+
namespace ModuleBase
4+
{
5+
CommunicationDomain::CommunicationDomain()
6+
{
7+
}
8+
9+
#ifdef __MPI
10+
CommunicationDomain::CommunicationDomain(MPI_Comm communicator) : communicator_(communicator)
11+
{
12+
if (communicator_ != MPI_COMM_NULL)
13+
{
14+
MPI_Comm_rank(communicator_, &rank_);
15+
MPI_Comm_size(communicator_, &size_);
16+
}
17+
}
18+
19+
MPI_Comm CommunicationDomain::communicator() const
20+
{
21+
return communicator_;
22+
}
23+
#endif
24+
25+
int CommunicationDomain::rank() const
26+
{
27+
return rank_;
28+
}
29+
30+
int CommunicationDomain::size() const
31+
{
32+
return size_;
33+
}
34+
35+
CommunicationDomain world_communication_domain()
36+
{
37+
#ifdef __MPI
38+
return CommunicationDomain(MPI_COMM_WORLD);
39+
#else
40+
return CommunicationDomain();
41+
#endif
42+
}
43+
} // namespace ModuleBase
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#ifndef COMMUNICATION_DOMAIN_H
2+
#define COMMUNICATION_DOMAIN_H
3+
4+
#ifdef __MPI
5+
#include <mpi.h>
6+
#endif
7+
8+
namespace ModuleBase
9+
{
10+
class CommunicationDomain
11+
{
12+
public:
13+
CommunicationDomain();
14+
#ifdef __MPI
15+
explicit CommunicationDomain(MPI_Comm communicator);
16+
MPI_Comm communicator() const;
17+
#endif
18+
int rank() const;
19+
int size() const;
20+
21+
private:
22+
#ifdef __MPI
23+
MPI_Comm communicator_ = MPI_COMM_NULL;
24+
#endif
25+
int rank_ = 0;
26+
int size_ = 1;
27+
};
28+
29+
CommunicationDomain world_communication_domain();
30+
} // namespace ModuleBase
31+
32+
#endif

source/source_cell/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ add_library(
1515
read_pp_upf201.cpp
1616
read_pp_blps.cpp
1717
read_pp_vwr.cpp
18+
distributed_mdcell_reader.cpp
19+
md_cell.cpp
1820
unitcell.cpp
1921
read_atoms.cpp
2022
read_atoms_helper.cpp

0 commit comments

Comments
 (0)