1function test123
2%TEST123 test MIS on large matrix
3
4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
5% SPDX-License-Identifier: Apache-2.0
6
7fprintf ('test123: test MIS on large matrix\n') ;
8
9Prob = ssget (2662)
10A = Prob.A ;
11
12% make symmetric and remove self edges
13fprintf ('prep (in MATLAB):\n') ;
14tic
15A = spones (A) ;
16A = A+A' ;
17A = tril (A,-1) ;
18A = A+A' ;
19n = size (A,1) ;
20toc
21
22ncores = feature ('numcores') ;
23
24for seed = 1:3
25    fprintf ('\n') ;
26
27    for nthreads = [1 2 4 8 16 20 32 40 64 128 160 320]
28        if (nthreads > 2*ncores)
29            break ;
30        end
31        nthreads_set (nthreads) ;
32        tic
33        s = GB_mex_mis (A, seed) ;
34        t = toc ;
35
36        p = find (s == 1) ;
37        S = A (p,p) ;
38        % make sure it's independent
39        assert (nnz (S) == 0)
40
41        if (nthreads == 1)
42            t1 = t ;
43        end
44
45        isize = nnz (s) ;
46        fprintf ('%3d threads: %8.4f sec, speedup %6.2f', nthreads, t, t1/t) ;
47        fprintf (' iset: %d of %d (%8.2f %%)\n', ...
48            isize, n, 100 * isize / n) ;
49    end
50end
51
52fprintf ('amd run time, for comparison:\n') ;
53tic
54p = amd (A) ;
55toc
56
57fprintf ('test123: all tests passed\n') ;
58