File: test49.m

package info (click to toggle)
suitesparse-graphblas 7.4.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 67,112 kB
  • sloc: ansic: 1,072,243; cpp: 8,081; sh: 512; makefile: 506; asm: 369; python: 125; awk: 10
file content (50 lines) | stat: -rw-r--r-- 1,071 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function test49
%TEST49 performance test of GrB_mxm (dot product method, A'*B)

% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
% SPDX-License-Identifier: Apache-2.0

[save save_chunk] = nthreads_get ;
chunk = 4096 ;
nthreads = feature_numcores ;
nthreads_set (nthreads, chunk) ;

d = struct ('inp0', 'tran', 'axb', 'dot') ;

rng ('default') ;
k = 1e6 ;

semiring.multiply = 'times' ;
semiring.add = 'plus' ;
semiring.class = 'double' ;

A1 = sprand (k, 16, 10e6 / (k*16)) ;
B1 = sprand (k, 16, 10e6 / (k*16)) ;

for m = 1:4
    for n = 1:4

        A = A1 (:, 1:m) ;
        B = B1 (:, 1:n) ;

        W = sparse (m, n) ;

        tic ;
        C = A'*B ;
        t1 = toc  ;

        tic ;
        C2 = GB_mex_mxm (W, [], [], semiring, A, B, d) ;
        t2 = toc ;

        e = norm (C - C2.matrix, 1) ;
        fprintf (...
       'm %3d n %3d built-in: %10.5g  GrB: %10.5g  speedup %10.2f  err: %g\n', ...
           m, n, t1, t2, t1/t2, e) ;
    end
end

nthreads_set (save, save_chunk) ;

fprintf ('\ntest49: all tests passed\n') ;