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

Updates for review comments #247

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions paper/paper.tex
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ \subsection{Matrix-vector product}
The generic implementation in \ma{} exploits the mutability of the elements of \lstinline|c|.
This provides a significant speedup and a drastic reduction of memory usage:
\begin{jllisting}
@benchmark add_mul!($c, $A, $b)
@benchmark add_mul!!($c, $A, $b)

# output

Expand Down Expand Up @@ -482,25 +482,27 @@ \subsection{Mutability layers}
Consider the following example using Polynomials~\cite{verzani2021polynomials}.
\begin{jllisting}
using Polynomials
m = 100
n = 10
p(d) = Polynomial(big.(1:d))
z(d) = Polynomial([zero(BigInt) for i in 1:d])
A = [p(d) for i in 1:m, j in 1:n]
b = [p(d) for i in 1:n]
c = [z(2d - 1) for i in 1:m]
A = [p(d) for d in 1:m, _ in 1:n]
b = [p(d) for d in 1:n]
c = [z(2d - 1) for d in 1:m]
\end{jllisting}
The arrays contain 3 layers of mutability:
\lstinline|Array|, \lstinline|Polynomial| and \lstinline|BigInt|.
As shown in the benchmark below,
impact on performance is amplified by the number of layers.
\begin{jllisting}
julia> @benchmark LinearAlgebra.mul!($c, $A, $b)
Time (median): 131.901 ms
Time (mean): 128.542 ms
Memory: 38.02 MiB, allocs: 2032580.
Time (median): 18.132 ms
Time (mean): 46.276 ms
Memory: 30.12 MiB, allocs: 1560450.

julia> @benchmark add_mul!($c, $A, $b)
Time (median): 7.633 ms
Time (mean): 7.687 ms
julia> @benchmark add_mul!!($c, $A, $b)
Time (median): 2.613 ms
Time (mean): 2.789 ms
Memory: 48 bytes, allocs: 3.

julia> buf = buffer_for(
Expand Down