pax_global_header 0000666 0000000 0000000 00000000064 13315376622 0014522 g ustar 00root root 0000000 0000000 52 comment=015fa4624071e9abde23a1330335832c65d569ec
MPI-015fa4624071e9abde23a1330335832c65d569ec/ 0000775 0000000 0000000 00000000000 13315376622 0016712 5 ustar 00root root 0000000 0000000 MPI-015fa4624071e9abde23a1330335832c65d569ec/README.md 0000664 0000000 0000000 00000001351 13315376622 0020171 0 ustar 00root root 0000000 0000000 # Parallel programming with MPI
This repository contains various exercises and examples on parallel programming with message passing interface (MPI).
A working MPI installation is needed, please see individual exercise/example for detailed build instructions.
## How to contribute
Any contributions (new exercises and examples, bug fixes, improvements etc.) are
warmly welcome. In order to contribute, please follow the standard
Gitlab workflow:
1. Fork the project into your personal space
2. Create a feature branch
3. Work on your contributions
4. Push the commit(s) to your fork
5. Submit a merge request to the master branch
As a quality assurance, the merge request is reviewed by PRACE staff before it is accepted into main branch.
MPI-015fa4624071e9abde23a1330335832c65d569ec/hello-world/ 0000775 0000000 0000000 00000000000 13315376622 0021142 5 ustar 00root root 0000000 0000000 MPI-015fa4624071e9abde23a1330335832c65d569ec/hello-world/LICENSE.txt 0000664 0000000 0000000 00000001051 13315376622 0022762 0 ustar 00root root 0000000 0000000
Copyright (C) 2018 CSC - IT Center for Science Ltd.
Licensed under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
Code is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
Copy of the GNU General Public License can be obtained from
.
MPI-015fa4624071e9abde23a1330335832c65d569ec/hello-world/README.md 0000664 0000000 0000000 00000000676 13315376622 0022432 0 ustar 00root root 0000000 0000000 ## Parallel Hello World
a) Write a simple parallel program that prints out something
(e.g. “Hello world!”) from multiple processes. Include the MPI headers
(C), use the MPI module (Fortran), or import mpi4py (Python) and
call appropriate initialization and finalization routines.
b) Modify the program so that each process prints out also its rank
and so that the process with rank 0 prints out the total number of MPI
processes as well.
MPI-015fa4624071e9abde23a1330335832c65d569ec/hello-world/solution/ 0000775 0000000 0000000 00000000000 13315376622 0023016 5 ustar 00root root 0000000 0000000 MPI-015fa4624071e9abde23a1330335832c65d569ec/hello-world/solution/hello.F90 0000664 0000000 0000000 00000000536 13315376622 0024405 0 ustar 00root root 0000000 0000000 program hello
use mpi
implicit none
integer :: rc, myid, ntasks
call MPI_INIT(rc)
call MPI_COMM_SIZE(MPI_COMM_WORLD, ntasks, rc)
call MPI_COMM_RANK(MPI_COMM_WORLD, myid, rc)
if(myid == 0) then
write(*,*) 'In total there are ',ntasks, 'tasks'
endif
write(*,*) 'Hello from ',myid
call MPI_FINALIZE(rc)
end program hello
MPI-015fa4624071e9abde23a1330335832c65d569ec/hello-world/solution/hello.c 0000664 0000000 0000000 00000000605 13315376622 0024266 0 ustar 00root root 0000000 0000000 #include
#include
#include
int main(int argc, char *argv[])
{
int i, myid, ntasks;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &ntasks);
MPI_Comm_rank(MPI_COMM_WORLD, &myid);
if (myid == 0) {
printf("In total there are %i tasks\n", ntasks);
}
printf("Hello from %i\n", myid);
MPI_Finalize();
return 0;
}
MPI-015fa4624071e9abde23a1330335832c65d569ec/hello-world/solution/hello.py 0000664 0000000 0000000 00000000344 13315376622 0024474 0 ustar 00root root 0000000 0000000 from __future__ import print_function
from mpi4py import MPI
comm = MPI.COMM_WORLD
size = comm.Get_size()
rank = comm.Get_rank()
if rank == 0:
print("In total there are {0} tasks".format(size))
print("Hello from", rank)