mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-25 06:18:05 +02:00
MPI
This commit is contained in:
parent
3cec128f33
commit
b0bddad82f
8 changed files with 82 additions and 1 deletions
|
@ -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|)}
|
Binary file not shown.
|
@ -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 ...
|
||||
}
|
1
documents/Programmierparadigmen/scripts/mpi/comm-rank.c
Normal file
1
documents/Programmierparadigmen/scripts/mpi/comm-rank.c
Normal file
|
@ -0,0 +1 @@
|
|||
int MPI_Comm_rank( MPI_Comm comm, int *rank )
|
|
@ -0,0 +1,7 @@
|
|||
#include "mpi.h"
|
||||
|
||||
int size;
|
||||
MPI_Comm comm;
|
||||
...
|
||||
MPI_Comm_size(comm, &size);
|
||||
...
|
1
documents/Programmierparadigmen/scripts/mpi/comm-size.c
Normal file
1
documents/Programmierparadigmen/scripts/mpi/comm-size.c
Normal file
|
@ -0,0 +1 @@
|
|||
int MPI_Comm_size( MPI_Comm comm, int *size )
|
|
@ -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);
|
||||
...
|
3
documents/Programmierparadigmen/scripts/mpi/mpi-reduce.c
Normal file
3
documents/Programmierparadigmen/scripts/mpi/mpi-reduce.c
Normal 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)
|
Loading…
Add table
Add a link
Reference in a new issue