← Back to Pull requests

Add Fortran (Flang + Enzyme) support to Enzyme Explorer #34

Open
unknown opened this pull request with 240 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 03, 2026 19:23 UTC
Author

Summary


  • Language & Compiler Config:

  • - Enable fortran in restrictToLanguages (frontend/files/etc/config/compiler-explorer.enzyme.properties).
    - Add template_files/etc/config/fortran.enzyme.properties.j2 configuring flang20-enzyme-main and flang21-enzyme-main (defaultCompiler=flang21-enzyme-main, compilerType=flang, Intel/AT&T asm, LLVM IR view, execution, --config=FlangEnzyme-<ver>.cfg for regular and -flto builds, -Xflang -load for -mllvm -enzyme- options, and binaryHideFuncRe for static libFortranRuntime.a / libFortranDecimal.a symbols).
  • Toolchain & .mod Precompilation:

  • - Install flang-${v} for LLVM >= 20 in frontend/install_clang.sh, fetch enzyme_function_hooks.f90 and enzyme.f90 directly from EnzymeAD/Enzyme, and precompile .mod files per Flang version so iso_c_binding.mod checksums match.
    - Add frontend/entrypoint.sh to recompile /opt/compiler-explorer/main/fortran/
    .f90 (synced from Enzyme/main by builder) with each installed /usr/bin/flang-${v} on startup, and sync /app/compiler-explorer/etc/config/.enzyme.properties into /app/etc/config/ when present so live commit hashes display instead of <unknown>.
    - Update scripts/update-versions.py to download LLDEnzyme-{version}.so, FlangEnzyme-{version}.so, and FlangEnzyme-{version}.cfg (published by https://github.com/EnzymeAD/Enzyme/pull/3551), copy Enzyme/enzyme/Fortran/
    .f90 into /opt/compiler-explorer/main/fortran/, and render fortran.enzyme.properties.
  • Builtin Fortran Examples:

  • - Add default.f90, dot_product.f90, forward_mode.f90, custom_derivative.f90, and function_like.f90 under frontend/files/examples/fortran/.

    Verification


  • Verified all 5 Fortran examples across flang-20 and flang-21 (assembly, LLVM IR, binary disassembly, and program execution) via a live local Compiler Explorer server (--env enzyme).
  • Diff: 240 lines (+180 / -60) across 3 files Reviewer: joewallwork Review duration: 29101m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 240 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.328
    Real PR Conversation Timeline
    1 comments
    "Review active on #34"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 38.7% (MEDIUM) · Higher = larger blast radius
    38.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.6% · Safe to merge
    20.6%