FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
arrayfire-python/examples/benchmarks/bench_blas.py at master · arrayfire/arrayfire-python · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
arrayfire
/
arrayfire-python
Public
Notifications
You must be signed in to change notification settings
Fork
64
Star
422
Code
Issues
57
Pull requests
3
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
arrayfire-python
/
examples
/
benchmarks
/
bench_blas.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
68 lines (48 loc) · 1.38 KB
Breadcrumbs
arrayfire-python
/
examples
/
benchmarks
/
bench_blas.py
Copy path
File metadata and controls
68 lines (48 loc) · 1.38 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/python
#######################################################
# Copyright (c) 2015, ArrayFire
# All rights reserved.
#
# This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause
########################################################
import
sys
from
time
import
time
import
arrayfire
as
af
try
:
import
numpy
as
np
except
ImportError
:
np
=
None
def
calc_arrayfire
(
n
):
A
=
af
.
randu
(
n
,
n
)
af
.
sync
()
def
run
(
iters
):
for
t
in
range
(
iters
):
B
=
af
.
matmul
(
A
,
A
)
af
.
sync
()
return
run
def
calc_numpy
(
n
):
np
.
random
.
seed
(
1
)
A
=
np
.
random
.
rand
(
n
,
n
).
astype
(
np
.
float32
)
def
run
(
iters
):
for
t
in
range
(
iters
):
B
=
np
.
dot
(
A
,
A
)
return
run
def
bench
(
calc
,
iters
=
100
,
upto
=
2048
):
_
,
name
=
calc
.
__name__
.
split
(
"_"
)
print
(
"Benchmark N x N matrix multiply on %s"
%
name
)
for
n
in
range
(
128
,
upto
+
128
,
128
):
run
=
calc
(
n
)
start
=
time
()
run
(
iters
)
t
=
(
time
()
-
start
)
/
iters
gflops
=
2.0
*
(
n
**
3
)
/
(
t
*
1E9
)
print
(
"Time taken for %4d x %4d: %0.4f Gflops"
%
(
n
,
n
,
gflops
))
if
__name__
==
"__main__"
:
if
(
len
(
sys
.
argv
)
>
1
):
af
.
set_device
(
int
(
sys
.
argv
[
1
]))
af
.
info
()
bench
(
calc_arrayfire
)
if
np
:
bench
(
calc_numpy
,
upto
=
512
)
Back
|
FazBrowse Home
|
New Git URL