2
0
Fork 0
mirror of https://github.com/MartinThoma/LaTeX-examples.git synced 2025-04-24 22:08:04 +02:00
This commit is contained in:
Martin Thoma 2014-03-09 20:34:02 +01:00
parent 3cec128f33
commit b0bddad82f
8 changed files with 82 additions and 1 deletions

View file

@ -13,11 +13,57 @@ Das wird \texttt{mpicc hello-world.c} kompiliert.\\
Mit \texttt{mpirun -np 14 scripts/mpi/a.out} werden 14 Kopien des Programms
gestartet.
\section{Syntax}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Funktionen}
\inputminted[numbersep=5pt, tabsize=4]{c}{scripts/mpi/comm-size.c}
Liefert die Größe des angegebenen Kommunikators; dh. die Anzahl der Prozesse in der Gruppe.
\textbf{Parameter}
\begin{itemize}
\item \textbf{comm}: Kommunikator (handle)
\item \textbf{size}: Anzahl der Prozesse in der Gruppe von \texttt{comm}
\end{itemize}
\textbf{Beispiel}
\inputminted[numbersep=5pt, tabsize=4]{c}{scripts/mpi/comm-size-example.c}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\rule{\textwidth}{0.4pt}
\inputminted[numbersep=5pt, tabsize=4]{c}{scripts/mpi/comm-rank.c}
Bestimmt den Rang des rufenden Prozesses innerhalb des Kommunikators.
Der Rang wird von MPI zum Identifizieren eines Prozesses verwendet. Die Rangnummer ist innerhalb eines Kommunikators eindeutig. Dabei wird stets von Null beginnend durchnumeriert. Sender und Empfänger bei Sendeoperationen oder die Wurzel bei kollektiven Operationen werden immer mittels Rang angegeben.
\textbf{Parameter}
\begin{itemize}
\item \textbf{comm}: Kommunikator (handle)
\item \textbf{rank}: Rang des rufenden Prozesses innerhalb von \texttt{comm}
\end{itemize}
\textbf{Beispiel}
\inputminted[numbersep=5pt, tabsize=4]{c}{scripts/mpi/comm-rank-example.c}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\rule{\textwidth}{0.4pt}
\inputminted[numbersep=5pt, tabsize=4]{c}{scripts/mpi/mpi-reduce.c}
Führt eine globale Operation \textbf{op} aus; der Prozeß \enquote{root} erhält das Resultat.
\textbf{Parameter}
\begin{itemize}
\item \textbf{sendbuf} Startadresse des Sendepuffers
\item \textbf{count} Anzahl der Elemente im Sendepuffer
\item \textbf{datatype} Datentyp der Elemente von \texttt{sendbuf}
\item \textbf{op} auszuführende Operation (handle)
\item \textbf{root} Rang des Root-Prozesses in comm, der das Ergebnis haben soll
\item \textbf{comm} Kommunikator (handle)
\end{itemize}
\textbf{Beispiel}
\inputminted[numbersep=5pt, tabsize=4]{c}{scripts/mpi/mpi-reduce-example.c}
\section{Beispiele}
\section{Weitere Informationen}
\begin{itemize}
\item \url{http://mpitutorial.com/}
\item \url{http://www.open-mpi.org/}
\item \url{http://www.tu-chemnitz.de/informatik/RA/projects/mpihelp/}
\end{itemize}
\index{MPI|)}

View file

@ -0,0 +1,13 @@
#include "mpi.h"
int rank;
MPI_Comm comm;
...
MPI_Comm_rank(comm, &rank);
if (rank==0) {
... Code fur Prozess 0 ...
}
else {
... Code fur die anderen Prozesse ...
}

View file

@ -0,0 +1 @@
int MPI_Comm_rank( MPI_Comm comm, int *rank )

View file

@ -0,0 +1,7 @@
#include "mpi.h"
int size;
MPI_Comm comm;
...
MPI_Comm_size(comm, &size);
...

View file

@ -0,0 +1 @@
int MPI_Comm_size( MPI_Comm comm, int *size )

View file

@ -0,0 +1,10 @@
#include "mpi.h"
int myid;
int recvbuf[DATASIZE], sendbuf[DATA_SIZE];
...
/* Minimum bilden */
MPI_Reduce(sendbuf, recvbuf, DATA_SIZE, MPI_INT, MPI_MIN,
0, MPI_COMM_WORLD);
...

View file

@ -0,0 +1,3 @@
int MPI_Reduce(const void *sendbuf, void *recvbuf,
int count, MPI_Datatype datatype,
MPI_Op op, int root, MPI_Comm comm)