Python Overhead

October 24, 2022 ยท View on GitHub

We try to assess the overhead generated by starting a Python interpreter from Fortran compared to pure Fortran (possible calling a C interface)

In order to do so we run a Fortran program that calls

  1. a Fortran routine that does nothing do_nothing

  2. a Python function through a CFFI generated wrapper that does nothing do_nothing

  3. a Fortran routine that copies an array copy

  4. a Python function through a CFFI generated wrapper that copies an numpy array copy_array

The results for increasing array length can be found in overhead.csv. Absolute values arbitrary depending on where they were run...

resulting plot

Run

> export LIB=./build
> python timing_cffi_builder.py
> gfortran -I$LIB -Wl,-rpath=$LIB -L$LIB  python_functions_mod.f90 fortran_functions_mod.f90 python_overhead.f90 -ltiming_plugin
> ./a.out