OpenMathLib / OpenMathLib/OpenBLAS

cblas_simatcopy: poor performance/avx512 instructions not supported

Open
#3,078 6 comments 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

Good afternoon,

I was trying to compare the cblas_simatcopy routine against intel-mkl equivalent and noticed this routine is performing very poorly. I would like to understand if these performance issues were caused by me or if they are inherent to this BLAS implementation.

I've called the routine as defined in intel-mkl documentation:

cblas_simatcopy(CblasRowMajor /* row-major ordering /,
CblasTrans /
A will be transposed /,
n /
rows /,
n /
cols /,
1. /
scales the input matrix /,
src /
source matrix /,
n /
src_stride /,
n /
dst_stride */);

I performed some tests on a Intel(R) Core(TM) i9-10980XE CPU @ 3.00GHz with GCC version 9.3.1 20200408 (Red Hat 9.3.1-2).

The following sequential execution times were obtained for input matrices of size 8000x8000:
cblas_simatcopy -> 0.117561 seconds
mkl_simatcopy -> 0.047644 seconds

The performance of cblas_simatcopy seems to worsen in a multi-threaded environment (same input matrix):
2 cores -> 0.117933 seconds
4 cores -> 0.166409 seconds
8 cores -> 0.198745 seconds

The number of threads was selected using openblas_set_num_threads(num_threads).

Furthermore I've analyzed the asm file generated by cblas_simatcopy and no zmm register was found, which implies no avx512 instruction was used. My processor, however, can support avx512 instruction and so does my compiler version.

My source code follows in attachment.

Thanks in advance for any insight!

simat_cblas.txt

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 with the attached simat_cblas.txt and the cblas_simatcopy invocation, then reproduce the reported timings on the Intel i9-10980XE with different OpenBLAS thread counts. Inspect the generated assembly for AVX512 instructions and compare the single- and multi-threaded results. Done means the cause of the missing AVX512 usage and poor scaling is identified and documented or corrected.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.