Skip to content

Commit c7c273f

Browse files
committed
Adding the ability to switch devices for monte_carlo_pi example
1 parent 5879685 commit c7c273f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

examples/benchmarks/monte_carlo_pi.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from time import time
1414
from arrayfire import (array, randu)
1515
import arrayfire as af
16+
import sys
1617

1718
#alias range / xrange because xrange is faster than range in python2
1819
try:
@@ -47,5 +48,9 @@ def bench(calc_pi, samples=1000000, iters=25):
4748
print("Average time taken: %f ms" % (1000 * (end - start) / iters))
4849

4950
if __name__ == "__main__":
51+
if (len(sys.argv) > 1):
52+
af.set_device(int(sys.argv[1]))
53+
af.info()
54+
5055
bench(calc_pi_device)
5156
bench(calc_pi_host)

0 commit comments

Comments
 (0)