-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimerMulti.py
More file actions
27 lines (19 loc) · 903 Bytes
/
timerMulti.py
File metadata and controls
27 lines (19 loc) · 903 Bytes
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
import os, subprocess
from timeit import Timer
def callCUDA():
# change qd-newCUDA to the correct name of the executable which runs the algorithm using CUDA
subprocess.call("./cuda", 0, None, None, None, None)
def callOpenCL():
# change qd-newCPU to the correct name of the executable which runs the algorithm using CPU
subprocess.call("./qd", 0, None, None, None, None)
if __name__=='__main__':
f = open('performanceResult', 'w')
f.write('Mutliprecision library - CPU/CUDA comparison\n')
time = min(Timer("callCUDA()","from __main__ import callCUDA").repeat(5,1))
mystr = 'Time needed using CUDA:\n' + str(time) +'\n'
f.write(mystr)
f.write('\n\nFloating point vector addition using OpenCL\n')
time = min(Timer("callOpenCL()","from __main__ import callOpenCL").repeat(5,1))
mystr = 'Time needed using CPU:\n' + str(time) +'\n'
f.write(mystr)
f.close()