File: test30b.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 (46 lines) | stat: -rw-r--r-- 969 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
function test30b
%TEST30B performance test GB_mex_assign, scalar expansion

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

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

Prob = ssget (2662) ;
A = Prob.A ;

[m n] = size (A) ;

ni =  500 ;
nj = 1000 ;
I = randperm (m,ni) ;
J = randperm (n,nj) ;
I0 = uint64 (I-1) ;
J0 = uint64 (J-1) ;

scalar = sparse (pi) ;

% tic/toc includes the mexFunction overhead of making a deep copy
% of the input matrix.

fprintf ('start GraphBLAS:\n') ;
tic
C2 = GB_mex_assign (A, [], [], scalar, I0, J0, []) ;
t = toc ;

C = A ; 
fprintf ('start built-in method:\n') ;
tic 
C (I,J) = scalar ;
tm = toc

fprintf ('GraphBLAS speedup over built-in method: %g\n',  tm/t) ;

assert (isequal (C, C2.matrix)) ;
fprintf ('\ntest30b: all tests passed\n') ;

nthreads_set (save_nthreads, save_chunk) ;