1function test61
2%TEST61 performance test of GrB_eWiseMult
3
4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
5% SPDX-License-Identifier: Apache-2.0
6
7fprintf ('\n----------------------------- eWiseMult performance tests\n') ;
8
9[save save_chunk] = nthreads_get ;
10chunk = 4096 ;
11nthreads = feature ('numcores') ;
12nthreads_set (nthreads, chunk) ;
13
14Prob = ssget (2662)
15A = Prob.A ;
16[m n] = size (A) ;
17
18B = A ;
19A (:, 1:5) = 44 ;
20
21S = sparse (m,n) ;
22fprintf ('\n\nm: %d n %d nnz(A) %d\n', m, n,  nnz (A)) ;
23
24d = nnz (A) / prod (size (A)) ;
25
26    tic
27    C = A .*B ;
28    t1 = toc ;
29
30    tic
31    C2 = GB_mex_Matrix_eWiseMult (S, [ ], [ ], 'times', A, B, [ ]) ;
32    t2 = toc ;
33
34    fprintf (...
35    'd %10.6g nnz(C) %8d MATLAB %10.6f GB %10.6f  speedup %10.4f\n',...
36        d, nnz (C), t1, t2, t1/t2) ;
37
38
39A = sparse (rand (5000)) ;
40[m n] = size (A) ;
41S = sparse (m,n) ;
42fprintf ('\n\nm: %d n %d nnz(A) %d\n', m, n,  nnz (A)) ;
43
44for d = [0.00001:0.00001:0.0001 0.0002:0.0001: 0.001 0.002:.001:0.01 0.02:0.01:.1 1]
45
46    B = sprandn (m, n, d) ;
47
48    tic
49    C = A .*B ;
50    t1 = toc ;
51
52    tic
53    C2 = GB_mex_Matrix_eWiseMult (S, [ ], [ ], 'times', A, B, [ ]) ;
54    t2 = toc ;
55
56    fprintf (...
57    'd %10.6g nnz(C) %8d MATLAB %10.6f GB %10.6f  speedup %10.4f\n',...
58        d, nnz (C), t1, t2, t1/t2) ;
59
60    assert (isequal (C, C2.matrix)) ;
61end
62
63fprintf ('\ntest61: all tests passed\n') ;
64
65nthreads_set (save, save_chunk) ;
66