↓Skip to main content
  1. /classes/
  2. Classes, Fall 2026/
  3. CS 4250 Fall 2026: Course Site/

cs4250 Notes: 10-30 Matrix Multiplication

·185 words·1 min·

The stereotypical parallel compute task is multiplying two matrices.

Unfortunately, we don’t have linear algebra as a requirement in our CS program, nor do we do any of the things that it enables, so why this is something you’d want to do isn’t immediately obvious, but here’s the basic procedure:

  • You can multiply an M×N matrix A with an N×P matrix B to get an M×P matrix C.
  • Formula: C[i][j] = sum(k = 1..n, A[i][k] * B[k][j])
  • That means each row of A multiplies with a column of B pairwise, and the sum of that to is one cell of C.
  • To make this a bit simpler, making N=M=P gives you that you can multiply together two square matrices to get a square matrix of the same size.

Simple example cases:

  • Identity matrix (diagonal 1’s)
  • Doubling matrix (diagonal 2’s)

Code Examples

Stuff to look at:

seq

  • Read mmul
  • Run bench 1000
  • Run bench 1024
  • Read mmul2

threads

  • Show bench 1024
  • Show bench 2000
  • Show bench 4000

gpu

  • We can get up to bench 8000
  • Mabye higher?

Then keep going with the GPU slides.

GPU Slides

Nat Tuck
Author
Nat Tuck