1
我需要添加两个(A & B)的大随机大小(10^7,10^12)的矢量与python或多处理中的两个线程的帮助。然后需要将它存储在C中。我还必须记录我的代码。最后需要从最终向量中找出最小和平均数。我尝试了很多东西,目前正在使用Anaconda Jupyter笔记本。它接受代码,但不给我任何输出。线程/多处理/队列?
这是我的代码
"import time
import multiprocessing
import numpy as np
import threading
add_result = []
a = np.random.rand(10000000)
b = np.random.rand(10000000)
def calc_add(numbers):
global add_results
for n in numbers:
print('add' + str(a+b))
add_result.append(a+b)
print('within a process result' +str(add_result))
time.Time = start_time
if __name__=="__main__":
arr = a+b
p1 = multiprocessing.Process(target = calc_add, args = (arr))
p2 = multiprocessing.Process(target = calc_add, args = (arr))
p1.start()
p2.start()
p1.join()
p2.join()
print("result" +str(add_result))
print("done!")
请把你的代码放到你的问题中。 – martineau