SYCL: Avoid using no_init read accessor in rocFFT
[alexxy/gromacs.git] / src / gromacs / domdec / localatomset.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
5  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6  * and including many others, as listed in the AUTHORS file in the
7  * top-level source directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35 /*! \file
36  * \libinternal \brief
37  * Declares gmx::LocalAtomSet.
38  *
39  * \author Christian Blau <cblau@gwdg.de>
40  * \inlibraryapi
41  * \ingroup module_domdec
42  */
43 #ifndef GMX_DOMDEC_LOCALATOMSET_H
44 #define GMX_DOMDEC_LOCALATOMSET_H
45
46 #include <cstddef>
47
48 namespace gmx
49 {
50 template<typename>
51 class ArrayRef;
52 namespace internal
53 {
54 class LocalAtomSetData;
55 } // namespace internal
56 /*! \libinternal \brief
57  * A local atom set collects local, global and collective indices of
58  * the home atoms on a rank. The indices of the home atoms are automatically
59  * updated during domain decomposition, thus gmx::LocalAtomSet::localIndex
60  * enables iteration over local atoms properties like coordinates or forces.
61  * TODO: add a LocalAtomSet iterator.
62  *
63  * To generate a LocalAtomSet call gmx::LocalAtomSetManger::add and keep the
64  * handle to the LocalAtomSet returned from this call.
65  *
66  * \inlibraryapi
67  * \ingroup module_domdec
68  */
69 class LocalAtomSet
70 {
71 public:
72     friend class LocalAtomSetManager;
73     /*! \brief Maps indices on rank [0..numAtomsLocal_) to global atom indicices.
74      *
75      * \returns the collective index.
76      */
77     ArrayRef<const int> collectiveIndex() const;
78     /*! \brief Global indices of the atoms in this set.
79      *
80      * \note For best performance, store and use a local copy of the arrayref.
81      *
82      * \returns the global index.
83      */
84     ArrayRef<const int> globalIndex() const;
85     /*! \brief Local indices of the atoms.
86      *
87      * For example, the i-th local atom coordinate of this set is
88      * x[atomSet.localIndex()[i]].
89      *
90      * When using in a loop other than a range-based for loop,
91      * performance may improve if the ArrayRef is stored in
92      * a local variable before the loop is entered.
93      * Updated within domain-decomposition.
94      *
95      * \note For best performance, store and use a local copy of the ArrayRef.
96      *
97      * \returns the local index.
98      */
99     ArrayRef<const int> localIndex() const;
100     /*! \brief The number of atoms from this group index on this rank.
101      *
102      * \note For best performance, store and use a local copy of the ArrayRef.
103      */
104     std::size_t numAtomsLocal() const;
105     /*! \brief The number of all atoms from this group index on all ranks together.
106      *
107      * \note For best performance, store and use a local copy.
108      */
109     std::size_t numAtomsGlobal() const;
110
111 private:
112     /*! \brief Constructs a new atom set by setting a reference to its
113      * internal data.
114      * \param[in] data The data for the atom set is stored
115      * in LocalAtomSetData, which is manged by \ref gmx::LocalAtomSetManager.
116      */
117     explicit LocalAtomSet(const internal::LocalAtomSetData& data);
118
119     const internal::LocalAtomSetData* data_;
120 };
121
122 } // namespace gmx
123
124 #endif