File tree Expand file tree Collapse file tree 2 files changed +79
-0
lines changed
Expand file tree Collapse file tree 2 files changed +79
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/python
2+
3+ #######################################################
4+ # Copyright (c) 2015, ArrayFire
5+ # All rights reserved.
6+ #
7+ # This file is distributed under 3-clause BSD license.
8+ # The complete license agreement can be obtained at:
9+ # http://arrayfire.com/licenses/BSD-3-Clause
10+ ########################################################
11+
12+
13+ import sys
14+ from time import time
15+ from arrayfire import (array , randu , matmul )
16+ import arrayfire as af
17+
18+ def bench (A , iters = 100 ):
19+ start = time ()
20+ for t in range (iters ):
21+ B = af .matmul (A , A )
22+ af .sync ()
23+ return (time () - start ) / iters
24+
25+ if __name__ == "__main__" :
26+
27+ if (len (sys .argv ) > 1 ):
28+ af .set_device (int (sys .argv [1 ]))
29+
30+ af .info ()
31+ print ("Benchmark N x N matrix multiply" )
32+
33+ for n in range (128 , 2048 + 128 , 128 ):
34+ A = af .randu (n , n )
35+ af .sync ()
36+
37+ t = bench (A )
38+ gflops = 2.0 * (n ** 3 ) / (t * 1E9 )
39+ print ("Time taken for %4d x %4d: %0.4f Gflops" % (n , n , gflops ))
Original file line number Diff line number Diff line change 1+ #!/usr/bin/python
2+
3+ #######################################################
4+ # Copyright (c) 2015, ArrayFire
5+ # All rights reserved.
6+ #
7+ # This file is distributed under 3-clause BSD license.
8+ # The complete license agreement can be obtained at:
9+ # http://arrayfire.com/licenses/BSD-3-Clause
10+ ########################################################
11+
12+
13+ import sys
14+ from time import time
15+ from arrayfire import (array , randu , matmul )
16+ import arrayfire as af
17+
18+ def bench (A , iters = 100 ):
19+ start = time ()
20+ for t in range (iters ):
21+ B = af .fft2 (A )
22+ af .sync ()
23+ return (time () - start ) / iters
24+
25+ if __name__ == "__main__" :
26+
27+ if (len (sys .argv ) > 1 ):
28+ af .set_device (int (sys .argv [1 ]))
29+
30+ af .info ()
31+ print ("Benchmark N x N 2D fft" )
32+
33+ for M in range (7 , 13 ):
34+ N = 1 << M
35+ A = af .randu (N , N )
36+ af .sync ()
37+
38+ t = bench (A )
39+ gflops = (10.0 * N * N * M ) / (t * 1E9 )
40+ print ("Time taken for %4d x %4d: %0.4f Gflops" % (N , N , gflops ))
You can’t perform that action at this time.
0 commit comments