(git:b77b4be)
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
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.
26
}
dbm_dist_1d_t
;
27
28
/*******************************************************************************
29
* \brief Internal struct for storing a two dimensional distribution.
30
* \author Ole Schuett
31
******************************************************************************/
32
typedef
struct
{
33
int
ref_count
;
34
dbm_dist_1d_t
rows
;
35
dbm_dist_1d_t
cols
;
36
dbm_mpi_comm_t
comm
;
37
int
nranks
;
38
int
my_rank
;
39
}
dbm_distribution_t
;
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
******************************************************************************/
53
void
dbm_distribution_hold(
dbm_distribution_t
*dist);
54
55
/*******************************************************************************
56
* \brief Decreases the reference counter of the given distribution.
57
* \author Ole Schuett
58
******************************************************************************/
59
void
dbm_distribution_release(
dbm_distribution_t
*dist);
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
******************************************************************************/
79
int
dbm_distribution_stored_coords
(
const
dbm_distribution_t
*dist,
80
const
int
row,
const
int
col);
81
82
#endif
83
84
// EOF
dbm_distribution_stored_coords
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.
Definition
dbm_distribution.c:179
dbm_mpi.h
dbm_mpi_comm_t
int dbm_mpi_comm_t
Definition
dbm_mpi.h:19
dbm_dist_1d_t
Internal struct for storing a one dimensional distribution.
Definition
dbm_distribution.h:17
dbm_dist_1d_t::nlocals
int nlocals
Definition
dbm_distribution.h:20
dbm_dist_1d_t::my_rank
int my_rank
Definition
dbm_distribution.h:24
dbm_dist_1d_t::local_indicies
int * local_indicies
Definition
dbm_distribution.h:21
dbm_dist_1d_t::index2coord
int * index2coord
Definition
dbm_distribution.h:19
dbm_dist_1d_t::nshards
int nshards
Definition
dbm_distribution.h:25
dbm_dist_1d_t::nranks
int nranks
Definition
dbm_distribution.h:23
dbm_dist_1d_t::length
int length
Definition
dbm_distribution.h:18
dbm_dist_1d_t::comm
dbm_mpi_comm_t comm
Definition
dbm_distribution.h:22
dbm_distribution_t
Internal struct for storing a two dimensional distribution.
Definition
dbm_distribution.h:32
dbm_distribution_t::my_rank
int my_rank
Definition
dbm_distribution.h:38
dbm_distribution_t::rows
dbm_dist_1d_t rows
Definition
dbm_distribution.h:34
dbm_distribution_t::nranks
int nranks
Definition
dbm_distribution.h:37
dbm_distribution_t::comm
dbm_mpi_comm_t comm
Definition
dbm_distribution.h:36
dbm_distribution_t::cols
dbm_dist_1d_t cols
Definition
dbm_distribution.h:35
dbm_distribution_t::ref_count
int ref_count
Definition
dbm_distribution.h:33
dbm
dbm_distribution.h
Generated by
1.9.8