Earliest Completion Time for Dependent Kernel Launches

Last updated: November 29, 2026

Quick Overview

You are given durations for GPU kernels and a list of dependencies (a, b) meaning b may start only after a finishes. Assuming unlimited parallel hardware, return the earliest time all kernels finish and each kernel's earliest start time, or report a cycle.

AMD
Coding & Algorithms
Software Engineer
AMD
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


You are given durations for GPU kernels and a list of dependencies (a, b) meaning b may start only after a finishes. Assuming unlimited parallel hardware, return the earliest time all kernels finish and each kernel's earliest start time, or report a cycle.

An onsite coding round in the style of AMD HIP runtime and graph teams, where HIP graphs and multi-stream applications form a dependency DAG and the critical path bounds achievable latency. The interviewer checks topological sorting, longest path in a DAG, and cycle detection.

What the Interviewer Expects
  • Model the problem as longest path in a DAG
  • Use Kahn's algorithm with in-degrees
  • Propagate start time as the max finish time of predecessors
  • Detect cycles when not every node is processed
  • Return the overall finish as max start plus duration
  • Give O(V + E) complexity
Key Topics to Cover
topological sort
DAG longest path
critical path
cycle detection
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you recover the actual critical path, not just its length?
  • How does the answer change with only two hardware queues?
  • How would you incrementally update finish times when one kernel's duration changes?
  • Where do implicit dependencies come from in real multi-stream code?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: durations (list, kernel i has durations[i]) and deps, pairs (before, after). Output: (finish_time, start_times) or None if the dependencies contain a cycle. Kernels with no predeces...

High-Level Design

Earliest start of kernel v is the max over predecessors u of start[u] + durations[u]. That is a longest path computation, which is easy on a DAG in topological order. Kahn's algorithm gives that ord...


Submit Your Answer
Markdown supported

Related Questions