7373
7474function tpose (A:: SuiteSparseGraphBLAS.GBArray )
7575 Ao = storageorder (A) == ColMajor () ? " C" : " R"
76- Bo = storageorder (B) == ColMajor () ? " C" : " R"
77- printstyled (stdout , " \n C::GBArray = transpose(A::GBArray($Ao , $(size (A)) ))\n " )
78- result = @gbbench copy (transpose (A))
76+ C = similar (A)
77+ gbset (C, :format , storageorder (A) === ColMajor () ? SuiteSparseGraphBLAS. BYCOL : SuiteSparseGraphBLAS. BYROW)
78+ Co = storageorder (A) == ColMajor () ? " C" : " R"
79+ printstyled (stdout , " \n C::GBArray($(Co) ) = transpose(A::GBArray($Ao , $(size (A)) ))\n " )
80+ result = @gbbench SuiteSparseGraphBLAS. gbtranspose! (C, A)
7981 println (stdout , result, " s" )
8082 GC. gc ()
8183 flush (stdout )
@@ -91,7 +93,45 @@ function tpose(A::SparseMatrixCSC)
9193 return result
9294end
9395
94- function spdbench (A)
96+ function runthreadedt (A; accumdenseoutput= false )
97+ v = []
98+ for t ∈ threadlist
99+ printstyled (stdout , " \n Running GraphBLAS with $t threads\n " ; bold= true )
100+ gbset (:nthreads , t)
101+ push! (v, tpose (A))
102+ end
103+ return v
104+ end
105+
106+ function idx (C, A, I, J)
107+ if C isa SuiteSparseGraphBLAS. AbstractGBArray
108+ Ao = storageorder (A) == ColMajor () ? " C" : " R"
109+ Co = storageorder (A) == ColMajor () ? " C" : " R"
110+ printstyled (stdout , " \n C::GBArray($(Co) )[I, J] = A::GBArray($Ao , $(size (A)) )\n " )
111+ result = @gbbench begin
112+ C[I, J] = A
113+ wait (C)
114+ end
115+ println (stdout , result, " s" )
116+ GC. gc ()
117+ else
118+ printstyled (stdout , " \n C[I, J] = A::SparseMatrixCSC($(size (A)) )\n " )
119+ result = @bench C[I, J] = A
120+ println (stdou, result, " s" )
121+ GC. gc ()
122+ end
123+ flush (stdout )
124+ return result
125+ end
126+
127+ function runthreadedidx (C, A, I, J)
128+ v = []
129+ for t ∈ threadlist
130+ printstyled (stdout , " \n Running GraphBLAS with $t threads\n " ; bold= true )
131+ gbset (:nthreads , t)
132+ push! (v, idx (C, A, I, J))
133+ end
134+ return v
95135end
96136
97137function singlebench (pathornum)
@@ -113,12 +153,13 @@ function singlebench(pathornum)
113153 printstyled (stdout , " \n #################################################################################\n " ; bold= true , color= :green )
114154 printstyled (stdout , " Benchmarking $name :\n " ; bold= true , color= :green )
115155 printstyled (stdout , " #################################################################################\n " ; bold= true , color= :green )
156+
116157 printstyled (stdout , " \n Sparse * Vec\n " ; bold= true )
117158 println (stdout , " ################################" )
118159 flush (stdout )
119160 B = rand (eltype (A), size (A, 2 ))
120161 B = GBVector (B)
121-
162+ #
122163 gbresultsR = runthreaded (A, B; accumdenseoutput= true )
123164 gbset (A, :format , SuiteSparseGraphBLAS. BYCOL)
124165 diag (A)
@@ -130,7 +171,7 @@ function singlebench(pathornum)
130171 println (stdout , " A by col (1, 2, 16 thread): $gbresultsC " )
131172 println (stdout , " SparseArrays: $SAresults " )
132173 flush (stdout )
133-
174+ #
134175 printstyled (stdout , " \n Sparse * (n x 2)\n " ; bold= true )
135176 println (stdout , " ################################" )
136177 flush (stdout )
@@ -148,7 +189,7 @@ function singlebench(pathornum)
148189 println (stdout , " A by col (1, 2, 16 thread): $gbresultsC " )
149190 println (stdout , " SparseArrays: $SAresults " )
150191 flush (stdout )
151-
192+ #
152193 printstyled (stdout , " \n Sparse * (n x 32)\n " ; bold= true )
153194 println (stdout , " ################################" )
154195 flush (stdout )
@@ -166,7 +207,7 @@ function singlebench(pathornum)
166207 println (stdout , " A by col (1, 2, 16 thread): $gbresultsC " )
167208 println (stdout , " SparseArrays: $SAresults " )
168209 flush (stdout )
169-
210+ #
170211 printstyled (stdout , " \n Sparse * Sparse'" ; bold= true )
171212 println (stdout , " ################################" )
172213 flush (stdout )
@@ -179,32 +220,31 @@ function singlebench(pathornum)
179220 A2 = SparseMatrixCSC (A)
180221 SAresults = mxm (A2, transpose (A2))
181222 println (stdout , )
182- printstyled (stdout , " \n RESULTS, Sparse * Sparse : \n " ; bold= true , color= :green )
223+ printstyled (stdout , " \n RESULTS, Sparse * n x 32 Dense : \n " ; bold= true , color= :green )
183224 println (stdout , " ################################" )
184225 println (stdout , " A by row (1, 2, 16 thread): $gbresultsR " )
185226 println (stdout , " A by col (1, 2, 16 thread): $gbresultsC " )
186227 println (stdout , " SparseArrays: $SAresults " )
187228 flush (stdout )
188229
189- printstyled (stdout , " \n Sparse * Sparse' " ; bold= true )
230+ printstyled (stdout , " \n C = copy(transpose(A)) " ; bold= true )
190231 println (stdout , " ################################" )
191232 flush (stdout )
192233 gbset (A, :format , SuiteSparseGraphBLAS. BYROW)
193234 diag (A)
194- gbresultsR = runthreaded (A, transpose (A) )
235+ gbresultsR = runthreadedt (A )
195236 gbset (A, :format , SuiteSparseGraphBLAS. BYCOL)
196237 diag (A)
197- gbresultsC = runthreaded (A, transpose (A) )
198- A2 = SparseMatrixCSC (A)
199- SAresults = mxm (A2, transpose (A2) )
238+ gbresultsC = runthreadedt (A )
239+ A2 = SparseMatrixCSC (A)
240+ SAresults = tpose (A2)
200241 println (stdout , )
201- printstyled (stdout , " \n RESULTS, Sparse * Sparse : \n " ; bold= true , color= :green )
242+ printstyled (stdout , " \n RESULTS, C = copy(transpose(A)) : \n " ; bold= true , color= :green )
202243 println (stdout , " ################################" )
203244 println (stdout , " A by row (1, 2, 16 thread): $gbresultsR " )
204245 println (stdout , " A by col (1, 2, 16 thread): $gbresultsC " )
205246 println (stdout , " SparseArrays: $SAresults " )
206247 flush (stdout )
207-
208248 return nothing
209249end
210250
0 commit comments