forked from CDS/infrastruktur-dok
Update Cluster-Getting-Started.md
This commit is contained in:
parent
ccdf9699ca
commit
fa7a729737
@ -159,6 +159,29 @@ module load py3-mpi4py
|
|||||||
# Execute the python script and pass the argument '90'
|
# Execute the python script and pass the argument '90'
|
||||||
srun python3 my-mpiProg.py 90
|
srun python3 my-mpiProg.py 90
|
||||||
```
|
```
|
||||||
|
## MPI Hello World
|
||||||
|
|
||||||
|
Der Cluster unterstützt das Message Passing Interface erlaubt das parallele und verteilte Rechnen in einem Programm. Um MPI zu nutzen, muss der Code angepasst werden. Ein Hello World mit C und MPI sieht zum Beispiel so aus:
|
||||||
|
|
||||||
|
```
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "mpi.h"
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
|
char hostname[1024];
|
||||||
|
hostname[1023] = '\0';
|
||||||
|
gethostname(hostname, 1023);
|
||||||
|
|
||||||
|
int ierr;
|
||||||
|
ierr = MPI_Init(&argc, &argv);
|
||||||
|
printf( "Hello from %s\n", hostname);
|
||||||
|
ierr = MPI_Finalize( );
|
||||||
|
exit(ierr);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user