Repository navigation
Parallel smmp - #201
Merged
Merged
Parallel smmp#201
Conversation
Using this bool vector enables to directly store the column indices in the result indices vector, and we should get less cache misses thanks to the usage of a boolean vector to check for duplicate column indices. I also introduce an API to dynamically choose the strategy, to be able to benchmark them. It's possible I keep this API in the future, if it turns out there are some good strategies for specialized workloads. Future work: try a bitvector instead of a bool vector. Try and sort the indices on insertion.
Benchmarks have shown it consistently outperforms the linked list strategy, probably thanks to less cache misses.
This is mostly to establish the structure of parallel computation before it's done in a smarter way.
The work splitting is a bit naive right now, as it splits according to the number of nonzeros of the left-hand side of the product. A future improvement should be to delay sorting to be able to have a more even workload.
It's been shown in the past that they are too slow, we need to keep acceptable bench times.
Benchmarks have shown this is beneficial on a few machines, and there is a configuration to only use physical cores.
This is useful when running profilers, and should not perturb performance too much.
This was referenced Jul 3, 2020
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.
This pull request improves the performance of the sparse matrix product by taking advantage of multiple cores, thanks to rayon. Here are benchmark results demonstrating the improvements (benchmarked on a AMD Ryzen 7 3700X 8-Core Processor this time):
Here's a description of the entries:
Vec<bool>in the symbolic part of the algorithm to check if a column has been seen, which is more cache friendly than the index based "linked list" in the original SMMP algorithmAs before, with no multithreading, it takes a very large matrix to beat scipy's implementation (mostly because we need to sort the indices whereas scipy does not guarantee sorted indices). However, as far as I know scipy's matrix product is not parallelized, so taking advantage of multiple cores gives sprs an advantage.
On smaller shapes it takes a lot of threads to beat scipy (here the shape is 15000 x 25000):
I'm not entirely satisfied with the current multithreading implementation, dividing the work into independent chunks has been a bit clunky, but I'm sure it could be done in a cleaner way. That can wait though, the current state is correct and is a nice milestone.
It's quite possible some performance can be gained in the future, as currently the heuristic to divide the workload for the symbolic part has not been extensively tested, so some threads could be starving. A simple improvement could be to delay the sorting of indices, to know the actual number of nonzeros of the result and be able to divide the sorting workload evenly.