\doxysection{partition.\+hpp}
\hypertarget{partition_8hpp_source}{}\label{partition_8hpp_source}\index{ginkgo/core/distributed/partition.hpp@{ginkgo/core/distributed/partition.hpp}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{comment}{//\ SPDX-\/FileCopyrightText:\ 2017\ -\/\ 2025\ The\ Ginkgo\ authors}}
\DoxyCodeLine{00002\ \textcolor{comment}{//}}
\DoxyCodeLine{00003\ \textcolor{comment}{//\ SPDX-\/License-\/Identifier:\ BSD-\/3-\/Clause}}
\DoxyCodeLine{00004\ }
\DoxyCodeLine{00005\ \textcolor{preprocessor}{\#ifndef\ GKO\_PUBLIC\_CORE\_DISTRIBUTED\_PARTITION\_HPP\_}}
\DoxyCodeLine{00006\ \textcolor{preprocessor}{\#define\ GKO\_PUBLIC\_CORE\_DISTRIBUTED\_PARTITION\_HPP\_}}
\DoxyCodeLine{00007\ }
\DoxyCodeLine{00008\ }
\DoxyCodeLine{00009\ \textcolor{preprocessor}{\#include\ <ginkgo/core/base/array.hpp>}}
\DoxyCodeLine{00010\ \textcolor{preprocessor}{\#include\ <ginkgo/core/base/polymorphic\_object.hpp>}}
\DoxyCodeLine{00011\ \textcolor{preprocessor}{\#include\ <ginkgo/core/base/segmented\_array.hpp>}}
\DoxyCodeLine{00012\ \textcolor{preprocessor}{\#include\ <ginkgo/core/base/types.hpp>}}
\DoxyCodeLine{00013\ }
\DoxyCodeLine{00014\ }
\DoxyCodeLine{00015\ \textcolor{keyword}{namespace\ }\doxymbox{\hyperlink{namespacegko}{gko}}\ \{}
\DoxyCodeLine{00016\ \textcolor{keyword}{namespace\ }experimental\ \{}
\DoxyCodeLine{00022\ \textcolor{keyword}{namespace\ }\doxymbox{\hyperlink{namespacegko_1_1experimental_1_1distributed}{distributed}}\ \{}
\DoxyCodeLine{00023\ }
\DoxyCodeLine{00024\ }
\DoxyCodeLine{00079\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ LocalIndexType\ =\ \textcolor{keywordtype}{int}32,\ \textcolor{keyword}{typename}\ GlobalIndexType\ =\ \textcolor{keywordtype}{int}64>}
\DoxyCodeLine{00080\ \textcolor{keyword}{class\ }Partition\ :\ \textcolor{keyword}{public}\ \doxymbox{\hyperlink{classgko_1_1EnablePolymorphicObject}{EnablePolymorphicObject}}<}
\DoxyCodeLine{00081\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Partition<LocalIndexType,\ GlobalIndexType>>,}
\DoxyCodeLine{00082\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{public}\ \doxymbox{\hyperlink{classgko_1_1EnablePolymorphicAssignment}{EnablePolymorphicAssignment}}<}
\DoxyCodeLine{00083\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Partition<LocalIndexType,\ GlobalIndexType>>\ \{}
\DoxyCodeLine{00084\ \ \ \ \ \textcolor{keyword}{friend}\ \textcolor{keyword}{class\ }\doxymbox{\hyperlink{classgko_1_1EnablePolymorphicObject}{EnablePolymorphicObject}}<Partition>;}
\DoxyCodeLine{00085\ \ \ \ \ \textcolor{keyword}{static\_assert}(\textcolor{keyword}{sizeof}(GlobalIndexType)\ >=\ \textcolor{keyword}{sizeof}(LocalIndexType),}
\DoxyCodeLine{00086\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}GlobalIndexType\ must\ be\ at\ least\ as\ large\ as\ "{}}}
\DoxyCodeLine{00087\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}LocalIndexType"{}});}
\DoxyCodeLine{00088\ }
\DoxyCodeLine{00089\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00090\ \ \ \ \ \textcolor{keyword}{using\ }\doxymbox{\hyperlink{classgko_1_1EnablePolymorphicAssignment}{EnablePolymorphicAssignment}}<Partition>::convert\_to;}
\DoxyCodeLine{00091\ \ \ \ \ \textcolor{keyword}{using\ }\doxymbox{\hyperlink{classgko_1_1EnablePolymorphicAssignment}{EnablePolymorphicAssignment}}<Partition>::move\_to;}
\DoxyCodeLine{00092\ }
\DoxyCodeLine{00093\ \ \ \ \ \textcolor{keyword}{using\ }local\_index\_type\ =\ LocalIndexType;}
\DoxyCodeLine{00094\ \ \ \ \ \textcolor{keyword}{using\ }global\_index\_type\ =\ GlobalIndexType;}
\DoxyCodeLine{00095\ }
\DoxyCodeLine{00101\ \ \ \ \ \doxymbox{\hyperlink{namespacegko_a9579c98b1d85bf4ad02d7cb5b96fc771}{size\_type}}\ \doxymbox{\hyperlink{classgko_1_1experimental_1_1distributed_1_1Partition_ab0957c5a0fcaebdfb383ba0ec3362dbb}{get\_size}}()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ size\_;\ \}}
\DoxyCodeLine{00102\ }
\DoxyCodeLine{00109\ \ \ \ \ \doxymbox{\hyperlink{namespacegko_a9579c98b1d85bf4ad02d7cb5b96fc771}{size\_type}}\ \doxymbox{\hyperlink{classgko_1_1experimental_1_1distributed_1_1Partition_a0d048491c25db9e138d58402cfe0b298}{get\_num\_ranges}}()\ const\ noexcept}
\DoxyCodeLine{00110\ \ \ \ \ \{}
\DoxyCodeLine{00111\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ offsets\_.get\_size()\ -\/\ 1;}
\DoxyCodeLine{00112\ \ \ \ \ \}}
\DoxyCodeLine{00113\ }
\DoxyCodeLine{00119\ \ \ \ \ \doxymbox{\hyperlink{namespacegko_1_1experimental_1_1mpi_a13b7760affb031fee59d385754eaaffb}{comm\_index\_type}}\ \doxymbox{\hyperlink{classgko_1_1experimental_1_1distributed_1_1Partition_ab8fea11edeee12878190c566423c53b2}{get\_num\_parts}}()\ const\ noexcept\ \{\ \textcolor{keywordflow}{return}\ num\_parts\_;\ \}}
\DoxyCodeLine{00120\ }
\DoxyCodeLine{00126\ \ \ \ \ \doxymbox{\hyperlink{namespacegko_1_1experimental_1_1mpi_a13b7760affb031fee59d385754eaaffb}{comm\_index\_type}}\ \doxymbox{\hyperlink{classgko_1_1experimental_1_1distributed_1_1Partition_a016cf045cc715fec475ef845635db98c}{get\_num\_empty\_parts}}()\ const\ noexcept}
\DoxyCodeLine{00127\ \ \ \ \ \{}
\DoxyCodeLine{00128\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ num\_empty\_parts\_;}
\DoxyCodeLine{00129\ \ \ \ \ \}}
\DoxyCodeLine{00130\ }
\DoxyCodeLine{00138\ \ \ \ \ \textcolor{keyword}{const}\ global\_index\_type*\ \doxymbox{\hyperlink{classgko_1_1experimental_1_1distributed_1_1Partition_ae415fc63fa0389204fe1b9e88b695cc9}{get\_range\_bounds}}()\ const\ noexcept}
\DoxyCodeLine{00139\ \ \ \ \ \{}
\DoxyCodeLine{00140\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ offsets\_.get\_const\_data();}
\DoxyCodeLine{00141\ \ \ \ \ \}}
\DoxyCodeLine{00142\ }
\DoxyCodeLine{00150\ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{namespacegko_1_1experimental_1_1mpi_a13b7760affb031fee59d385754eaaffb}{comm\_index\_type}}*\ \doxymbox{\hyperlink{classgko_1_1experimental_1_1distributed_1_1Partition_a7bf502db40611079d1799a55ec26d7fe}{get\_part\_ids}}()\ const\ noexcept}
\DoxyCodeLine{00151\ \ \ \ \ \{}
\DoxyCodeLine{00152\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ part\_ids\_.get\_const\_data();}
\DoxyCodeLine{00153\ \ \ \ \ \}}
\DoxyCodeLine{00154\ }
\DoxyCodeLine{00168\ \ \ \ \ \textcolor{keyword}{const}\ local\_index\_type*\ \doxymbox{\hyperlink{classgko_1_1experimental_1_1distributed_1_1Partition_a22babde6d81a5556d9466f35d8bd9182}{get\_range\_starting\_indices}}()\ const\ noexcept}
\DoxyCodeLine{00169\ \ \ \ \ \{}
\DoxyCodeLine{00170\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ starting\_indices\_.get\_const\_data();}
\DoxyCodeLine{00171\ \ \ \ \ \}}
\DoxyCodeLine{00172\ }
\DoxyCodeLine{00179\ \ \ \ \ \textcolor{keyword}{const}\ local\_index\_type*\ \doxymbox{\hyperlink{classgko_1_1experimental_1_1distributed_1_1Partition_a13fe4631a2bdf30b34487bcde587f5bb}{get\_part\_sizes}}()\ const\ noexcept}
\DoxyCodeLine{00180\ \ \ \ \ \{}
\DoxyCodeLine{00181\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ part\_sizes\_.get\_const\_data();}
\DoxyCodeLine{00182\ \ \ \ \ \}}
\DoxyCodeLine{00183\ }
\DoxyCodeLine{00192\ \ \ \ \ local\_index\_type\ \doxymbox{\hyperlink{classgko_1_1experimental_1_1distributed_1_1Partition_a885a9f1b9d9151c62a44c1081d2d2f68}{get\_part\_size}}(\doxymbox{\hyperlink{namespacegko_1_1experimental_1_1mpi_a13b7760affb031fee59d385754eaaffb}{comm\_index\_type}}\ part)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00193\ }
\DoxyCodeLine{00199\ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{structgko_1_1segmented__array}{segmented\_array<size\_type>}}\&\ \doxymbox{\hyperlink{classgko_1_1experimental_1_1distributed_1_1Partition_a39774739a7328a8db5bbc521eb9da82d}{get\_ranges\_by\_part}}()\textcolor{keyword}{\ const}}
\DoxyCodeLine{00200\ \textcolor{keyword}{\ \ \ \ }\{}
\DoxyCodeLine{00201\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ ranges\_by\_part\_;}
\DoxyCodeLine{00202\ \ \ \ \ \}}
\DoxyCodeLine{00203\ }
\DoxyCodeLine{00209\ \ \ \ \ \textcolor{keywordtype}{bool}\ \doxymbox{\hyperlink{classgko_1_1experimental_1_1distributed_1_1Partition_a5ad93372e02e79504c4d35298ba8bf04}{has\_connected\_parts}}()\ \textcolor{keyword}{const};}
\DoxyCodeLine{00210\ }
\DoxyCodeLine{00218\ \ \ \ \ \textcolor{keywordtype}{bool}\ \doxymbox{\hyperlink{classgko_1_1experimental_1_1distributed_1_1Partition_ae19a3f932fa504c4ca122c65ac6ea1de}{has\_ordered\_parts}}()\ \textcolor{keyword}{const};}
\DoxyCodeLine{00219\ }
\DoxyCodeLine{00229\ \ \ \ \ \textcolor{keyword}{static}\ std::unique\_ptr<Partition>\ \doxymbox{\hyperlink{classgko_1_1experimental_1_1distributed_1_1Partition_ad17d1164a99bca5df2d2ec0eb5d79c2f}{build\_from\_mapping}}(}
\DoxyCodeLine{00230\ \ \ \ \ \ \ \ \ std::shared\_ptr<const\ Executor>\ exec,}
\DoxyCodeLine{00231\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1array}{array<comm\_index\_type>}}\&\ mapping,\ \doxymbox{\hyperlink{namespacegko_1_1experimental_1_1mpi_a13b7760affb031fee59d385754eaaffb}{comm\_index\_type}}\ num\_parts);}
\DoxyCodeLine{00232\ }
\DoxyCodeLine{00246\ \ \ \ \ \textcolor{keyword}{static}\ std::unique\_ptr<Partition>\ \doxymbox{\hyperlink{classgko_1_1experimental_1_1distributed_1_1Partition_acbc987df113d50d6cdf6d6b605a15860}{build\_from\_contiguous}}(}
\DoxyCodeLine{00247\ \ \ \ \ \ \ \ \ std::shared\_ptr<const\ Executor>\ exec,}
\DoxyCodeLine{00248\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1array}{array<global\_index\_type>}}\&\ ranges,}
\DoxyCodeLine{00249\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1array}{array<comm\_index\_type>}}\&\ part\_ids\ =\ \{\});}
\DoxyCodeLine{00250\ }
\DoxyCodeLine{00262\ \ \ \ \ \textcolor{keyword}{static}\ std::unique\_ptr<Partition>\ \doxymbox{\hyperlink{classgko_1_1experimental_1_1distributed_1_1Partition_a54bfa82bec475057cba794814342505e}{build\_from\_global\_size\_uniform}}(}
\DoxyCodeLine{00263\ \ \ \ \ \ \ \ \ std::shared\_ptr<const\ Executor>\ exec,\ \doxymbox{\hyperlink{namespacegko_1_1experimental_1_1mpi_a13b7760affb031fee59d385754eaaffb}{comm\_index\_type}}\ num\_parts,}
\DoxyCodeLine{00264\ \ \ \ \ \ \ \ \ global\_index\_type\ global\_size);}
\DoxyCodeLine{00265\ }
\DoxyCodeLine{00266\ \textcolor{keyword}{private}:}
\DoxyCodeLine{00267\ \ \ \ \ Partition(std::shared\_ptr<const\ Executor>\ exec,}
\DoxyCodeLine{00268\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{namespacegko_1_1experimental_1_1mpi_a13b7760affb031fee59d385754eaaffb}{comm\_index\_type}}\ num\_parts\ =\ 0,\ \doxymbox{\hyperlink{namespacegko_a9579c98b1d85bf4ad02d7cb5b96fc771}{size\_type}}\ num\_ranges\ =\ 0);}
\DoxyCodeLine{00269\ }
\DoxyCodeLine{00270\ \ \ \ \ \textcolor{keyword}{static}\ std::unique\_ptr<Partition>\ create(}
\DoxyCodeLine{00271\ \ \ \ \ \ \ \ \ std::shared\_ptr<const\ Executor>\ exec,\ \doxymbox{\hyperlink{namespacegko_1_1experimental_1_1mpi_a13b7760affb031fee59d385754eaaffb}{comm\_index\_type}}\ num\_parts\ =\ 0,}
\DoxyCodeLine{00272\ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{namespacegko_a9579c98b1d85bf4ad02d7cb5b96fc771}{size\_type}}\ num\_ranges\ =\ 0);}
\DoxyCodeLine{00273\ }
\DoxyCodeLine{00279\ \ \ \ \ \textcolor{keywordtype}{void}\ finalize\_construction();}
\DoxyCodeLine{00280\ }
\DoxyCodeLine{00281\ \ \ \ \ \doxymbox{\hyperlink{namespacegko_1_1experimental_1_1mpi_a13b7760affb031fee59d385754eaaffb}{comm\_index\_type}}\ num\_parts\_;}
\DoxyCodeLine{00282\ \ \ \ \ \doxymbox{\hyperlink{namespacegko_1_1experimental_1_1mpi_a13b7760affb031fee59d385754eaaffb}{comm\_index\_type}}\ num\_empty\_parts\_;}
\DoxyCodeLine{00283\ \ \ \ \ global\_index\_type\ size\_;}
\DoxyCodeLine{00284\ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1array}{array<global\_index\_type>}}\ offsets\_;}
\DoxyCodeLine{00285\ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1array}{array<local\_index\_type>}}\ starting\_indices\_;}
\DoxyCodeLine{00286\ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1array}{array<local\_index\_type>}}\ part\_sizes\_;}
\DoxyCodeLine{00287\ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1array}{array<comm\_index\_type>}}\ part\_ids\_;}
\DoxyCodeLine{00288\ \ \ \ \ \doxymbox{\hyperlink{structgko_1_1segmented__array}{segmented\_array<size\_type>}}\ ranges\_by\_part\_;}
\DoxyCodeLine{00289\ \};}
\DoxyCodeLine{00290\ }
\DoxyCodeLine{00291\ }
\DoxyCodeLine{00292\ \}\ \ \textcolor{comment}{//\ namespace\ distributed}}
\DoxyCodeLine{00293\ \}\ \ \textcolor{comment}{//\ namespace\ experimental}}
\DoxyCodeLine{00294\ \}\ \ \textcolor{comment}{//\ namespace\ gko}}
\DoxyCodeLine{00295\ }
\DoxyCodeLine{00296\ }
\DoxyCodeLine{00297\ \textcolor{preprocessor}{\#endif\ \ }\textcolor{comment}{//\ GKO\_PUBLIC\_CORE\_DISTRIBUTED\_PARTITION\_HPP\_}}

\end{DoxyCode}
