Skip to content

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

The templates run with the parallelization factor P = 4, which is the maximum of the limited version.

How to Run

  1. Save a template and the MIDACO library in one folder: midacoc.a and midaco.h from the C/C++ page or midacof.a from the Fortran page
  2. 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
  3. 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).

Back to Parallelization