Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

map/map! for sparse matrices #19438

Merged
merged 1 commit into from
Dec 2, 2016
Merged

map/map! for sparse matrices #19438

merged 1 commit into from
Dec 2, 2016

Conversation

Sacha0
Copy link
Member

@Sacha0 Sacha0 commented Nov 28, 2016

This pull request provides (1) a map/map! implementation specialized for a single (input) sparse matrix, (2) a map/map! implementation specialized for a pair of (input) sparse matrices, and (3) a general map/map! implementation capable of efficiently handling an arbitrary number of sparse matrices (within compiler limits). broadcast/broadcast! over a single (input) sparse matrix being identical to map/map! over the same, this pull request also reimplements broadcast/broadcast! over a single (input) sparse matrix as short children of map/map!.

The semantics of these map!/broadcast! methods are those discussed in #19372. Notably these map!/broadcast! methods only allocate when strictly necessary, so for example

julia> C = spzeros(5,5); A = speye(5); B = sparse(Bidiagonal(zeros(5), ones(4), true));

julia> @allocated map!(*, C, A, B) # after warmup
0

Additionally, where these map!/broadcast! methods do allocate, they do so less pessimistically than the existing broadcast! methods.

The specialized map/map! methods achieve performance similar to corresponding existing broadcast/broadcast! methods (despite performing slightly more work to enable the more precise allocation behavior). The former win in some cases and the latter in others, with runtime differences usually ~10% or less in (hopefully realistic) tests.

The general map/map! methods achieve performance not too far behind the methods specialized for pairs of (input) sparse matrices. The latter typically best the former by only 10-35% runtime, though in some cases they're on par and in others the gap stretches to 45%.

Fixes (the SparseMatrixCSC part of) #19363. Also relevant to #16285 and friends as a step in the sparse broadcast/broadcast! overhaul. Best!

(Realized this PR lacks a map!(f, A) method. Punting to a followup PR.)

@Sacha0 Sacha0 added domain:arrays:sparse Sparse arrays domain:broadcast Applying a function over a collection labels Nov 28, 2016
@Sacha0
Copy link
Member Author

Sacha0 commented Nov 28, 2016

The abstractarray test failure should be fixed.

@Sacha0
Copy link
Member Author

Sacha0 commented Nov 28, 2016

Travis macOS hit an openblas-related error seemingly similar to that in #19379?

@Sacha0
Copy link
Member Author

Sacha0 commented Nov 30, 2016

Absent objections or requests for time, I plan to merge this Friday morning PST. Best!

…dcast! over a single sparse matrix in terms of map/map!.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:arrays:sparse Sparse arrays domain:broadcast Applying a function over a collection
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant