Skip to content

Commit ed0c3e4

Browse files
author
abacus_fixer
committed
refactor(parallel): rename ProcessTopology to ParallelPartition
Rename the class from ProcessTopology to ParallelPartition to avoid the physics-specific meaning of "topology" in a condensed-matter code. Also rename files via git mv (parallel_partition.h/cpp, parallel_partition_test.cpp), the factory create_topology -> create_partition, the test target MODULE_BASE_ProcessTopology -> MODULE_BASE_ParallelPartition, and update all 7 referencing CMakeLists.txt files. No behavior change.
1 parent 65509aa commit ed0c3e4

13 files changed

Lines changed: 121 additions & 121 deletions

File tree

source/source_base/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ add_library(
5757
parallel_reduce.cpp
5858
parallel_device.cpp
5959
parallel_grid.cpp
60-
parallel_topology.cpp
60+
parallel_partition.cpp
6161
sph_bessel_tf.cpp
6262
cubic_spline.cpp
6363
parallel_2d.cpp

source/source_base/parallel_global.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,12 @@ void Parallel_Global::divide_pools(const int& NPROC,
283283
return;
284284
}
285285

286-
ProcessTopology Parallel_Global::create_topology(int world_nproc,
287-
int my_rank,
288-
int kpar,
289-
int bndpar,
290-
int diag_np,
291-
int /*grid_np*/)
286+
ParallelPartition Parallel_Global::create_partition(int world_nproc,
287+
int my_rank,
288+
int kpar,
289+
int bndpar,
290+
int diag_np,
291+
int /*grid_np*/)
292292
{
293293
#ifdef __MPI
294294
// ---- Build the nproc_in_pool vector (arithmetic, no MPI). ----
@@ -309,7 +309,7 @@ ProcessTopology Parallel_Global::create_topology(int world_nproc,
309309
for (int s : nproc_in_pool) { total += s; }
310310
if (total != world_nproc)
311311
{
312-
ModuleBase::WARNING_QUIT("Parallel_Global::create_topology",
312+
ModuleBase::WARNING_QUIT("Parallel_Global::create_partition",
313313
"internal: nproc_in_pool sum differs from world_nproc.");
314314
}
315315
}
@@ -335,7 +335,7 @@ ProcessTopology Parallel_Global::create_topology(int world_nproc,
335335
// These two helpers currently write DIAG_WORLD / GRID_WORLD as a
336336
// side effect; they were always called by drivers in the old flow
337337
// right after divide_pools, so we fold them into the factory to
338-
// centralise all 6 legacy comm + scalar topology construction.
338+
// centralise all 6 legacy comm + scalar partition construction.
339339
//
340340
// diag_np == 0 is not meaningful; fall back to 1 so the
341341
// even-partition guard in divide_mpi_groups (called inside
@@ -347,32 +347,32 @@ ProcessTopology Parallel_Global::create_topology(int world_nproc,
347347
int grank = -1, gsize = -1;
348348
Parallel_Global::split_grid_world(effective_diag_np, world_nproc, my_rank, grank, gsize);
349349

350-
return ProcessTopology(world_nproc,
351-
my_rank,
352-
kpar,
353-
my_pool_local,
354-
rank_in_pool_local,
355-
nproc_in_pool,
356-
bndpar,
357-
my_bndgroup,
358-
rank_in_bpgroup,
359-
nproc_in_bndgroup,
360-
POOL_WORLD, // -> pw_world_comm (legacy duped handle)
361-
KP_WORLD, // -> kmesh_world_comm (KP_WORLD alias back)
362-
INT_BGROUP, // -> bsame_kdiff_world_comm
363-
BP_WORLD, // -> bdiff_ksame_world_comm
364-
GRID_WORLD, // -> rgrid_world_comm
365-
DIAG_WORLD, // -> diag_world_comm
366-
MPI_COMM_NULL, // -> matrix_world_comm (caller-filled later)
367-
MPI_COMM_NULL); // -> atom_world_comm (caller-filled later)
350+
return ParallelPartition(world_nproc,
351+
my_rank,
352+
kpar,
353+
my_pool_local,
354+
rank_in_pool_local,
355+
nproc_in_pool,
356+
bndpar,
357+
my_bndgroup,
358+
rank_in_bpgroup,
359+
nproc_in_bndgroup,
360+
POOL_WORLD, // -> pw_world_comm (legacy duped handle)
361+
KP_WORLD, // -> kmesh_world_comm (KP_WORLD alias back)
362+
INT_BGROUP, // -> bsame_kdiff_world_comm
363+
BP_WORLD, // -> bdiff_ksame_world_comm
364+
GRID_WORLD, // -> rgrid_world_comm
365+
DIAG_WORLD, // -> diag_world_comm
366+
MPI_COMM_NULL, // -> matrix_world_comm (caller-filled later)
367+
MPI_COMM_NULL); // -> atom_world_comm (caller-filled later)
368368
#else
369-
// Serial / non-MPI fallback: a single-process trivial topology.
369+
// Serial / non-MPI fallback: a single-process trivial partition.
370370
(void)world_nproc;
371371
(void)my_rank;
372372
(void)kpar;
373373
(void)bndpar;
374374
(void)diag_np;
375-
return ProcessTopology();
375+
return ParallelPartition();
376376
#endif
377377
}
378378

source/source_base/parallel_global.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#define PARALLEL_GLOBAL_H
88

99
#include "parallel_comm.h"
10-
#include "parallel_topology.h"
10+
#include "parallel_partition.h"
1111

1212
namespace Parallel_Global
1313
{
@@ -21,26 +21,26 @@ extern int omp_number;
2121
void read_pal_param(int argc, char** argv, int& NPROC, int& NTHREAD_PER_PROC, int& MY_RANK);
2222

2323
/**
24-
* @brief Build a ProcessTopology snapshot for the given parallel parameters.
24+
* @brief Build a ParallelPartition snapshot for the given parallel parameters.
2525
*
2626
* This is the single factory that knows how to:
2727
* * split MPI_COMM_WORLD into KPAR k-pools via divide_group_comm(even=false);
2828
* * split each pool into BNDPAR band groups via divide_group_comm(even=true);
2929
* * derive INT_BGROUP (bsame_kdiff_world) / BP_WORLD (bdiff_ksame_world);
3030
* * split diag_np-based DIAG_WORLD and diag_np-grouped GRID_WORLD.
3131
*
32-
* The returned ProcessTopology::pw_world_comm (previously POOL_WORLD) is the
32+
* The returned ParallelPartition::pw_world_comm (previously POOL_WORLD) is the
3333
* smallest PW tile: the intersection of one k-pool and one band-group.
3434
*
3535
* matrix_world_comm and atom_world_comm are left as MPI_COMM_NULL in the
3636
* returned value; callers that know which distributed view is required for
3737
* a given step (Parallel_2D / Parallel_Orbitals / DomainDecomposition) are
3838
* expected to fill them in from the appropriate view before passing the
39-
* topology down.
39+
* partition down.
4040
*
4141
* Note: The factory is only available under __MPI. The non-MPI build path
42-
* uses the default ProcessTopology constructor which already produces the
43-
* single-process trivial topology.
42+
* uses the default ParallelPartition constructor which already produces the
43+
* single-process trivial partition.
4444
*
4545
* @param[in] world_nproc Size of MPI_COMM_WORLD
4646
* @param[in] my_rank Rank in MPI_COMM_WORLD
@@ -52,12 +52,12 @@ void read_pal_param(int argc, char** argv, int& NPROC, int& NTHREAD_PER_PROC, in
5252
* @param[in] grid_np Reserved; currently the real-space grid world is
5353
* tied to diag_np via split_grid_world(diag_np, ...).
5454
*/
55-
ProcessTopology create_topology(int world_nproc,
56-
int my_rank,
57-
int kpar,
58-
int bndpar,
59-
int diag_np,
60-
int grid_np);
55+
ParallelPartition create_partition(int world_nproc,
56+
int my_rank,
57+
int kpar,
58+
int bndpar,
59+
int diag_np,
60+
int grid_np);
6161

6262

6363
/**-------------------------------------------
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#include "parallel_topology.h"
1+
#include "parallel_partition.h"
22

33
#include <cassert>
44

5-
ProcessTopology::ProcessTopology()
5+
ParallelPartition::ParallelPartition()
66
: world_nproc_(1),
77
my_rank_(0),
88
kpar_(1),
@@ -27,7 +27,7 @@ ProcessTopology::ProcessTopology()
2727
{
2828
}
2929

30-
ProcessTopology::ProcessTopology(int world_nproc_in,
30+
ParallelPartition::ParallelPartition(int world_nproc_in,
3131
int my_rank_in,
3232
int kpar_in,
3333
int my_pool_in,
@@ -92,7 +92,7 @@ ProcessTopology::ProcessTopology(int world_nproc_in,
9292
assert(rank_in_band_group_ >= 0 && rank_in_band_group_ < nproc_in_band_group_);
9393
}
9494

95-
int ProcessTopology::pool_root_rank(int pool) const
95+
int ParallelPartition::pool_root_rank(int pool) const
9696
{
9797
if (pool < 0 || pool >= kpar_)
9898
{
@@ -106,7 +106,7 @@ int ProcessTopology::pool_root_rank(int pool) const
106106
return offset;
107107
}
108108

109-
int ProcessTopology::band_group_root_rank(int band_group) const
109+
int ParallelPartition::band_group_root_rank(int band_group) const
110110
{
111111
if (band_group < 0 || band_group >= bndpar_)
112112
{
@@ -135,58 +135,58 @@ int ProcessTopology::band_group_root_rank(int band_group) const
135135
#ifdef __MPI
136136
// Immutable builders: each returns a copy of *this with exactly one
137137
// communicator replaced. Scalar topology fields are never touched.
138-
ProcessTopology ProcessTopology::with_pw_world_comm(MPI_Comm comm) const
138+
ParallelPartition ParallelPartition::with_pw_world_comm(MPI_Comm comm) const
139139
{
140-
ProcessTopology t = *this;
140+
ParallelPartition t = *this;
141141
t.pw_world_comm_ = comm;
142142
return t;
143143
}
144144

145-
ProcessTopology ProcessTopology::with_kmesh_world_comm(MPI_Comm comm) const
145+
ParallelPartition ParallelPartition::with_kmesh_world_comm(MPI_Comm comm) const
146146
{
147-
ProcessTopology t = *this;
147+
ParallelPartition t = *this;
148148
t.kmesh_world_comm_ = comm;
149149
return t;
150150
}
151151

152-
ProcessTopology ProcessTopology::with_bsame_kdiff_world_comm(MPI_Comm comm) const
152+
ParallelPartition ParallelPartition::with_bsame_kdiff_world_comm(MPI_Comm comm) const
153153
{
154-
ProcessTopology t = *this;
154+
ParallelPartition t = *this;
155155
t.bsame_kdiff_world_comm_ = comm;
156156
return t;
157157
}
158158

159-
ProcessTopology ProcessTopology::with_bdiff_ksame_world_comm(MPI_Comm comm) const
159+
ParallelPartition ParallelPartition::with_bdiff_ksame_world_comm(MPI_Comm comm) const
160160
{
161-
ProcessTopology t = *this;
161+
ParallelPartition t = *this;
162162
t.bdiff_ksame_world_comm_ = comm;
163163
return t;
164164
}
165165

166-
ProcessTopology ProcessTopology::with_rgrid_world_comm(MPI_Comm comm) const
166+
ParallelPartition ParallelPartition::with_rgrid_world_comm(MPI_Comm comm) const
167167
{
168-
ProcessTopology t = *this;
168+
ParallelPartition t = *this;
169169
t.rgrid_world_comm_ = comm;
170170
return t;
171171
}
172172

173-
ProcessTopology ProcessTopology::with_diag_world_comm(MPI_Comm comm) const
173+
ParallelPartition ParallelPartition::with_diag_world_comm(MPI_Comm comm) const
174174
{
175-
ProcessTopology t = *this;
175+
ParallelPartition t = *this;
176176
t.diag_world_comm_ = comm;
177177
return t;
178178
}
179179

180-
ProcessTopology ProcessTopology::with_matrix_world_comm(MPI_Comm comm) const
180+
ParallelPartition ParallelPartition::with_matrix_world_comm(MPI_Comm comm) const
181181
{
182-
ProcessTopology t = *this;
182+
ParallelPartition t = *this;
183183
t.matrix_world_comm_ = comm;
184184
return t;
185185
}
186186

187-
ProcessTopology ProcessTopology::with_atom_world_comm(MPI_Comm comm) const
187+
ParallelPartition ParallelPartition::with_atom_world_comm(MPI_Comm comm) const
188188
{
189-
ProcessTopology t = *this;
189+
ParallelPartition t = *this;
190190
t.atom_world_comm_ = comm;
191191
return t;
192192
}
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef PARALLEL_TOPOLOGY_H
2-
#define PARALLEL_TOPOLOGY_H
1+
#ifndef PARALLEL_PARTITION_H
2+
#define PARALLEL_PARTITION_H
33

44
#include <vector>
55

@@ -8,7 +8,7 @@
88
#endif
99

1010
/**
11-
* @brief Immutable description of the ABACUS process topology.
11+
* @brief Immutable description of the ABACUS parallel partition.
1212
*
1313
* Replaces the six raw-global MPI_Comm (POOL_WORLD / KP_WORLD /
1414
* INT_BGROUP / BP_WORLD / GRID_WORLD / DIAG_WORLD) together with the
@@ -40,24 +40,24 @@
4040
* Values are captured at construction time; the object is copyable
4141
* (value semantics) and exposes no mutable workflow switches.
4242
* Consumers currently reading the global MPI_Comm / GlobalV fields
43-
* should migrate to taking a `const ProcessTopology&` from their
44-
* callers. Parallel_Global::create_topology(...) produces one such
43+
* should migrate to taking a `const ParallelPartition&` from their
44+
* callers. Parallel_Global::create_partition(...) produces one such
4545
* instance at startup whose communicators are also aliased back to
4646
* the legacy globals so existing code keeps working during the
4747
* migration.
4848
*
4949
* matrix_world_comm / atom_world_comm are not derived inside the
50-
* topology constructor because the correct choice depends on where
50+
* partition constructor because the correct choice depends on where
5151
* the view is used (LCAO diag, GK diag, MD step, ...). Callers that
5252
* need a proper matrix or atom domain are expected to fill in the
53-
* handle before passing the topology down to distributed modules.
53+
* handle before passing the partition down to distributed modules.
5454
*/
55-
class ProcessTopology
55+
class ParallelPartition
5656
{
5757
public:
5858
/// Trivially-constructible serial fallback. Produces a single-
59-
/// process, single-pool topology suitable for non-__MPI builds.
60-
ProcessTopology();
59+
/// process, single-pool partition suitable for non-__MPI builds.
60+
ParallelPartition();
6161

6262
/**
6363
* @brief Full constructor. Intended for Parallel_Global factory.
@@ -69,7 +69,7 @@ class ProcessTopology
6969
* and are filled in later by whichever call site knows which
7070
* domain view is needed for a given distributed calculation.
7171
*/
72-
ProcessTopology(int world_nproc_in,
72+
ParallelPartition(int world_nproc_in,
7373
int my_rank_in,
7474
int kpar_in,
7575
int my_pool_in,
@@ -139,14 +139,14 @@ class ProcessTopology
139139
* free that communicator itself). Serializers such as copies of the
140140
* returned object share the same handle, as usual for this class.
141141
*/
142-
ProcessTopology with_pw_world_comm(MPI_Comm comm) const;
143-
ProcessTopology with_kmesh_world_comm(MPI_Comm comm) const;
144-
ProcessTopology with_bsame_kdiff_world_comm(MPI_Comm comm) const;
145-
ProcessTopology with_bdiff_ksame_world_comm(MPI_Comm comm) const;
146-
ProcessTopology with_rgrid_world_comm(MPI_Comm comm) const;
147-
ProcessTopology with_diag_world_comm(MPI_Comm comm) const;
148-
ProcessTopology with_matrix_world_comm(MPI_Comm comm) const;
149-
ProcessTopology with_atom_world_comm(MPI_Comm comm) const;
142+
ParallelPartition with_pw_world_comm(MPI_Comm comm) const;
143+
ParallelPartition with_kmesh_world_comm(MPI_Comm comm) const;
144+
ParallelPartition with_bsame_kdiff_world_comm(MPI_Comm comm) const;
145+
ParallelPartition with_bdiff_ksame_world_comm(MPI_Comm comm) const;
146+
ParallelPartition with_rgrid_world_comm(MPI_Comm comm) const;
147+
ParallelPartition with_diag_world_comm(MPI_Comm comm) const;
148+
ParallelPartition with_matrix_world_comm(MPI_Comm comm) const;
149+
ParallelPartition with_atom_world_comm(MPI_Comm comm) const;
150150
#endif
151151

152152
private:
@@ -175,4 +175,4 @@ class ProcessTopology
175175
#endif
176176
};
177177

178-
#endif // PARALLEL_TOPOLOGY_H
178+
#endif // PARALLEL_PARTITION_H

source/source_base/test_parallel/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
AddTest(
22
TARGET MODULE_BASE_ParaCommon
33
LIBS parameter MPI::MPI_CXX
4-
SOURCES parallel_common_test.cpp ../global_variable.cpp ../parallel_common.cpp ../parallel_reduce.cpp ../parallel_comm.cpp ../parallel_global.cpp ../parallel_topology.cpp ../tool_quit.cpp ../global_file.cpp ../global_function.cpp ../memory_recorder.cpp ../timer.cpp
4+
SOURCES parallel_common_test.cpp ../global_variable.cpp ../parallel_common.cpp ../parallel_reduce.cpp ../parallel_comm.cpp ../parallel_global.cpp ../parallel_partition.cpp ../tool_quit.cpp ../global_file.cpp ../global_function.cpp ../memory_recorder.cpp ../timer.cpp
55
)
66

77
AddTest(
88
TARGET MODULE_BASE_ParaGlobal
99
LIBS parameter MPI::MPI_CXX
10-
SOURCES parallel_global_test.cpp ../global_variable.cpp ../parallel_global.cpp ../parallel_comm.cpp ../tool_quit.cpp ../global_file.cpp ../global_function.cpp ../memory_recorder.cpp ../timer.cpp ../parallel_reduce.cpp ../parallel_topology.cpp
10+
SOURCES parallel_global_test.cpp ../global_variable.cpp ../parallel_global.cpp ../parallel_comm.cpp ../tool_quit.cpp ../global_file.cpp ../global_function.cpp ../memory_recorder.cpp ../timer.cpp ../parallel_reduce.cpp ../parallel_partition.cpp
1111
)
1212

1313
AddTest(
14-
TARGET MODULE_BASE_ProcessTopology
14+
TARGET MODULE_BASE_ParallelPartition
1515
LIBS parameter MPI::MPI_CXX
16-
SOURCES parallel_topology_test.cpp ../global_variable.cpp ../parallel_global.cpp ../parallel_comm.cpp ../tool_quit.cpp ../global_file.cpp ../global_function.cpp ../memory_recorder.cpp ../timer.cpp ../parallel_reduce.cpp ../parallel_topology.cpp
16+
SOURCES parallel_partition_test.cpp ../global_variable.cpp ../parallel_global.cpp ../parallel_comm.cpp ../tool_quit.cpp ../global_file.cpp ../global_function.cpp ../memory_recorder.cpp ../timer.cpp ../parallel_reduce.cpp ../parallel_partition.cpp
1717
)
1818

1919
AddTest(
2020
TARGET MODULE_BASE_ParaReduce
2121
LIBS parameter MPI::MPI_CXX
22-
SOURCES parallel_reduce_test.cpp ../global_variable.cpp ../parallel_global.cpp ../parallel_comm.cpp ../parallel_common.cpp ../parallel_reduce.cpp ../tool_quit.cpp ../global_file.cpp ../global_function.cpp ../memory_recorder.cpp ../timer.cpp ../parallel_topology.cpp
22+
SOURCES parallel_reduce_test.cpp ../global_variable.cpp ../parallel_global.cpp ../parallel_comm.cpp ../parallel_common.cpp ../parallel_reduce.cpp ../tool_quit.cpp ../global_file.cpp ../global_function.cpp ../memory_recorder.cpp ../timer.cpp ../parallel_partition.cpp
2323
)
2424

2525
install(FILES parallel_common_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

0 commit comments

Comments
 (0)