FastPrepMatrix Multiplication and Parallel Partitions
Problems/Matrix Multiplication and Parallel Partitions

Matrix Multiplication and Parallel Partitions

AMD logoAMD● MediumFULLTIMENEW GRADINTERNPHONE SCREENONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: Three earlier reports cover matrix multiplication for experienced SDE2, new-graduate GPU and ML internship roles. The new-graduate material adds row, block/grid and shared-dimension worker partitions. A further experienced report says matrix tiling was asked twice in one interview loop; this is one report, not two independent sightings. Compatible shapes, integer bounds, portable APIs, worker code and the four-wide tiling example are authored practice choices. Allocation/free behavior, GPU execution and speed are not graded. Approximate source match: 90%.

Multiply an M×K matrix first by a K×N matrix second. Return the M×N matrix whose [r][c] entry is the sum of first[r][k]*second[k][c] over all shared-dimension indices. Leave both inputs unchanged. Values and dimensions guarantee signed32-bit results.

Parallelization follow-up: partition independent output rows, then compare splitting K into partial products and reducing them. The editorials include actual worker implementations for both partitions. The numeric judge checks returned values; it does not require a speedup or measure scheduling performance. Memory-allocation/deallocation is a separate source task and is not certified by this product-only judge.

Tiling follow-up: compute the same product in small blocks and explain how nearby matrix elements can be reused. The report says this coding topic was asked twice, but gives no tile size, device API or memory layout. The editorial uses ordinary CPU loops with an authored tile size of four and handles partial edge tiles. The judge checks the resulting product, not cache traffic, GPU execution or speed.

Function

matrixMultiply(first: int[][], second: int[][]) → int[][]

Examples

Example 1

first = [[1,2,3],[4,5,6]]second = [[7,8],[9,10],[11,12]]return = [[58,64],[139,154]]

The first row gives 1*7 + 2*9 + 3*11 = 58 and 1*8 + 2*10 + 3*12 = 64. The second row gives 4*7 + 5*9 + 6*11 = 139 and 4*8 + 5*10 + 6*12 = 154.

Example 2

first = [[2,-1]]second = [[3],[4]]return = [[2]]

The only dot product is 2*3 + (-1)*4 = 2.

Constraints

  • 1 <= first.length <= 16.
  • 1 <= first[r].length <= 512.
  • 1 <= second.length <= 512.
  • 1 <= second[r].length <= 16.
  • -100 <= every input matrix value <= 100.
  • Both matrices are rectangular, and every row of first has exactly second.length entries.

More AMD problems

  • Insert After a Linked-List NodeONSITE INTERVIEW · Seen Oct 2026
  • LRU CacheONSITE INTERVIEW · Seen Oct 2026
  • Lowest Common Ancestor of a Binary TreePHONE SCREEN · Seen Oct 2026
All AMD interview questionsSee AMD hiring insights
Saved
public int[][] matrixMultiply(int[][] first, int[][] second) {
    // Write your code here.
}
Checking account…