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