I want to try parallel computing in python-2.x using multiprocessing.Pool
.
I came up with the following simple code. Unfortunately, I was not able to produce any error message.
Can someone point me into the right direction of what might be wrong with my code?
import numpy as np
import multiprocessing as mp
import timeit
def fun(i,j):
return i+j
num=2
num_cores = mp.cpu_count()
p = mp.Pool(num_cores)
results = np.array([])
tasks = np.array([(i, j) for i in range(0,num) for j in range(0, num)])
if __name__ == '__main__':
results = np.array(p.map(fun,tasks))
print results