# chadhasakka/floating-point-stability-tools architecture

> Architecture diagram of the GitHub repository chadhasakka/floating-point-stability-tools, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chadhasakka/floating-point-stability-tools
- Repository: https://github.com/chadhasakka/floating-point-stability-tools

## Overview

##### Project Type and Purpose
- This is an open-source floating-point stability analysis tool built as an Intel Pin plugin (“MyPinTool”).
- Purpose: instrument existing C programs (e.g., fp-arithmetic.c, fp-error-propagation.c) at runtime, collect floating-point metrics, and report stability or error propagation.

##### Key Components (to show
a. Input Programs
- fp-arithmetic.c
- fp-error-propagation.c
b. Build System
- makefile & makefile.rules
- VS Project file (MyPinTool-clang.vcxproj)
c. Instrumentation Framework
- Intel Pin (external binary)
- MyPinTool.cpp (plugin source) → MyPinTool.o (obj-intel64)
d. Runtime Engine
- Pin Loader
- Tool Callbacks (Instruction-Level Hooks)
e. Output/Analysis
- Logs / Reports (custom format)

##### Architectural Patterns and Principles
- Plugin Architecture: MyPinTool registers callbacks with Pin’s API (Instrumentation Driver pattern).
- Modular Separation:
- Build files separated from source
- Test programs (C files) isolated from the instrumentation code
- Event-Driven Design: instrumentation occurs on each instruction or memory reference callback.

##### Technologies, Frameworks, and Libraries
- Intel Pin SDK (external dependency)
- C++ (MyPinTool.cpp)
- GNU make / MSVC project for cross-platform builds
- Standard C (fp-arithmetic.c, fp-error-propagation.c)

##### Essential Details to Capture
- Pin ↔ Plugin interface showing registration of callbacks.
- Two test programs separately to show extensibility.
- Object directory (obj-intel64) to note the build target.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Inputs
    subgraph "Inputs"
        direction TB
        FP1["fp-arithmetic.c"]:::source
        FP2["fp-error-propagation.c"]:::source
        MAKE["makefile"]:::source
        RULES["makefile.rules"]:::source
        VS["MyPinTool-clang.vcxproj"]:::source
    end

    %% Build & Plugin
    subgraph "Build & Plugin"
        direction TB
        SRC["MyPinTool.cpp"]:::plugin
        OBJDIR["obj-intel64"]:::build
        OBJ["MyPinTool.o"]:::build
        PINSDK["Intel Pin SDK"]:::external
    end

    %% Runtime & Output
    subgraph "Runtime & Output"
        direction TB
        LOADER["Pin Loader"]:::runtime
        CALLBACKS["Tool Callbacks"]:::runtime
        LOGS["Logs / Reports"]:::output
    end

    %% Build-time Dependencies
    FP1 -->|"source"| MAKE
    FP2 -->|"source"| MAKE
    SRC -->|"plugin source"| MAKE
    MAKE -->|"rules from"| RULES
    MAKE -->|"builds"| OBJDIR
    RULES -->|"define targets"| OBJDIR
    OBJDIR -->|"contains"| OBJ
    OBJ -->|"compiled plugin"| PINSDK

    %% Runtime Flow
    PINSDK -->|"loads plugin"| LOADER
    LOADER ---|"on start"| OBJ
    LOADER ---|"registers callbacks"| CALLBACKS
    CALLBACKS ---|"write metrics"| LOGS

    %% Click Events
    click FP1 "https://github.com/chadhasakka/floating-point-stability-tools/blob/main/./fp-arithmetic.c"
    click FP2 "https://github.com/chadhasakka/floating-point-stability-tools/blob/main/./fp-error-propagation.c"
    click MAKE "https://github.com/chadhasakka/floating-point-stability-tools/tree/main/./MyPinTool/makefile"
    click RULES "https://github.com/chadhasakka/floating-point-stability-tools/blob/main/./MyPinTool/makefile.rules"
    click VS "https://github.com/chadhasakka/floating-point-stability-tools/blob/main/./MyPinTool/MyPinTool-clang.vcxproj"
    click SRC "https://github.com/chadhasakka/floating-point-stability-tools/blob/main/./MyPinTool/MyPinTool.cpp"
    click OBJDIR "https://github.com/chadhasakka/floating-point-stability-tools/tree/main/./MyPinTool/obj-intel64"
    click OBJ "https://github.com/chadhasakka/floating-point-stability-tools/blob/main/./MyPinTool/obj-intel64/MyPinTool.o"
    click LOGS "https://github.com/chadhasakka/floating-point-stability-tools/blob/main/./README.md"

    %% Styles
    classDef source fill:#cce5ff,stroke:#004085,color:#004085;
    classDef build fill:#b8daff,stroke:#004085,color:#004085;
    classDef plugin fill:#d4edda,stroke:#155724,color:#155724;
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
    classDef runtime fill:#ffe5b4,stroke:#ff8c00,color:#ff8c00;
    classDef output fill:#f5c6cb,stroke:#721c24,color:#721c24;
```
