Repository navigation
Thread s/d omatcopy for large matrices - #6237
Open
aalquwayfili wants to merge 1 commit into
Open
aalquwayfili wants to merge 1 commit into
aalquwayfili wants to merge 1 commit into
Conversation
omatcopy always ran on one thread. Split A into blocks of rows (row-major) or columns (column-major) with blas_level1_thread and run the kernel on each block. For the transposed copies BLAS_TRANSB_T moves B by the block width. Copies below 65536 * GEMM_MULTITHREAD_THRESHOLD elements stay on one thread. The transposed ones give each thread at least 32 rows or columns, since narrower bands make the threads write into the same cache lines of B. Add domatcopy tests that are large enough to use the threaded path.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #6135 for #4902: omatcopy now uses threads for big matrices.
Each thread gets a block of rows (or columns for column-major) through
blas_level1_thread, andBLAS_TRANSB_Thandles where that block lands in B for the transposed copies.Two limits: small copies stay on one thread (
65536 * GEMM_MULTITHREAD_THRESHOLD, like gemv/ger), and in the transposed copies each thread gets at least 32 rows/columns. Without the second one the threads were fighting over the same cache lines of B, e.g. 8192x32 ColMajor/Trans got 2x slower on 16 threads.cblas_domatcopyon a 16-core i9-9960X, GB/s, 1 -> 16 threads:It tops out around 8 threads here (memory bandwidth), and 4000x10000 is actually a bit faster on 8. On the shapes from #4902 it now beats the OpenMP dcopy loop from the issue (about 0.25 s vs 0.32 to 0.35 s), so maybe that one can be closed. I can't compare with MKL though.
Output is bitwise the same as on one thread. I added four 600x500 tests since the existing ones are too small to hit the threaded path.
One side effect: with the pthreads build, calling it inside an OpenMP loop now prints the "Detect OpenMP Loop" warning, like daxpy does.