# rrze-hpc/likwid architecture

> Architecture diagram of the GitHub repository rrze-hpc/likwid, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rrze-hpc/likwid
- Repository: https://github.com/rrze-hpc/likwid

## Overview

##### Main components/modules
- Library/Daemon Layer:
– The “src” directory shows major source files implementing the core functionality. In particular, components such as the access daemon (src/access-daemon, which installs hardware access functions), access routines (access_x86, access_client, etc.), and various performance monitoring routines are central.
– The system also contains hardware-specific modules (e.g., different “access_x86…” and “sysFeatures” files) which encapsulate interfacing with different hardware architectures.
- Command Line Tools & Applications:
– Individual executables such as likwid-topology, likwid-perfctr, likwid-pin, likwid-powermeter, likwid-bench, likwid-genTopoCfg, and others (located in src/applications or built separately) wrap around the library calls to offer user-facing functionality.
- Benchmarking Component:
– The “bench” directory contains micro benchmark scripts and source files (e.g., various benchmark patterns for different architectures – x86, ARMv7, ARMv8, POWER, etc.) to test performance metrics.
- External Dependencies & Utilities:
– External libraries and tools integrated into the project (located under “ext”) include GOTCHA (for function interception), hwloc (for hardware locality and topology), and Lua (for configuration and scripting interfaces).
– Additionally, support files like “groups”, “filters”, and “doc” add event groups, filtering mechanisms, and documentation.
- Build & Packaging System:
– The “Makefile”, “config.mk”, “packaging”, “.github” workflows, and “gitlab-ci.yml” files represent the build configuration, continuous integration, and distribution preparation.

##### Relationships and interactions
- At the lowest level is the Hardware Interface Layer that directly interacts with CPU registers/performance counters, possibly using the operating system’s APIs or direct MSR access.
- The Library/Daemon Layer (including components in src/access-daemon and related files) abstracts hardware-specific details and provides APIs for higher-level tools.
- The CLI tools (such as likwid-topology or likwid-perfctr) call the library routines to retrieve system and performance data. They may also use the Marker API, allowing applications to embed performance markers.
- The benchmarking suite (in bench) calls both library functions and specific benchmark kernels to evaluate performance on various platforms.
- External dependencies (hwloc, GOTCHA, Lua) are used by the library and tools to fetch additional system information, intercept function calls, or provide scripting support.

##### Important architectural patterns and design principles
- Modularity: LIKWID is divided into clearly separated components (the core library, the daemon, and multiple tools) to keep concerns separate.
- Hardware Abstraction: There is a strong emphasis on abstracting away differences across various architectures using different source modules and configuration files.
- Extensibility: With clearly defined event groups and external interfaces (e.g., Marker API), new functionalities or bindings (for Python, Java, Julia) can easily plug into the existing framework.
- Build & Integration: The project’s use of standardized build systems (Makefiles, CMake config files in ext directories) and packaging scripts shows attention to easy installation and CI automation.

##### Relevant technologies/frameworks
- Programming Language: Mainly C (with some Fortran and Perl utilities) for performance-critical code.
- External Libraries: hwloc for topology discovery, GOTCHA for interposition (e.g., for runtime instrumentation), Lua for scripting interfaces, and possibly MPI/OpenMP integration for multiprocess/parallel testing.
- Build System: Traditional Unix Makefiles, enhanced by CMake (in ext directories and “make” folder), and CI/CD workflows (.github/workflows, .gitlab-ci.yml).

##### Specific elements
- Use clear labels for each component: e.g., “Hardware Interface Layer”, “Access Daemon & Core Library”, “CLI Tools (topology, perfctr, pin…)”, “Benchmark Suite”, “External Libraries (hwloc, GOTCHA, Lua)”, “Build/CI/Packaging”.
– User Commands → CLI Tools → Core Library/Daemon → Hardware/OS
– Benchmark suite → Core Library → Performance Counters/Hardware
– Integration of external libraries (e.g., hwloc providing system topology to both the core library and CLI tools)
- Build pipeline and test/packaging components as a separate side block that interacts with the source code and documentation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Layer
    subgraph "User Layer"
        U1("User Commands"):::user
    end

    %% Application Layer
    subgraph "Application Layer"
        CLI("CLI Tools (topology,perfctr,pin,powermeter,genTopoCfg,mpirun,sysfeatures)"):::cli
        BENCH("Benchmark Suite"):::bench
    end

    %% Core Layer
    subgraph "Core Layer"
        LIB("Access Daemon & Core Library"):::lib
        HWMOD("x86 Hardware Access Modules"):::module
    end

    %% External Dependencies & Utilities
    subgraph "External Dependencies & Utilities"
        GOTCHA("GOTCHA"):::ext
        HWLOC("hwloc"):::ext
        LUA("Lua"):::ext
        UTIL("Utilities (groups,filters,doc)"):::ext
    end

    %% Hardware Interface Layer
    subgraph "Hardware Interface"
        HW("Hardware Interface (OS/CPU Registers)"):::hardware
    end

    %% Build & Packaging
    subgraph "Build & Packaging"
        B1("Build Config (Makefile,config.mk,make)"):::build
        B2("CI & Packaging (.github,gitlab-ci,packaging)"):::build
    end

    %% Connections
    U1 --> CLI
    U1 --> BENCH
    CLI -->|"calls"| LIB
    BENCH -->|"executes"| LIB
    LIB -->|"integrates"| HWMOD
    LIB -->|"uses"| GOTCHA
    LIB -->|"uses"| HWLOC
    LIB -->|"uses"| LUA
    LIB -->|"may use"| UTIL
    LIB -->|"accesses"| HW
    B1 -->|"builds"| LIB
    B2 -->|"deploys"| LIB

    %% Styling Classes
    classDef user fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef cli fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef bench fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef lib fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef module fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef ext fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef hardware fill:#fefefe,stroke:#818182,stroke-width:2px;
    classDef build fill:#f5c6cb,stroke:#721c24,stroke-width:2px;

    %% Click Events
    click LIB "https://github.com/rrze-hpc/likwid/tree/master/src/access-daemon" "Access Daemon & Core Library"
    click HWMOD "https://github.com/rrze-hpc/likwid/blob/master/src/access_x86.c" "x86 Hardware Access Modules"
    click CLI "https://github.com/rrze-hpc/likwid/tree/master/src/applications" "CLI Tools"
    click BENCH "https://github.com/rrze-hpc/likwid/tree/master/bench" "Benchmark Suite"
    click GOTCHA "https://github.com/rrze-hpc/likwid/tree/master/ext/GOTCHA" "GOTCHA Integration"
    click HWLOC "https://github.com/rrze-hpc/likwid/tree/master/ext/hwloc" "hwloc Integration"
    click LUA "https://github.com/rrze-hpc/likwid/tree/master/ext/lua" "Lua Support"
    click UTIL "https://github.com/rrze-hpc/likwid/tree/master/groups" "Additional Utilities (groups,filters,doc)"
    click B1 "https://github.com/rrze-hpc/likwid/tree/master/Makefile" "Build Configuration"
    click B2 "https://github.com/rrze-hpc/likwid/blob/master/.github" "CI & Packaging"
```
