ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
Parallel::ParaKmeshWorld Class Reference

k-mesh parallel domain: k-point distribution across pools. More...

#include <para_kmesh_world.h>

Inheritance diagram for Parallel::ParaKmeshWorld:
Collaboration diagram for Parallel::ParaKmeshWorld:

Public Member Functions

 ParaKmeshWorld (int nkstot, int nspin)
 Construct a serial (single-pool) k-mesh domain.
 ParaKmeshWorld (const MPI_Comm &comm, int kpar, int my_pool, int nproc, int nkstot, int nspin)
 Construct a k-mesh domain on an existing communicator.
int kpar () const
 Number of pools.
int my_pool () const
 Pool index of this process.
int rank_in_pool () const
 Rank within the pool.
int nproc () const
 Total number of processes.
int nspin () const
 Number of spin components.
int nkstot () const
 Total number of k-points (without spin).
int nks_local () const
 Number of k-points in this pool.
int startk_global () const
 Global start index of this pool's k-points.
int nks_pool (int pool) const
 Number of k-points in the given pool.
int startk_pool (int pool) const
 Global start index of the given pool's k-points.
int which_pool (int ik_global) const
 Which pool owns the given global k-point index.
int startpro_pool (int pool) const
 First MPI_COMM_WORLD rank of the given pool.
int max_nks_pool () const
 Maximum number of k-points across all pools.
void pool_collection (double &value, const double *wk, int ik) const
 Collect a scalar value from the pool that owns k-point ik.
template<typename T>
void pool_collection (T *value, const T *w, int dim, int ik) const
 Collect an array slice from the pool that owns k-point ik.
void gather_kvec (const std::vector< double > &vec_local, std::vector< double > &vec_global) const
 Gather local k-point vectors to global array.
Public Member Functions inherited from Parallel::ParaWorld
virtual ~ParaWorld ()=default
const std::string & tag () const
 Domain tag string.
int rank () const
 Rank of this process inside the domain (0 in serial builds).
int size () const
 Number of processes in the domain (1 in serial builds).
bool valid () const
 True if this process belongs to the domain.
MPI_Comm comm () const
 Underlying MPI communicator (MPI builds only).

Private Member Functions

void distribute_kpoints ()

Private Attributes

int kpar_ = 1
int my_pool_ = 0
int rank_in_pool_ = 0
int nproc_ = 1
int nspin_ = 1
int nkstot_ = 0
int nks_local_ = 0
int startk_global_ = 0
std::vector< int > nks_pool_
 k-points per pool
std::vector< int > startk_pool_
 global start index per pool
std::vector< int > whichpool_
 pool index per k-point
std::vector< int > startpro_pool_
 first world rank per pool

Additional Inherited Members

Static Public Member Functions inherited from Parallel::ParaWorld
static ParaWorld serial (const std::string &tag)
 Build a serial (size=1, rank=0) domain for the given tag.
static std::unique_ptr< ParaWorld > make_serial (const std::string &tag)
 Build a serial domain as a heap-allocated unique_ptr.
static ParaWorld make_mpi (const std::string &tag, const MPI_Comm &comm)
 Build a domain wrapping an MPI communicator.
static std::unique_ptr< ParaWorld > make_mpi_ptr (const std::string &tag, const MPI_Comm &comm)
Protected Member Functions inherited from Parallel::ParaWorld
 ParaWorld (const std::string &tag)
 Construct a serial (single-process) domain.
 ParaWorld (const std::string &tag, const MPI_Comm &comm)
 Construct a domain wrapping an existing MPI communicator.

Detailed Description

k-mesh parallel domain: k-point distribution across pools.

Self-contained replacement for Parallel_Kpoints + KP_WORLD + GlobalV::KPAR / MY_POOL / RANK_IN_POOL. Owns all k-point pool topology data and provides query / collection operations.

In serial builds all operations degenerate to single-pool behavior. Tests only need this header; no GlobalV, no parallel_comm.h.

Constructor & Destructor Documentation

◆ ParaKmeshWorld() [1/2]

Parallel::ParaKmeshWorld::ParaKmeshWorld ( int nkstot,
int nspin )

Construct a serial (single-pool) k-mesh domain.

Parameters
[in]nkstottotal number of k-points (without spin)
[in]nspinnumber of spin components
Here is the call graph for this function:

◆ ParaKmeshWorld() [2/2]

Parallel::ParaKmeshWorld::ParaKmeshWorld ( const MPI_Comm & comm,
int kpar,
int my_pool,
int nproc,
int nkstot,
int nspin )

Construct a k-mesh domain on an existing communicator.

Parameters
[in]commk-point pool communicator (e.g. KP_WORLD)
[in]kparnumber of pools
[in]my_poolpool index of this process
[in]nproctotal number of processes (MPI_COMM_WORLD size)
[in]nkstottotal number of k-points (without spin)
[in]nspinnumber of spin components
Here is the call graph for this function:

Member Function Documentation

◆ distribute_kpoints()

void Parallel::ParaKmeshWorld::distribute_kpoints ( )
private
Here is the caller graph for this function:

◆ gather_kvec()

void Parallel::ParaKmeshWorld::gather_kvec ( const std::vector< double > & vec_local,
std::vector< double > & vec_global ) const

Gather local k-point vectors to global array.

Only pool-root processes contribute their local k-points; the result is valid on all ranks after MPI_Allreduce.

Parameters
[in]vec_locallocal k-point vectors (nks_local elements)
[out]vec_globalglobal k-point vectors (nkstot elements)
Here is the caller graph for this function:

◆ kpar()

int Parallel::ParaKmeshWorld::kpar ( ) const
inline

Number of pools.

Here is the caller graph for this function:

◆ max_nks_pool()

int Parallel::ParaKmeshWorld::max_nks_pool ( ) const

Maximum number of k-points across all pools.

Here is the caller graph for this function:

◆ my_pool()

int Parallel::ParaKmeshWorld::my_pool ( ) const
inline

Pool index of this process.

Here is the caller graph for this function:

◆ nks_local()

int Parallel::ParaKmeshWorld::nks_local ( ) const
inline

Number of k-points in this pool.

Here is the caller graph for this function:

◆ nks_pool()

int Parallel::ParaKmeshWorld::nks_pool ( int pool) const

Number of k-points in the given pool.

Here is the caller graph for this function:

◆ nkstot()

int Parallel::ParaKmeshWorld::nkstot ( ) const
inline

Total number of k-points (without spin).

Here is the caller graph for this function:

◆ nproc()

int Parallel::ParaKmeshWorld::nproc ( ) const
inline

Total number of processes.

Here is the caller graph for this function:

◆ nspin()

int Parallel::ParaKmeshWorld::nspin ( ) const
inline

Number of spin components.

Here is the caller graph for this function:

◆ pool_collection() [1/2]

void Parallel::ParaKmeshWorld::pool_collection ( double & value,
const double * wk,
int ik ) const

Collect a scalar value from the pool that owns k-point ik.

Pool 0 receives the value; other pools send. Only rank_in_pool==0 participates in the actual communication.

Parameters
[out]valuecollected value (valid on pool 0 root)
[in]wklocal k-point weights array
[in]ikglobal k-point index
Here is the caller graph for this function:

◆ pool_collection() [2/2]

template<typename T>
void Parallel::ParaKmeshWorld::pool_collection ( T * value,
const T * w,
int dim,
int ik ) const

Collect an array slice from the pool that owns k-point ik.

Parameters
[out]valueoutput array (dim elements)
[in]winput array (nkstot * dim elements, row-major by k)
[in]dimnumber of elements per k-point
[in]ikglobal k-point index

◆ rank_in_pool()

int Parallel::ParaKmeshWorld::rank_in_pool ( ) const
inline

Rank within the pool.

Here is the caller graph for this function:

◆ startk_global()

int Parallel::ParaKmeshWorld::startk_global ( ) const
inline

Global start index of this pool's k-points.

Here is the caller graph for this function:

◆ startk_pool()

int Parallel::ParaKmeshWorld::startk_pool ( int pool) const

Global start index of the given pool's k-points.

Here is the caller graph for this function:

◆ startpro_pool()

int Parallel::ParaKmeshWorld::startpro_pool ( int pool) const

First MPI_COMM_WORLD rank of the given pool.

◆ which_pool()

int Parallel::ParaKmeshWorld::which_pool ( int ik_global) const

Which pool owns the given global k-point index.

Here is the caller graph for this function:

Member Data Documentation

◆ kpar_

int Parallel::ParaKmeshWorld::kpar_ = 1
private

◆ my_pool_

int Parallel::ParaKmeshWorld::my_pool_ = 0
private

◆ nks_local_

int Parallel::ParaKmeshWorld::nks_local_ = 0
private

◆ nks_pool_

std::vector<int> Parallel::ParaKmeshWorld::nks_pool_
private

k-points per pool

◆ nkstot_

int Parallel::ParaKmeshWorld::nkstot_ = 0
private

◆ nproc_

int Parallel::ParaKmeshWorld::nproc_ = 1
private

◆ nspin_

int Parallel::ParaKmeshWorld::nspin_ = 1
private

◆ rank_in_pool_

int Parallel::ParaKmeshWorld::rank_in_pool_ = 0
private

◆ startk_global_

int Parallel::ParaKmeshWorld::startk_global_ = 0
private

◆ startk_pool_

std::vector<int> Parallel::ParaKmeshWorld::startk_pool_
private

global start index per pool

◆ startpro_pool_

std::vector<int> Parallel::ParaKmeshWorld::startpro_pool_
private

first world rank per pool

◆ whichpool_

std::vector<int> Parallel::ParaKmeshWorld::whichpool_
private

pool index per k-point


The documentation for this class was generated from the following files: