Advanced Templates
In C, C++ and Fortran you write the parallel loop yourself. These templates show how: OpenMP for the cores of one machine, MPI for the nodes of a cluster and GPGPU for a graphics card (by OpenACC). Every template solves the same small example and is a starting point for your own application. MATLAB, Python, Julia, Rust, C#, Java and R switch parallelization on with one option line, see Parallelization. The Python, MATLAB and Julia templates go one step further: a graphics card, a cluster or an external simulation program.
Templates
| Language | OpenMP | MPI | GPGPU |
|---|---|---|---|
| C | example_OpenMP.c | example_MPI.c | example_GPGPU.c |
| C++ | example_OpenMP.cpp | example_MPI.cpp | example_GPGPU.cpp |
| Fortran 77 | example_OpenMP.f | example_MPI.f | example_GPGPU.f |
| Fortran 90 | example_OpenMP.f90 | example_MPI.f90 | example_GPGPU.f90 |
| Language | GPU | Multi-Core and Cluster | External Simulation |
|---|---|---|---|
| Python | example_CuPy.py example_PyTorch.py | example_Numba.py example_Dask.py | example_Simulation.py |
| MATLAB | example_gpuArray.m | example_parfeval.m | example_Simulation.m |
| Julia | example_Simulation.jl |
The templates run with the parallelization factor P = 4, which is the maximum of the limited version.
How to Run
- Save a template and the MIDACO library in one folder:
midacoc.aandmidaco.hfrom the C/C++ page ormidacof.afrom the Fortran page - Compile and run the template in this folder, here for the C templates
# OpenMP gcc -O3 -fopenmp example_OpenMP.c midacoc.a -lm -o run ./run# MPI with 4 processes mpicc -O3 example_MPI.c midacoc.a -lm -o run mpirun -n 4 ./run# GPGPU with the NVIDIA HPC compiler nvc -O3 -acc example_GPGPU.c midacoc.a -lm -o run ./run - Python, MATLAB and Julia: save a template in the folder of the MIDACO files from the Python, MATLAB or Julia page and run it like the examples there
# Python python example_Numba.py# Julia with 4 threads julia -t 4 example_Simulation.jl
The commands for C++ and Fortran and the packages a Python template needs are given at the top of each template. The GPGPU templates use OpenACC directives, which are supported by the NVIDIA HPC compilers (nvc, nvc++, nvfortran) and by GCC (-fopenacc).
© Schlueter Research. All rights reserved.ImprintPrivacyDisclaimer