mgpusim icon indicating copy to clipboard operation
mgpusim copied to clipboard

Separate task locations for different task types in Compute Unit tracing

Open Copilot opened this issue 4 months ago • 0 comments

Problem

Previously, different types of tasks (wavefronts, instruction fetch operations, and memory transactions) were all recorded at the same trace location - the Compute Unit (CU) level. This made it difficult to distinguish between different operation types when analyzing simulation traces, as all these heterogeneous tasks appeared mixed together at GPU[X].CU[Y].

Solution

This PR ensures each task type is recorded at its own specific location within the CU hierarchy by using StartTaskWithSpecificLocation instead of StartTask for task tracing. Each functional unit now has its own distinct trace location:

Changes by Task Type

  1. Sampled Wavefronts (computeunit.go)

    • Location changed from CUCU.WFPool
    • Now consistent with regular wavefront tracing
  2. Instruction Fetch Tasks (scheduler.go)

    • Location changed from CUCU.InstFetch
    • Clearly separates fetch operations from other CU activities
  3. Vector Memory Transactions (vectormemoryunit.go)

    • Location changed from CUCU.VectorMemUnit
    • Replaced TraceReqInitiate with StartTaskWithSpecificLocation (no location-aware variant exists)
    • Maintains identical behavior with added location support
  4. Scalar Memory Transactions (scalarunit.go)

    • Location changed from CUCU.ScalarUnit
    • Same approach as vector memory transactions

Example

Before:

GPU[1].CU[0]
├─ Wavefront task
├─ Fetch task
├─ Vector memory transaction
└─ Scalar memory transaction

After:

GPU[1].CU[0]
├─ .WFPool
│   └─ Wavefront task
├─ .InstFetch
│   └─ Fetch task
├─ .VectorMemUnit
│   └─ Vector memory transaction
└─ .ScalarUnit
    └─ Scalar memory transaction

Impact

  • No functional changes - simulation behavior remains identical
  • Improved trace organization - task types are now clearly separated in the trace hierarchy
  • Better analysis - trace analysis tools can filter by specific functional units
  • Backward compatible - existing tools continue to work with more granular location data

Testing

  • ✅ Full build successful
  • ✅ Linter passed with no new issues
  • ✅ Acceptance tests passed (FIR, AES, stencil2d benchmarks)
  • ✅ CodeQL security scan passed
  • ✅ Manual validation with timing and emulation modes

Fixes #[issue_number]

Original prompt

This section details on the original issue you should resolve

<issue_title>One type of task in one trace location</issue_title> <issue_description>Currently, we mix many different levels of tasks at the same location when tracing tasks. For example, workgroups, wavefronts, and memory transactions are all recorded at the CU level. This needs to be changed so that each level have their own locations, even if they happen in the same component.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes sarchlab/mgpusim#221


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Oct 22 '25 23:10 Copilot