Revision [6944]

This is an old revision of Mpi made by ToBo on 2008-12-08 01:46:49.

 

MPI


1. Implementierungen



2. Informationsmaterial

3. Programme bei MPICH2


mpicc compiles and links MPI programs written in C
mpicxx compiles and links MPI programs written in C++
mpiexec runs an MPI program
mpd process mager
mpdallexit shutdown all process magers (mpd)
mpdclean


4. MPD setup


4.1Parameter für mpd


echo gibt Informationen aus, wie z.B. die Portnummer
mpd --echo



4.2mpd-Ring auf mehreren Rechnern


mpdallexit; mpdcleanup; mpdboot  -d -n 2 -f ../mpd_hosts


mpd_hosts mit zwei Rechnern
Unbedingt die /etc/hosts anpassen (siehe Fehlerbehandlung unten)
HOST1:1
HOST2:1


Starten von drei Prozessen auf HOST1 und einem Prozess auf HOST2
mpiexec  -n 3 -host HOST1 ~/code/mpi/04_ring/ring : -n 1 -host HOST2 ~/mpi/ring


Ausgabe
R1 is waiting for R0...
R2 is waiting for R1...
R3 is waiting for R2...
R0 sent data to R1.
R0 is waiting for R3...
R1 received from R0: Wir spielen mit MPI!
R1 sent data to R2.
R1 is waiting for R0...
R2 received from R1: Wir spielen mit MPI!
R2 sent data to R3.
...



5. Beispiele



6. Funktionen in C


MPICH

int MPI_Send (void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)
int MPI_Recv (void* buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status* status)
int MPI_Isend (void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request)
int MPI_Irecv (void* buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Request* request)

int MPI_Test (MPI_Request* request, int* flag, MPI_Status* status)
int MPI_Wait (MPI_Request* request, MPI_Status* status)

int MPI_Comm_group (MPI_Comm comm, MPI_Group* group)
int MPI_Group_union (MPI_Group group1, MPI_Group group2, MPI_Group* new_group)
int MPI_Group_intersection (MPI_Group group1, MPI_Group group2, MPI_Group* new_group)
int MPI_Group_difference (MPI_Group group1, MPI_Group group2, MPI_Group* new_group)

int MPI_Bcast (void *buffer, int count, MPI_Datatype type, int root, MPI_Comm comm)
int MPI_Gather (void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm)
int MPI_Gatherv (void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int *recvcounts, int *displs, MPI_Datatype recvtype, int root, MPI_Comm comm)
int MPI_Scatter (void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm)
int MPI_Scatterv (void *sendbuf, int *sendcounts, int *displs, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm)
int MPI_Reduce (void *sendbuf, void *recvbuf, int count, MPI_Datatype type, MPI_Op op, int root, MPI_Comm comm)



7. Installation


7.1unter Linux (Debian)


für OpenMPI
aptitude install openmpi-dev openmpi-dbg

für MPICH2
aptitude install mpich-bin libmpich1.0-dev openmpi-dev openmpi-dbg mpich-mpd-bin mpich-mpd-bin libmpich-mpd1.0-dev

oder herunterladen und kompiieren
./configure --prefix=/opt/mpi
make
make install



7.2 unter Windows


unter Windows
MPI 1.0.8
.NET 2.0. SP1
gcc MINGW 32
  • .Net framework 2.0 installieren, falls nicht vorhanden (der MPICh installer startet nicht, wenn .net 2.0 fehlt): dotnetfx.exe herunterladen und ausführen
  • .Net 2.0 Service pack 1 installieren: NetFx20_SP1_x86 herunterladen und ausführen
  • MPICH2 installieren: MPICH2 für Windows 32bit herunterladen, ausführen
  • Gcc aus MingW installieren, falls kein anderer C-Compiler vorhanden. Die Installation der neuen Version 1.08 habe ich nur mit Gcc getestet. VisualC++ oder Borland sollten auch funktionieren
  • SMPD als Dienst installieren (smpd -h listet die Optionen): smpd -install und smpd -register_spn
  • Suchpfad ergänzen (<MINGW_ROOT>/bin und <MPICH2_ROOT>/bin hinzufügen)
  • Das fertige Beispiel testen: cd <MPICH2_ROOT>/examples und mpirun -n 4 cpi


8. Vorbereitung


~/.mpich2
export PATH=/local/mpich2/bin:$PATH
export LD_LIBRARY_PATH=/local/mpich2/lib:$LD_LIBRARY_PATH


source ~/.mpich2


Kompiliren
mpicc cpi.c


~/.mpd.conf erstellen
echo "MPD_SECRETWORD=..." > ~/.mpd.conf


Rechte setzen
chmod 600 ~/.mpd.conf


HPC-Server starten
mpd &


Test
mpiexec -n 4 ~/mpi_ex/simple/spi



9. Fehlerbehandlung


mpd HOST1 (handle_mpd_output 392): failed to handshake with mpd on HOST2; recvd output={}

/etc/hosts
127.0.0.1       localhost.localdomain   localhost
10.3.6.1        HOST1
10.3.6.2        HOST2





Siehe auch
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki