Skip to content

Commit

Permalink
Merge pull request #295 from lucass-carneiro/main
Browse files Browse the repository at this point in the history
CarpetX: Added a section in the docs detailing host, device and inlining annotations of loop lambdas
  • Loading branch information
eschnett authored Jul 24, 2024
2 parents 0126ae0 + 009b65e commit 649af71
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions CarpetX/doc/documentation.tex
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,32 @@ \subsection{Loop Lambdas}
}
\end{lstlisting}

In addition, users can specify inlining (a compile-time optimization where the function call is replaced by its body) by using the \texttt{CCTK\_ATTRIBUTE\_ALWAYS\_INLINE} macro and designate host or device availability via the \texttt{CCTK\_HOST} or \texttt{CCTK\_DEVICE} macros, respectively. These annotations are optional unless the compiler is unable to build a function due to an inability to automatically determine that it needs to be available for device usage, for example. However, when these annotations are desired, they must be placed in specific locations.

To mark a lambda for host usage, one would use:
%
\begin{lstlisting}
[=] CCTK_HOST(const Loop::PointDesc &p) CCTK_ATTRIBUTE_ALWAYS_INLINE {
// loop body
}
\end{lstlisting}
%
For device usage, one would use:
%
\begin{lstlisting}
[=] CCTK_DEVICE(const Loop::PointDesc &p) CCTK_ATTRIBUTE_ALWAYS_INLINE {
// loop body
}
\end{lstlisting}
%
For both host and device usage, one would use:
%
\begin{lstlisting}
[=] CCTK_HOST CCTK_DEVICE(const Loop::PointDesc &p) CCTK_ATTRIBUTE_ALWAYS_INLINE {
// loop body
}
\end{lstlisting}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{The \texttt{PointDesc} type and loop lambda body}
\label{sec:point_des}
Expand Down

0 comments on commit 649af71

Please sign in to comment.