2
0
Fork 0
mirror of https://github.com/MartinThoma/LaTeX-examples.git synced 2025-04-26 06:48:04 +02:00

added more examples for MPI and Scala

This commit is contained in:
Martin Thoma 2014-09-13 17:26:09 +02:00
parent 6987dc28ab
commit 2c4f3e97bf
6 changed files with 68 additions and 5 deletions

View file

@ -98,7 +98,7 @@ Empfangen einer Nachricht (blockierend)
Ein Kommunikationsvorgang wird durch ein Tripel (Sender, Empfänger, tag) eindeutig beschrieben. Um Nachrichten mit beliebigen tags zu empfangen, benutzt man die Konstante \texttt{MPI\_ANY\_TAG}.
\item \textbf{comm}: Kommunikator (handle)
\item \textbf{status}: Status, welcher source und tag angibt (\texttt{MPI\_Status}).
Soll dieser Status ignoriert werden, kann \texttt{MPI\_STATUS\_IGNORE}\xindex{MPI\_STATUS\_IGNORE} angegeben werden.
Soll dieser Status ignoriert werden, kann \texttt{MPI\_STATUS\_IGNORE}\xindex{MPI\_STATUS\_IGNORE@\texttt{MPI\_STATUS\_IGNORE}} angegeben werden.
\end{itemize}
\textbf{Beispiel}
@ -167,7 +167,29 @@ Verteilt Daten vom Prozess \texttt{root} unter alle anderen Prozesse in der Grup
\item \textbf{root}: Rang des Prozesses in comm, der die Daten versendet
\item \textbf{comm}: Kommunikator (handle)
\end{itemize}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\goodbreak
\rule{\textwidth}{0.4pt}\xindex{MPI\_Allgather@\texttt{MPI\_Allgather}}%
\inputminted[numbersep=5pt, tabsize=4]{c}{scripts/mpi/mpi-allgather.c}
Sammelt Daten, die in einer Prozeßgruppe verteilt sind, ein und verteilt das Resultat an alle Prozesse in der Gruppe.
\textbf{Input-Parameter}
\begin{itemize}
\item \textbf{sendbuf}: Startadresse des Sendepuffers
\item \textbf{sendcount}: Anzahl der Elemente im Sendepuffer
\item \textbf{sendtype}: Datentyp der Elemente des Sendepuffers (handle) (vgl. \cpageref{sec:MPI-Datatypes})
\item \textbf{recvcount}: Anzahl der Elemente, die jeder einzelne Prozeß sendet (integer)
\item \textbf{recvtype}: Datentyp der Elemente im Empfangspuffer (handle) (vgl. \cpageref{sec:MPI-Datatypes})
\item \textbf{comm}: Kommunikator (handle)
\end{itemize}
\textbf{Output-Parameter}
\begin{itemize}
\item \textbf{recvbuf}: Anfangsadresse des Empfangspuffers
\end{itemize}
\textbf{Beispiel}
\inputminted[numbersep=5pt, tabsize=4]{c}{scripts/mpi/mpi-allgather-example.c}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\goodbreak
\rule{\textwidth}{0.4pt}\xindex{MPI\_Gather@\texttt{MPI\_Gather}}%

View file

@ -54,16 +54,16 @@ einige Unterschiede.
Weitere Informationen hat Graham Lea unter \url{http://tinyurl.com/scala-hello-world} zur Verfügung gestellt.
\section{Syntax}
In Scala gibt es sog. \textit{values}, die durch das Schlüsselwort \texttt{val}\xindex{val}
In Scala gibt es sog. \textit{values}, die durch das Schlüsselwort \texttt{val}\xindex{val (Scala)@\texttt{val} (Scala)}
angezeigt werden. Diese sind Konstanten. Die Syntax ist der UML-Syntax ähnlich.
\inputminted[numbersep=5pt, tabsize=4]{scala}{scripts/scala/val-syntax.scala}
Variablen werden durch das Schlüsselwort \texttt{var}\xindex{var} angezeigt:
Variablen werden durch das Schlüsselwort \texttt{var}\xindex{var (Scala)@\texttt{var} (Scala)} angezeigt:
\inputminted[numbersep=5pt, tabsize=4]{scala}{scripts/scala/var-syntax.scala}
Methoden werden mit dem Schlüsselwort \texttt{def}\xindex{def} erzeugt:
Methoden werden mit dem Schlüsselwort \texttt{def}\xindex{def (def)@\texttt{def} (Scala)} erzeugt:
\inputminted[numbersep=5pt, tabsize=4]{scala}{scripts/scala/method-syntax.scala}
@ -73,12 +73,17 @@ Klassen werden wie folgt erstellt:
und so instanziiert:
\inputminted[numbersep=5pt, tabsize=4]{scala}{scripts/scala/simple-class-instanciation.scala}
\subsection{Schleifen}\xindex{for (Scala)@\texttt{for} (Scala)}
Eine einfache \texttt{for}-Schleife sieht wie folgt aus:
\inputminted[numbersep=5pt, tabsize=4]{scala}{scripts/scala/extended-for.scala}
Listen können erstellt und durchgegangen werden:
\inputminted[numbersep=5pt, tabsize=4]{scala}{scripts/scala/extended-for.scala}
\subsection{Logische Operatoren}
\begin{table}[h]
\begin{table}[H]
\centering
\begin{tabular}{CCCC}
UND & ODER & Wahr & Falsch \\ \hline\hline

View file

@ -0,0 +1,12 @@
#include "mpi.h"
int sendcount, recvcount;
void *sendbuf, *recvbuf;
MPI_Datatype sendtype, recvtype;
MPI_Comm comm;
...
MPI_Allgather(sendbuf, sendcount, sendtype,
recvbuf, recvcount, recvtype,
comm);
...

View file

@ -0,0 +1,5 @@
int MPI_Allgather(const void *sendbuf, int sendcount,
MPI_Datatype sendtype,
void *recvbuf, int recvcount,
MPI_Datatype recvtype,
MPI_Comm comm)

View file

@ -0,0 +1,16 @@
matches(\varepsilon, []).
matches(C, [C]) :- atom(C), !.
matches(\cup(A, _), S) :- matches(A, S).
matches(\cup(_, B), S) :- matches(B, S).
matches(\cdot(A, B), S) :- append(S1, S2, S),
matches(A, S1),
matches(B, S2).
matches(*(_), []).
matches(*(A), S) :- append(S1, S2, S),
not(S1=[]),
matches(A, S1),
matches(*(A), S2).

View file

@ -0,0 +1,3 @@
for(a <- 1 until 10){
println("Value of a: " + a );
}