Parallel Work on Matrix Rows

An operation can assign each output row to a worker when output writes are separate and any shared inputs remain suitably available.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace row sums
  2. Check when rows are dependent
  3. Assign distinct output rows for a matrix–vector product
  4. Include result order and data locality

Trace row sums

For rows [2, 3] and [4, 6], separate workers can compute five and ten. The output positions preserve original row identity. Row and column indices identify those positions.

Check when rows are dependent

A running total over rows needs earlier results or an additional combine pass. Prefix scans show the dependency introduced by that output.[1]

Assign distinct output rows for a matrix–vector product

For a matrix times a fixed vector, each output row is one dot product. Workers can read the vector and separate matrix rows, then write disjoint outputs. Equal row counts can hide unequal costs for sparse rows. See matrix–vector products.

Row 0 [1,2] × vector [3,4] → 11
Row 1 [5,0] × same vector → 15
Workers write positions 0 and 1 respectively

Include result order and data locality

Finishing row one first need not put it first in the output. Attach a row ID or write directly at the desired position. Test a short remainder chunk and empty input.

References

  1. OpenMP Architecture Review Board, OpenMP API Specifications ↩