Skip to content

Parallelization along K-dimension (Parallel Reduction) for GEMM with small M/N and large K #5629

Description

@seulchanson

Hi OpenBLAS team,

I noticed that zgemm (and other GEMM functions) falls back to single-threaded execution when M and N are small (e.g., 32) but K is extremely large (e.g., 1,000,000).

On my many-core system, this leaves most cores idle. Given the large K size, parallelizing the K-loop (via parallel reduction) should theoretically offer significant speedup. I perform the matrix partitioning (of k) externally, and then use multithreading to call zgemm, but the performance is only average.

Questions:

Does OpenBLAS currently support threading along the K-dimension for this shape?

If not, are there any plans to implement parallel reduction for large K?

My Machine Info:

Image Image

Thanks!

Activity

  1. seulchanson commented on Jan 28, 2026

    @seulchanson
    Author

    MKL performs quite well with these types of tall and thin matrices (m and n are small, k is large), but OpenBLAS almost degrades to vectorized computation. 🥲

    The context of this problem is large-scale physical simulation programs, where OpenBLAS (zgemm) is used to compute the MGS process for block-GMRES.

  2. ChipKerchner commented on Mar 31, 2026

    @ChipKerchner
    Contributor

    Parallelizing K can cause epsilon differences dependent on number of threads.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions