(git:34ef472)
dbm_distribution.h
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------*/
2 /* CP2K: A general program to perform molecular dynamics simulations */
3 /* Copyright 2000-2024 CP2K developers group <https://cp2k.org> */
4 /* */
5 /* SPDX-License-Identifier: BSD-3-Clause */
6 /*----------------------------------------------------------------------------*/
7 
8 #ifndef DBM_DISTRIBUTION_H
9 #define DBM_DISTRIBUTION_H
10 
11 #include "dbm_mpi.h"
12 
13 /*******************************************************************************
14  * \brief Internal struct for storing a one dimensional distribution.
15  * \author Ole Schuett
16  ******************************************************************************/
17 typedef struct {
18  int length; // global number of rows/cols
19  int *index2coord; // maps row/col indicies to cart coordinate
20  int nlocals;
21  int *local_indicies; // list of row/col indicies that reside locally.
22  dbm_mpi_comm_t comm; // 1D communicator
23  int nranks;
24  int my_rank;
25  int nshards; // Number of shards for distributing blocks across threads.
27 
28 /*******************************************************************************
29  * \brief Internal struct for storing a two dimensional distribution.
30  * \author Ole Schuett
31  ******************************************************************************/
32 typedef struct {
33  int ref_count;
37  int nranks;
38  int my_rank;
40 
41 /*******************************************************************************
42  * \brief Creates a new two dimensional distribution.
43  * \author Ole Schuett
44  ******************************************************************************/
45 void dbm_distribution_new(dbm_distribution_t **dist_out, const int fortran_comm,
46  const int nrows, const int ncols,
47  const int row_dist[nrows], const int col_dist[ncols]);
48 
49 /*******************************************************************************
50  * \brief Increases the reference counter of the given distribution.
51  * \author Ole Schuett
52  ******************************************************************************/
54 
55 /*******************************************************************************
56  * \brief Decreases the reference counter of the given distribution.
57  * \author Ole Schuett
58  ******************************************************************************/
60 
61 /*******************************************************************************
62  * \brief Returns the rows of the given distribution.
63  * \author Ole Schuett
64  ******************************************************************************/
65 void dbm_distribution_row_dist(const dbm_distribution_t *dist, int *nrows,
66  const int **row_dist);
67 
68 /*******************************************************************************
69  * \brief Returns the columns of the given distribution.
70  * \author Ole Schuett
71  ******************************************************************************/
72 void dbm_distribution_col_dist(const dbm_distribution_t *dist, int *ncols,
73  const int **col_dist);
74 
75 /*******************************************************************************
76  * \brief Returns the MPI rank on which the given block should be stored.
77  * \author Ole Schuett
78  ******************************************************************************/
80  const int row, const int col);
81 
82 #endif
83 
84 // EOF
int dbm_distribution_stored_coords(const dbm_distribution_t *dist, const int row, const int col)
Returns the MPI rank on which the given block should be stored.
void dbm_distribution_new(dbm_distribution_t **dist_out, const int fortran_comm, const int nrows, const int ncols, const int row_dist[nrows], const int col_dist[ncols])
Creates a new two dimensional distribution.
void dbm_distribution_hold(dbm_distribution_t *dist)
Increases the reference counter of the given distribution.
void dbm_distribution_release(dbm_distribution_t *dist)
Decreases the reference counter of the given distribution.
void dbm_distribution_row_dist(const dbm_distribution_t *dist, int *nrows, const int **row_dist)
Returns the rows of the given distribution.
void dbm_distribution_col_dist(const dbm_distribution_t *dist, int *ncols, const int **col_dist)
Returns the columns of the given distribution.
int dbm_mpi_comm_t
Definition: dbm_mpi.h:18
Internal struct for storing a one dimensional distribution.
dbm_mpi_comm_t comm
Internal struct for storing a two dimensional distribution.
dbm_dist_1d_t rows
dbm_mpi_comm_t comm
dbm_dist_1d_t cols