OpenMathLib / OpenMathLib/OpenBLAS

GEMM slower than GEMV slower than AXPY equivalent on Intel i5 CPU

Open
#528 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
7.6k
Forks
1.7k
Avg merge
1d 3h
Merged PRs (30d)
42

Description

Consider the following Julia code (using Julia 0.4-dev):

let
       B = randn(1000, 1000)
       v = randn(1000)
       y = randn(1000); sB = [slice(B, :, j) for j = 1:size(B, 2)]

       @time for i = 1:1000;BLAS.gemm!('N', 'N', 1.0, B, v, 1.0, y);end;

       @time for i = 1:1000;BLAS.gemv!('N', 1.0, B, v, 1.0, y);end;

       @time for i = 1:1000;
           for j = 1:size(B,2)
             BLAS.axpy!(v[j], sB[j], y)
           end
       end
end

On @andreasnoack's machine, a Macbook Pro with i7-4870HQ CPU, GEMM is 4 times slower than GEMV:

elapsed time: 1.084909686 seconds (0 bytes allocated)
elapsed time: 0.2644927 seconds (0 bytes allocated)
elapsed time: 0.321705553 seconds (0 bytes allocated)

On my machine, a Macbook Pro with i5-4258U, I get similar behavior, but also that the AXPY equivalent is the fastest of the 3 computations:

elapsed time: 1.693223657 seconds (0 bytes allocated)
elapsed time: 0.818590556 seconds (0 bytes allocated)
elapsed time: 0.715702898 seconds (0 bytes allocated)

I find the relative performance behaviors surprising.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Julia benchmark using BLAS.gemm!, BLAS.gemv!, and BLAS.axpy! on the reported Intel CPUs, then compare the relative timings. The issue does not name source files, tests, or a specific change; clarify whether the goal is to explain the disparity or improve one operation before defining done.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, julia
Domain
hpc, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.