Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Content/Presentations/sections/Section_DataParallelPatterns.tex
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@
@gray);@gray
\end{code}

(Will review C\texttt{++} Lambdas on the next slide)

\pause

A lambda is not \textit{magic}, it is the compiler \textbf{auto-generating} a \textbf{functor} for you.
Expand All @@ -291,6 +293,36 @@

%==========================================================================

\begin{frame}[fragile]{Quick review of C\texttt{++} Lambda syntax}
\url{https://cppreference.com/cpp/language/lambda}

C++ Lambdas auto-generate the variable capture code:

\begin{code}[keywords={}, frame=single, numbers=left]
@grayKokkos::parallel_for(numberOfAtoms,@gray
[@pattern=@pattern] (const int64_t atomIndex) { // copy by value, implicit
@darkgreenatomForces@darkgreen[atomIndex] = calculateForce(@darkreddata@darkred);
}
@gray);@gray
\end{code}

\begin{code}[keywords={}, frame=single, numbers=left, firstnumber=2]
[@patternatomForces, data@pattern] (const int64_t atomIndex) { // explicit
\end{code}

\pause

\begin{code}[keywords={}, frame=single, numbers=left, firstnumber=2]
[@pattern&@pattern] (const int64_t atomIndex) { // by reference, implicit
\end{code}

\begin{code}[keywords={}, frame=single, numbers=left, firstnumber=2]
[@pattern&atomForces, &data@pattern] (const int64_t atomIndex) { // explicit
\end{code}
\end{frame}

%==========================================================================

\begin{frame}[fragile]{parallel\_for examples}

\textbf{How does this compare to OpenMP?}
Expand Down
Loading