Balance Kernel Workloads Across Compute Units Greedily

Last updated: November 29, 2026

Quick Overview

Given the estimated durations of independent GPU work groups and a number of compute units, assign each work group to a unit so that the time until the last unit finishes (the makespan) is small. Return the makespan and the unit chosen for each work group using the longest-processing-time-first heuristic.

AMD
Coding & Algorithms
Software Engineer
AMD
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Given the estimated durations of independent GPU work groups and a number of compute units, assign each work group to a unit so that the time until the last unit finishes (the makespan) is small. Return the makespan and the unit chosen for each work group using the longest-processing-time-first heuristic.

A technical screen in the style of AMD GPU runtime and library teams, where uneven work distribution across compute units leaves silicon idle and caps throughput on Instinct accelerators. The interviewer checks heap usage, the reasoning behind sorting longest first, and awareness that exact makespan minimization is NP-hard.

What the Interviewer Expects
  • State that exact minimization is NP-hard and a heuristic is expected
  • Sort work longest first, breaking ties by index for determinism
  • Use a min-heap of (load, unit) to pick the least loaded unit
  • Return both makespan and per-item assignment
  • Mention the 4/3 approximation bound of LPT
  • Give O(n log n + n log m) complexity
Key Topics to Cover
greedy algorithms
heaps
load balancing
GPU scheduling
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 does the answer change if durations are unknown until the work group runs?
  • How would you model units that run at different clock speeds?
  • When would round-robin assignment be good enough?
  • How would you get an exact answer for very small n?
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, a list of non-negative numbers, and num_units >= 1. Output: (makespan, assignment) where assignment[i] is the unit for work group i. Work groups are independent and non-pre...

High-Level Design

Exact makespan minimization on identical machines is NP-hard, so use LPT: process items from longest to shortest and give each to the currently least loaded unit. Placing big items first leaves small ...


Submit Your Answer
Markdown supported

Related Questions