(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
******************************************************************************/
16
typedef
struct
{
17
int
length
;
// global number of rows/cols
18
int
*
index2coord
;
// maps row/col indicies to cart coordinate
19
int
nlocals
;
20
int
*
local_indicies
;
// list of row/col indicies that reside locally.
21
cp_mpi_comm_t
comm
;
// 1D communicator
22
int
nranks
;
23
int
my_rank
;
24
int
nshards
;
// Number of shards for distributing blocks across threads.
25
}
dbm_dist_1d_t
;
26
27
/*******************************************************************************
28
* \brief Internal struct for storing a two dimensional distribution.
29
* \author Ole Schuett
30
******************************************************************************/
31
typedef
struct
{
32
int
ref_count
;
33
dbm_dist_1d_t
rows
;
34
dbm_dist_1d_t
cols
;
35
cp_mpi_comm_t
comm
;
36
int
nranks
;
37
int
my_rank
;
38
}
dbm_distribution_t
;
39
40
/*******************************************************************************
41
* \brief Creates a new two dimensional distribution.
42
* \author Ole Schuett
43
******************************************************************************/
44
void
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
******************************************************************************/
52
void
dbm_distribution_hold(
dbm_distribution_t
*dist);
53
54
/*******************************************************************************
55
* \brief Decreases the reference counter of the given distribution.
56
* \author Ole Schuett
57
******************************************************************************/
58
void
dbm_distribution_release(
dbm_distribution_t
*dist);
59
60
/*******************************************************************************
61
* \brief Returns the rows of the given distribution.
62
* \author Ole Schuett
63
******************************************************************************/
64
void
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
******************************************************************************/
71
void
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
******************************************************************************/
78
int
dbm_distribution_stored_coords
(
const
dbm_distribution_t
*dist,
79
const
int
row,
const
int
col);
80
81
#endif
82
83
// EOF
cp_mpi_comm_t
int cp_mpi_comm_t
Definition
cp_mpi.h:18
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:180
dbm_dist_1d_t
Internal struct for storing a one dimensional distribution.
Definition
dbm_distribution.h:16
dbm_dist_1d_t::nlocals
int nlocals
Definition
dbm_distribution.h:19
dbm_dist_1d_t::my_rank
int my_rank
Definition
dbm_distribution.h:23
dbm_dist_1d_t::local_indicies
int * local_indicies
Definition
dbm_distribution.h:20
dbm_dist_1d_t::index2coord
int * index2coord
Definition
dbm_distribution.h:18
dbm_dist_1d_t::comm
cp_mpi_comm_t comm
Definition
dbm_distribution.h:21
dbm_dist_1d_t::nshards
int nshards
Definition
dbm_distribution.h:24
dbm_dist_1d_t::nranks
int nranks
Definition
dbm_distribution.h:22
dbm_dist_1d_t::length
int length
Definition
dbm_distribution.h:17
dbm_distribution_t
Internal struct for storing a two dimensional distribution.
Definition
dbm_distribution.h:31
dbm_distribution_t::my_rank
int my_rank
Definition
dbm_distribution.h:37
dbm_distribution_t::rows
dbm_dist_1d_t rows
Definition
dbm_distribution.h:33
dbm_distribution_t::nranks
int nranks
Definition
dbm_distribution.h:36
dbm_distribution_t::cols
dbm_dist_1d_t cols
Definition
dbm_distribution.h:34
dbm_distribution_t::comm
cp_mpi_comm_t comm
Definition
dbm_distribution.h:35
dbm_distribution_t::ref_count
int ref_count
Definition
dbm_distribution.h:32
dbm
dbm_distribution.h
Generated by
1.9.8