@@ -10,9 +10,10 @@ using StorageOrders
10
10
11
11
# OPTIONS SET 1:
12
12
# 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
14
15
# 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
16
17
17
18
# Comment or uncomment this line to disable or enable MKLSparse respectively.
18
19
# This will only work for SpMM and SpMV and only operates on CSC.
@@ -26,9 +27,9 @@ const threadlist = [1, Sys.CPU_THREADS ÷ 2]
26
27
const suite = BenchmarkGroup ()
27
28
const ssmc = ssmc_db ()
28
29
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
32
33
show (stdout , MIME (" text/plain" ), result)
33
34
return median (result)
34
35
end
@@ -37,12 +38,18 @@ function mxm(A::SuiteSparseGraphBLAS.GBArray, B::SuiteSparseGraphBLAS.GBArray; a
37
38
Ao = storageorder (A) == ColMajor () ? " C" : " R"
38
39
Bo = storageorder (B) == ColMajor () ? " C" : " R"
39
40
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
42
46
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 " )
44
48
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
46
53
end
47
54
show (stdout , MIME (" text/plain" ), result)
48
55
return median (result)
@@ -64,22 +71,69 @@ function singlebench(pathornum)
64
71
printstyled (" Benchmarking $name :\n " ; bold= true , color= :green )
65
72
printstyled (" #################################################################################\n " ; bold= true , color= :green )
66
73
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 " )
70
75
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 )
74
83
gbset (A, :format , SuiteSparseGraphBLAS. BYCOL)
75
84
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 " )
80
91
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 " )
82
106
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 ()
83
137
return nothing
84
138
end
85
139
0 commit comments