标签:com load engine until finish rip def 任务 one
n = 10
a = mx.nd.ones((1000,1000))
b = mx.nd.ones((6000,6000), gpu_device)
tic = time.time()
c = do(a, n)
wait(c)
print(‘Time to finish the CPU workload: %f sec‘ % (time.time() - tic))
d = do(b, n)
wait(d)
print(‘Time to finish both CPU/GPU workloads: %f sec‘ % (time.time() - tic))
# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
import mxnet as mx
import numpy as np
import pickle as pkl
import time
def do(x, n):
"""push computation into the backend engine"""
return [mx.nd.dot(x,x) for i in range(n)]
def wait(x):
"""wait until all results are available"""
for y in x:
y.wait_to_read()
tic = time.time()
a = mx.nd.ones((1000,1000))
b = do(a, 50)
print(‘time for all computations are pushed into the backend engine:\n %f sec‘ % (time.time() - tic))
wait(b)
print(‘time for all computations are finished:\n %f sec‘ % (time.time() - tic))
标签:com load engine until finish rip def 任务 one
原文地址:http://blog.51cto.com/13959448/2316997