\hypertarget{group__hwlocality__helper__traversal}{\section{Advanced Traversal Helpers}
\label{group__hwlocality__helper__traversal}\index{Advanced Traversal Helpers@{Advanced Traversal Helpers}}
}


Be sure to see the figure in termsanddefs that shows a complete topology tree, including depths, child/sibling/cousin relationships, and an example of an asymmetric topology where one socket has fewer caches than its peers.  


\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
H\+W\+L\+O\+C\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C unsigned \hyperlink{group__hwlocality__helper__traversal_ga26c2ac4f25b1ed293249c88e232f1bea}{hwloc\+\_\+get\+\_\+closest\+\_\+objs} (\hyperlink{group__hwlocality__topology_ga9d1e76ee15a7dee158b786c30b6a6e38}{hwloc\+\_\+topology\+\_\+t} topology, \hyperlink{group__hwlocality__objects_ga79b8ab56877ef99ac59b833203391c7d}{hwloc\+\_\+obj\+\_\+t} src, \hyperlink{group__hwlocality__objects_ga79b8ab56877ef99ac59b833203391c7d}{hwloc\+\_\+obj\+\_\+t} $\ast$\+\_\+\+\_\+hwloc\+\_\+restrict objs, unsigned max)
\begin{DoxyCompactList}\small\item\em Do a depth-\/first traversal of the topology to find and sort. \end{DoxyCompactList}\item 
static \+\_\+\+\_\+hwloc\+\_\+inline \\*
\hyperlink{group__hwlocality__objects_ga79b8ab56877ef99ac59b833203391c7d}{hwloc\+\_\+obj\+\_\+t} \\*
\+\_\+\+\_\+hwloc\+\_\+attribute\+\_\+pure \hyperlink{group__hwlocality__helper__traversal_ga3d32c128aa36b5c9d56f6bf9e70d0e78}{hwloc\+\_\+get\+\_\+obj\+\_\+below\+\_\+by\+\_\+type} (\hyperlink{group__hwlocality__topology_ga9d1e76ee15a7dee158b786c30b6a6e38}{hwloc\+\_\+topology\+\_\+t} topology, \hyperlink{group__hwlocality__types_gacd37bb612667dc437d66bfb175a8dc55}{hwloc\+\_\+obj\+\_\+type\+\_\+t} type1, unsigned idx1, \hyperlink{group__hwlocality__types_gacd37bb612667dc437d66bfb175a8dc55}{hwloc\+\_\+obj\+\_\+type\+\_\+t} type2, unsigned idx2)
\begin{DoxyCompactList}\small\item\em Find an object below another object, both specified by types and indexes. \end{DoxyCompactList}\item 
static \+\_\+\+\_\+hwloc\+\_\+inline \\*
\hyperlink{group__hwlocality__objects_ga79b8ab56877ef99ac59b833203391c7d}{hwloc\+\_\+obj\+\_\+t} \\*
\+\_\+\+\_\+hwloc\+\_\+attribute\+\_\+pure \hyperlink{group__hwlocality__helper__traversal_ga340bb7021204078c30382ea77d38bde9}{hwloc\+\_\+get\+\_\+obj\+\_\+below\+\_\+array\+\_\+by\+\_\+type} (\hyperlink{group__hwlocality__topology_ga9d1e76ee15a7dee158b786c30b6a6e38}{hwloc\+\_\+topology\+\_\+t} topology, int nr, \hyperlink{group__hwlocality__types_gacd37bb612667dc437d66bfb175a8dc55}{hwloc\+\_\+obj\+\_\+type\+\_\+t} $\ast$typev, unsigned $\ast$idxv)
\begin{DoxyCompactList}\small\item\em Find an object below a chain of objects specified by types and indexes. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Be sure to see the figure in termsanddefs that shows a complete topology tree, including depths, child/sibling/cousin relationships, and an example of an asymmetric topology where one socket has fewer caches than its peers. 



\subsection{Function Documentation}
\hypertarget{group__hwlocality__helper__traversal_ga26c2ac4f25b1ed293249c88e232f1bea}{\index{Advanced Traversal Helpers@{Advanced Traversal Helpers}!hwloc\+\_\+get\+\_\+closest\+\_\+objs@{hwloc\+\_\+get\+\_\+closest\+\_\+objs}}
\index{hwloc\+\_\+get\+\_\+closest\+\_\+objs@{hwloc\+\_\+get\+\_\+closest\+\_\+objs}!Advanced Traversal Helpers@{Advanced Traversal Helpers}}
\subsubsection[{hwloc\+\_\+get\+\_\+closest\+\_\+objs}]{\setlength{\rightskip}{0pt plus 5cm}H\+W\+L\+O\+C\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C unsigned hwloc\+\_\+get\+\_\+closest\+\_\+objs (
\begin{DoxyParamCaption}
\item[{{\bf hwloc\+\_\+topology\+\_\+t}}]{topology, }
\item[{{\bf hwloc\+\_\+obj\+\_\+t}}]{src, }
\item[{{\bf hwloc\+\_\+obj\+\_\+t} $\ast$\+\_\+\+\_\+hwloc\+\_\+restrict}]{objs, }
\item[{unsigned}]{max}
\end{DoxyParamCaption}
)}}\label{group__hwlocality__helper__traversal_ga26c2ac4f25b1ed293249c88e232f1bea}


Do a depth-\/first traversal of the topology to find and sort. 

all objects that are at the same depth than {\ttfamily src}. Report in {\ttfamily objs} up to {\ttfamily max} physically closest ones to {\ttfamily src}.

\begin{DoxyReturn}{Returns}
the number of objects returned in {\ttfamily objs}.

0 if {\ttfamily src} is an I/\+O object. 
\end{DoxyReturn}
\hypertarget{group__hwlocality__helper__traversal_ga340bb7021204078c30382ea77d38bde9}{\index{Advanced Traversal Helpers@{Advanced Traversal Helpers}!hwloc\+\_\+get\+\_\+obj\+\_\+below\+\_\+array\+\_\+by\+\_\+type@{hwloc\+\_\+get\+\_\+obj\+\_\+below\+\_\+array\+\_\+by\+\_\+type}}
\index{hwloc\+\_\+get\+\_\+obj\+\_\+below\+\_\+array\+\_\+by\+\_\+type@{hwloc\+\_\+get\+\_\+obj\+\_\+below\+\_\+array\+\_\+by\+\_\+type}!Advanced Traversal Helpers@{Advanced Traversal Helpers}}
\subsubsection[{hwloc\+\_\+get\+\_\+obj\+\_\+below\+\_\+array\+\_\+by\+\_\+type}]{\setlength{\rightskip}{0pt plus 5cm}static \+\_\+\+\_\+hwloc\+\_\+inline {\bf hwloc\+\_\+obj\+\_\+t} \+\_\+\+\_\+hwloc\+\_\+attribute\+\_\+pure hwloc\+\_\+get\+\_\+obj\+\_\+below\+\_\+array\+\_\+by\+\_\+type (
\begin{DoxyParamCaption}
\item[{{\bf hwloc\+\_\+topology\+\_\+t}}]{topology, }
\item[{int}]{nr, }
\item[{{\bf hwloc\+\_\+obj\+\_\+type\+\_\+t} $\ast$}]{typev, }
\item[{unsigned $\ast$}]{idxv}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [static]}}}\label{group__hwlocality__helper__traversal_ga340bb7021204078c30382ea77d38bde9}


Find an object below a chain of objects specified by types and indexes. 

This is a generalized version of \hyperlink{group__hwlocality__helper__traversal_ga3d32c128aa36b5c9d56f6bf9e70d0e78}{hwloc\+\_\+get\+\_\+obj\+\_\+below\+\_\+by\+\_\+type()}.

Arrays {\ttfamily typev} and {\ttfamily idxv} must contain {\ttfamily nr} types and indexes.

Start from the top system object and walk the arrays {\ttfamily typev} and {\ttfamily idxv}. For each type and logical index couple in the arrays, look under the previously found object to find the index-\/th object of the given type. Indexes are specified within the parent, not withing the entire system.

For instance, if nr is 3, typev contains N\+O\+D\+E, S\+O\+C\+K\+E\+T and C\+O\+R\+E, and idxv contains 0, 1 and 2, return the third core object below the second socket below the first N\+U\+M\+A node. 

References hwloc\+\_\+obj\+::cpuset, hwloc\+\_\+get\+\_\+obj\+\_\+inside\+\_\+cpuset\+\_\+by\+\_\+type(), and hwloc\+\_\+get\+\_\+root\+\_\+obj().

\hypertarget{group__hwlocality__helper__traversal_ga3d32c128aa36b5c9d56f6bf9e70d0e78}{\index{Advanced Traversal Helpers@{Advanced Traversal Helpers}!hwloc\+\_\+get\+\_\+obj\+\_\+below\+\_\+by\+\_\+type@{hwloc\+\_\+get\+\_\+obj\+\_\+below\+\_\+by\+\_\+type}}
\index{hwloc\+\_\+get\+\_\+obj\+\_\+below\+\_\+by\+\_\+type@{hwloc\+\_\+get\+\_\+obj\+\_\+below\+\_\+by\+\_\+type}!Advanced Traversal Helpers@{Advanced Traversal Helpers}}
\subsubsection[{hwloc\+\_\+get\+\_\+obj\+\_\+below\+\_\+by\+\_\+type}]{\setlength{\rightskip}{0pt plus 5cm}static \+\_\+\+\_\+hwloc\+\_\+inline {\bf hwloc\+\_\+obj\+\_\+t} \+\_\+\+\_\+hwloc\+\_\+attribute\+\_\+pure hwloc\+\_\+get\+\_\+obj\+\_\+below\+\_\+by\+\_\+type (
\begin{DoxyParamCaption}
\item[{{\bf hwloc\+\_\+topology\+\_\+t}}]{topology, }
\item[{{\bf hwloc\+\_\+obj\+\_\+type\+\_\+t}}]{type1, }
\item[{unsigned}]{idx1, }
\item[{{\bf hwloc\+\_\+obj\+\_\+type\+\_\+t}}]{type2, }
\item[{unsigned}]{idx2}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [static]}}}\label{group__hwlocality__helper__traversal_ga3d32c128aa36b5c9d56f6bf9e70d0e78}


Find an object below another object, both specified by types and indexes. 

Start from the top system object and find object of type {\ttfamily type1} and logical index {\ttfamily idx1}. Then look below this object and find another object of type {\ttfamily type2} and logical index {\ttfamily idx2}. Indexes are specified within the parent, not withing the entire system.

For instance, if type1 is S\+O\+C\+K\+E\+T, idx1 is 2, type2 is C\+O\+R\+E and idx2 is 3, return the fourth core object below the third socket. 

References hwloc\+\_\+obj\+::cpuset, hwloc\+\_\+get\+\_\+obj\+\_\+by\+\_\+type(), and hwloc\+\_\+get\+\_\+obj\+\_\+inside\+\_\+cpuset\+\_\+by\+\_\+type().

