提交 90738add authored 作者: Frederic's avatar Frederic

Update the multi-gpu timing to be more clear. Example:

one ctx async 3.349727 two ctx async 1.713157 two ctx, 2 fct async 1.717468 two ctx, 2 fct with transfer 3.635517 two ctx, 2 fct async, 2 threads 1.731599 two ctx, 2 fct with transfer, 2 threads 2.071597
上级 83ea18f2
...@@ -76,21 +76,14 @@ def main(dev1, dev2): ...@@ -76,21 +76,14 @@ def main(dev1, dev2):
t2 = time.time() t2 = time.time()
r = None r = None
print("two ctx, 2 fct async, 1 thread %f" % (t2 - t,)) print("two ctx, 2 fct async %f" % (t2 - t,))
t = time.time() t = time.time()
r = f5.fn() r = f5.fn()
r2 = f6.fn() r2 = f6.fn()
t2 = time.time() t2 = time.time()
r = None r = None
print("two ctx, 2 fct with transfer, 1 thread %f" % (t2 - t,)) print("two ctx, 2 fct with transfer %f" % (t2 - t,))
t = time.time()
r = f5()
t2 = time.time()
r = None
print("one ctx, 1 fct with transfer, 1 thread %f" % (t2 - t,))
# Multi-thread version # Multi-thread version
class myThread (threading.Thread): class myThread (threading.Thread):
...@@ -104,13 +97,14 @@ def main(dev1, dev2): ...@@ -104,13 +97,14 @@ def main(dev1, dev2):
# print "Starting " + self.name # print "Starting " + self.name
# r = self.f.fn(n_calls=10) # r = self.f.fn(n_calls=10)
r = self.f() r = self.f()
# print "End " + self.name
if self.sync: if self.sync:
r[0].sync() r[0].sync()
self.r = r self.r = r
# print "Exiting " + self.name # print "Exiting " + self.name
thread1 = myThread("Thread-1", f3, True) thread1 = myThread("Thread-3", f3, True)
thread2 = myThread("Thread-2", f4, True) thread2 = myThread("Thread-4", f4, True)
t = time.time() t = time.time()
thread1.start() thread1.start()
thread2.start() thread2.start()
...@@ -120,32 +114,8 @@ def main(dev1, dev2): ...@@ -120,32 +114,8 @@ def main(dev1, dev2):
print("two ctx, 2 fct async, 2 threads %f" % (t2 - t,)) print("two ctx, 2 fct async, 2 threads %f" % (t2 - t,))
thread1 = myThread("Thread-1", f3, True) thread1 = myThread("Thread-5", f5, False)
thread2 = myThread("Thread-2", f4, True) thread2 = myThread("Thread-6", f6, False)
t = time.time()
thread1.start()
thread2.start()
thread2.join()
thread1.join()
t2 = time.time()
print("two ctx, 2 fct async, 2 threads %f reverse join" % (t2 - t,))
thread1 = myThread("Thread-1", f3, False)
thread2 = myThread("Thread-2", f4, False)
t = time.time()
thread1.start()
thread2.start()
thread1.join()
thread2.join()
thread1.r[0].sync()
thread2.r[0].sync()
t2 = time.time()
print("two ctx, 2 fct async + late sync, 2 threads %f" % (t2 - t,))
thread1 = myThread("Thread-3", f5, False)
thread2 = myThread("Thread-4", f6, False)
t = time.time() t = time.time()
thread1.start() thread1.start()
thread2.start() thread2.start()
...@@ -155,16 +125,6 @@ def main(dev1, dev2): ...@@ -155,16 +125,6 @@ def main(dev1, dev2):
print("two ctx, 2 fct with transfer, 2 threads %f" % (t2 - t,)) print("two ctx, 2 fct with transfer, 2 threads %f" % (t2 - t,))
thread1 = myThread("Thread-3", f5, False)
thread2 = myThread("Thread-4", f6, False)
t = time.time()
thread1.start()
thread2.start()
thread2.join()
thread1.join()
t2 = time.time()
print("two ctx, 2 fct with transfer, 2 threads %f reverse join" % (t2 - t,))
if __name__ == '__main__': if __name__ == '__main__':
import sys import sys
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论