I have found the following lines of code to compute the array mx
by the repeated calling of a function called fun
.
However, I would like to understand better what it does.
Also, I assigned 16 cores to the parallel pool, however, I noticed that during computations no more than 2 cores are running at the same time.
Could someone explain what this code does and why it could be that only part of the threads is working?
Thank you!
from tqdm import tqdm
from multiprocessing import Pool
from functools import partial
with Pool(processes = 16) as p_mx:
mx = tqdm(p_mx.imap(partial(fun, L), nodes), total = n)