Skip to content

Commit

Permalink
Updates for review comments (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat authored Dec 21, 2023
1 parent 69a675d commit 0b3f7d1
Showing 1 changed file with 12 additions and 10 deletions.
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

0 comments on commit 0b3f7d1

Please sign in to comment.