Skip to content

TutorialMarkerF90

Thomas Gruber edited this page Apr 9, 2021 · 3 revisions

Marker API with Fortran 90

Introduction

The Marker API consists of a bunch of function calls and defines that enable the measuring of code regions to get a better insight of the system's activities executing the code region. In scientific programming the interesting code regions are often calculation loops.

The instrumentation is done inside your application but the setup of the performance counters is performed by likwid-perfctr. After the application run, the results are evaluated by likwid-perfctr.

Notice: Please be aware that building of the Fortran 90 module with compiler setting GCC in config.mk requires the Intel® Fortran compiler. You can change this in the file make/include_GCC.mk with the variables FC and FCFLAGS.

Available functions

The functions are defined by the Fortran module likwid.mod. In contrast to the C/C++ Marker API, there are no defines that can be switched on and off at compile time.

  • likwid_markerInit()
    Initialize the Marker API and read the configured eventsets from the environment
  • likwid_markerThreadInit()
    Add thread to the Marker API and pin application thread (commonly only required if not pthread based threading)
  • likwid_markerRegisterRegion(character(*) tag)
    Register a region name tag to the Marker API. This creates an entry in the internally used hash table to minimize overhead at the start of the named region. This call is optional, the same operations are done by start if not registered previously.
  • likwid_markerStartRegion(character(*) tag)
    Start a named region identified by tag. This reads the counters are stores the values in the thread's hash table. If the hash table entry tag does not exist, it is created.
  • likwid_markerStopRegion(character(*) tag)
    Stop a named region identified by tag. This reads the counters are stores the values in the thread's hash table. It is assumed that a STOP can only follow a START, hence no existence check of the hash table entry is performed.
  • likwid_markerGetRegion(character(*) tag, INTEGER nevents, DOUBLE PRECISION, DIMENSION(*) events, DOUBLE PRECISION time, INTEGER count )
    If you want to process a code regions measurement results in the instrumented application itself, you can call this function to get the intermediate results. The region is identified by tag. The nevents parameter is used to specify the length of the events array. After the function returns, nevents is the number of events filled in the events array. The aggregated measurement time is returned in time and the amount of measurements is returned in count.
  • likwid_markerNextGroup()
    Switch to the next eventset. If only a single eventset is given, the function performs no operation. If multiple eventsets are configured, this function switches through the eventsets in a round-robin fashion.
    Notice: This function creates the biggest overhead of all Marker API functions as it has to setup the register to the next eventset.
  • likwid_markerClose()
    Finalize the Marker API and write the aggregated results of all regions to a file that is picked up by likwid-perfctr for evaulation.

Instrumenting the code

The instrumentation is done similar to the C/C++ Marker API. An example of the Fortran90 Marker API can be found here: https://github.com/RRZE-HPC/likwid/blob/master/examples/F-markerAPI.F90

Build and Run application

The building of the instrumented application is similar to the C/C++ Marker API. Sure, the Fortran90 Marker API only works if LIKWID was built with FORTRAN_INTERFACE = true in the config.mk file. The Fortran90 module is installed to the include path. Determine the paths:

$ /bin/bash -c "echo LIKWID_LIB=$(dirname $(which likwid-perfctr))/../lib/"
$ /bin/bash -c "echo LIKWID_INCLUDE=$(dirname $(which likwid-perfctr))/../include/"

After we have the paths, we can build the application:

$ gfortran -fopenmp -I$(LIKWID_INCLUDE) -L$(LIKWID_LIB) <SRC> -o <EXEC> -llikwid

After that we can run our application in the same way we did it for the C/C++ Marker API.

$ likwid-perfctr -C S0:0-3 -g L3 -m <EXEC>
Clone this wiki locally