← Back to Pull requests

Add HIP-Basic execution context example #485

Closed
unknown closed this pull request without merging on Aug 24, 2026 12:01 UTC
View on GitHub
unknown unknown commented on Jul 14, 2026 18:49 UTC
Author

Motivation

Demonstrate partitioning a device's compute units into separate execution contexts, running a long-running background kernel and a latency-sensitive critical kernel on their own dedicated resources. Register the example in the HIP-Basic CMake build and the top-level README.

Technical Details

Adds a new HIP-Basic/execution_context example (HIP's counterpart to CUDA green contexts).

  • Queries the device's compute units with hipDeviceGetDevResource (hipDevResourceTypeSm), splits them with hipDevSmResourceSplit, wraps each group in a descriptor via hipDevResourceGenerateDesc, and creates an execution context per group with hipGreenCtxCreate.

  • A stream created on each context with hipExecutionCtxStreamCreate confines its kernels to that context's CUs.
  • Runs a fixed critical workload concurrently with a device-saturating background kernel and measures the critical kernel's runtime. It first records a baseline where both kernels share all CUs, then sweeps several partition sizes (about an eighth, a quarter, and half of the device), printing a table of each configuration's critical- and background-kernel runtimes plus the critical kernel's speedup over the baseline. As the critical partition grows, its runtime drops below the contended baseline while the background kernel (confined to fewer CUs) takes longer.

  • Partitioning is guarded by __HIP_PLATFORM_AMD__. On the CUDA backend, where the required runtime support may be unavailable, only the shared-CU baseline runs, and the CU-equivalent count is read from hipGetDeviceProperties.

  • Includes a warm-up launch and hipDeviceSynchronize between cases so the device is idle before contexts are created and destroyed.

  • Registered via add_subdirectory(execution_context) in HIP-Basic/CMakeLists.txt and listed in the top-level README.md.
  • Files added: main.hip, CMakeLists.txt, Makefile, README.md, .gitignore.

    Test Plan

  • Build through the HIP-Basic CMake target hip_execution_context and run ./bin/hip_execution_context on an AMD GPU.

  • Verify the baseline row plus one partitioned row per sweep size are printed, that the critical kernel's runtime falls (and

  • speedup rises) as the partition grows, and that the program completes cleanly.

    Test Result

    Run on a 80-CU device (gfx1100): the critical kernel's runtime dropped from the shared baseline (~230 ms) to ~110 ms on larger partitions, roughly a 2x speedup, with the background-kernel runtime rising as its CU share shrank.

    Added/Updated documentation?

  • Yes

  • No, does not apply to this PR.
  • Included Visual Studio files?

  • Yes

  • No, does not apply to this PR.
  • Submission Checklist

  • New examples contain proper CMake and Make files.

  • I have updated relevant CI workflows and the new examples are being built and tested in CI.

  • Check and guard against unsupported ASICs if relevant dependent libraries have limited support.

  • Look over the contributing guidelines at https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
  • Diff: 385 lines (+288 / -97) across 4 files Reviewer: jujiang-del Review duration: 58632m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 385 lines diff across 4 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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
    Diff Size diff_size
    0.356
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #485"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 48% (MEDIUM) · Higher = larger blast radius
    48%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 19.0% · Safe to merge
    19.0%