I am attempting to parallelise some code in python. Running in serial my code takes around 24 hours, however, there is a for loop where each iteration is independent of the previous iteration, so this is an ideal situation for parallelisation. A simple example of what I am trying to achieve with my code is as follows,
import scipy as sci
from multiprocessing import Pool
def mycode(args):
for x in range(0,2000)
y = sci.fft(data[x,:],axis=1)
output[x,:]=y
return output
if __name__=="__main__":
pool=Pool(processes = 8)
output= pool.map(mycode(args),2000)
However, from looking at top, I can see that although python generates 9 python processes, only one is actually using any CPU power or memory. All the others are at 0%. What is the correct way to use Pool with a for loop?
reconstructionfunction? Does it return a callable? Why is the second argument topool.mapa number (2000) and not an iterable? Why is there amycodefunction in your example if it is never called?