@@ -153,3 +153,53 @@ function benchmark_three_arg_dot!(
153153
154154 return nothing
155155end
156+
157+ """
158+ benchmark_sparse_dense_add!(SUITE, array_constructor, array_type_name; N=10000, T=Float64)
159+
160+ Benchmark sparse + dense matrix addition for CSC, CSR, and COO formats.
161+
162+ # Arguments
163+ - `SUITE`: The BenchmarkGroup to add benchmarks to
164+ - `array_constructor`: Function to construct arrays (e.g., `Array`, `JLArray`)
165+ - `array_type_name`: String name for the array type (for display)
166+
167+ # Keyword Arguments
168+ - `N`: Size of the matrix (default: 10000)
169+ - `T`: Element type (default: Float64)
170+ """
171+ function benchmark_sparse_dense_add!(
172+ SUITE,
173+ array_constructor,
174+ array_type_name;
175+ N = 10000 ,
176+ T = Float64,
177+ )
178+ # Create sparse matrix with 1% density
179+ sm_csc_std = sprand(T, N, N, 0.01 )
180+
181+ # Convert to different formats
182+ sm_csc = DeviceSparseMatrixCSC(sm_csc_std)
183+ sm_csr = DeviceSparseMatrixCSR(sm_csc_std)
184+ sm_coo = DeviceSparseMatrixCOO(sm_csc_std)
185+
186+ # Adapt to device
187+ dsm_csc = adapt(array_constructor, sm_csc)
188+ dsm_csr = adapt(array_constructor, sm_csr)
189+ dsm_coo = adapt(array_constructor, sm_coo)
190+
191+ # Create dense matrix
192+ dense_mat = adapt(array_constructor, randn(T, N, N))
193+
194+ # Level 3: Format (CSC, CSR, COO - will be plotted together)
195+ SUITE[" Sparse + Dense Addition" ][array_type_name][" CSC" ] =
196+ @benchmarkable $ dsm_csc + $ dense_mat
197+
198+ SUITE[" Sparse + Dense Addition" ][array_type_name][" CSR" ] =
199+ @benchmarkable $ dsm_csr + $ dense_mat
200+
201+ SUITE[" Sparse + Dense Addition" ][array_type_name][" COO" ] =
202+ @benchmarkable $ dsm_coo + $ dense_mat
203+
204+ return nothing
205+ end
0 commit comments