@@ -10,9 +10,10 @@ using StorageOrders
1010
1111# OPTIONS SET 1:
1212# Maximum number of samples taken for each benchmark
13- BenchmarkTools. DEFAULT_PARAMETERS. samples = 10
13+ BenchmarkTools. DEFAULT_PARAMETERS. samples = 3
14+ BenchmarkTools. DEFAULT_PARAMETERS. evals = 1
1415# Total amount of time allowed for each benchmark, minimum of 1 sample taken.
15- BenchmarkTools. DEFAULT_PARAMETERS. seconds = 60
16+ BenchmarkTools. DEFAULT_PARAMETERS. seconds = 1000
1617
1718# Comment or uncomment this line to disable or enable MKLSparse respectively.
1819# This will only work for SpMM and SpMV and only operates on CSC.
@@ -26,9 +27,9 @@ const threadlist = [1, Sys.CPU_THREADS ÷ 2]
2627const suite = BenchmarkGroup ()
2728const ssmc = ssmc_db ()
2829
29- function mxm (A:: SparseMatrixCSC , B:: Union{SparseMatrixCSC, DenseArray} )
30- printstyled (" \n C = A::SparseMatrixCSC * B::$(typeof (B)) \n " )
31- result = @benchmark $ A * $ B
30+ function mxm (A:: SparseMatrixCSC , B)
31+ printstyled (" \n C = A::SparseMatrixCSC( $( size (A)) ) * B::$(typeof (B)) ( $( size (B) ) )\n " )
32+ result = @benchmark $ A * $ B samples = 3 evals = 1 seconds = 2
3233 show (stdout , MIME (" text/plain" ), result)
3334 return median (result)
3435end
@@ -37,12 +38,18 @@ function mxm(A::SuiteSparseGraphBLAS.GBArray, B::SuiteSparseGraphBLAS.GBArray; a
3738 Ao = storageorder (A) == ColMajor () ? " C" : " R"
3839 Bo = storageorder (B) == ColMajor () ? " C" : " R"
3940 if ! accumdenseoutput
40- printstyled (" \n C::GBArray = A::GBArray($Ao ) * B::GBArray($Bo )\n " )
41- result = @benchmark mul ($ A, $ B)
41+ printstyled (" \n C::GBArray = A::GBArray($Ao , $(size (A)) ) * B::GBArray($Bo , $(size (B)) )\n " )
42+ gbset (:burble , true )
43+ mul (A, B)
44+ gbset (:burble , false )
45+ result = @benchmark mul ($ A, $ B) samples= 3 evals= 1 seconds= 2
4246 else
43- printstyled (" \n C::GBArray += A::GBArray($Ao ) * B::GBArray($Bo )\n " )
47+ printstyled (" \n C::GBArray += A::GBArray($Ao , $( size (A)) ) * B::GBArray($Bo , $( size (B)) )\n " )
4448 C = GBMatrix (zeros (eltype (A), size (A, 1 ), size (B, 2 )))
45- result = @benchmark mul! ($ C, $ A, $ B; accum= + )
49+ gbset (:burble , true )
50+ mul! (C, A, B; accum= + )
51+ gbset (:burble , false )
52+ result = @benchmark mul! ($ C, $ A, $ B; accum= + ) samples= 3 evals= 1 seconds= 2
4653 end
4754 show (stdout , MIME (" text/plain" ), result)
4855 return median (result)
@@ -64,22 +71,69 @@ function singlebench(pathornum)
6471 printstyled (" Benchmarking $name :\n " ; bold= true , color= :green )
6572 printstyled (" #################################################################################\n " ; bold= true , color= :green )
6673 printstyled (" Sparse * Vec\n " ; bold= true )
67- v = rand (eltype (A), size (A, 2 ))
68- v = GBVector (v)
69- printstyled (" A matrix: " )
74+ printstyled (" A matrix: \n " )
7075 show (stdout , MIME (" text/plain" ), A)
71- printstyled (" B matrix: " )
72- show (stdout , MIME (" text/plain" ), v)
73- gbresultsR = runthreaded (A, v; accumdenseoutput= true )
76+ B = rand (eltype (A), size (A, 2 ))
77+ B = GBVector (B)
78+
79+ printstyled (" B matrix: \n " )
80+ show (stdout , MIME (" text/plain" ), B)
81+
82+ gbresultsR = runthreaded (A, B; accumdenseoutput= true )
7483 gbset (A, :format , SuiteSparseGraphBLAS. BYCOL)
7584 diag (A)
76- show (stdout , MIME (" text/plain" ), A)
77- gbresultsC = runthreaded (A, v; accumdenseoutput= true )
78- SAresults = mxm (SparseMatrixCSC (A), Vector (v))
79- println ((gbresultsR, gbresultsC, SAresults))
85+ gbresultsC = runthreaded (A, B; accumdenseoutput= true )
86+ SAresults = mxm (SparseMatrixCSC (A), Vector (B))
87+ printstyled (" RESULTS, Sparse * DenseVec: \n " ; bold= true , color= :green )
88+ println (" A by row: $gbresultsR " )
89+ println (" A by col: $gbresultsC " )
90+ println (" SparseArrays: $SAresults " )
8091
81- B = GBMatrix (rand (eltype (A), size (A, 2 ), 160 ))
92+ B = GBMatrix (rand (eltype (A), size (A, 2 ), 2 ))
93+ printstyled (" B matrix: \n " )
94+ show (stdout , MIME (" text/plain" ), B)
95+ gbset (A, :format , SuiteSparseGraphBLAS. BYROW)
96+ diag (A)
97+ gbresultsR = runthreaded (A, B; accumdenseoutput= true )
98+ gbset (A, :format , SuiteSparseGraphBLAS. BYCOL)
99+ diag (A)
100+ gbresultsC = runthreaded (A, B; accumdenseoutput= true )
101+ SAresults = mxm (SparseMatrixCSC (A), Matrix (B))
102+ printstyled (" RESULTS, Sparse * n x 2 Dense: \n " ; bold= true , color= :green )
103+ println (" A by row: $gbresultsR " )
104+ println (" A by col: $gbresultsC " )
105+ println (" SparseArrays: $SAresults " )
82106
107+ B = GBMatrix (rand (eltype (A), size (A, 2 ), 32 ))
108+ printstyled (" B matrix: \n " )
109+ show (stdout , MIME (" text/plain" ), B)
110+ gbset (A, :format , SuiteSparseGraphBLAS. BYROW)
111+ diag (A)
112+ gbresultsR = runthreaded (A, B; accumdenseoutput= true )
113+ gbset (A, :format , SuiteSparseGraphBLAS. BYCOL)
114+ diag (A)
115+ gbresultsC = runthreaded (A, B; accumdenseoutput= true )
116+ SAresults = mxm (SparseMatrixCSC (A), Matrix (B))
117+ printstyled (" RESULTS, Sparse * n x 32 Dense: \n " ; bold= true , color= :green )
118+ println (" A by row: $gbresultsR " )
119+ println (" A by col: $gbresultsC " )
120+ println (" SparseArrays: $SAresults " )
121+
122+
123+ gbset (A, :format , SuiteSparseGraphBLAS. BYROW)
124+ diag (A)
125+ gbresultsR = runthreaded (A, transpose (A))
126+ gbset (A, :format , SuiteSparseGraphBLAS. BYCOL)
127+ diag (A)
128+ gbresultsC = runthreaded (A, transpose (A))
129+ A2 = SparseMatrixCSC (A)
130+ SAresults = mxm (A2, transpose (A2))
131+ println ()
132+ printstyled (" \n\n RESULTS, Sparse * Sparse: \n " ; bold= true , color= :green )
133+ println (" A by row: $gbresultsR " )
134+ println (" A by col: $gbresultsC " )
135+ println (" SparseArrays: $SAresults " )
136+ println ()
83137 return nothing
84138end
85139
0 commit comments