Note that there are some explanatory texts on larger screens.

plurals
  1. POPython multiprocessing.starmap Process Count & Speed
    primarykey
    data
    text
    <p>I have a genetic algorithm whose fitness function is a cumbersome simulation environment. The code is absolutely CPU-bound, runs on 64bit python 3.3, so I have implemented <code>multiprocessing.starmap_async</code> to parallelize.</p> <p>And it works very well, large increases in efficiency over serial. On my processor,Intel i7 CPU @ 2.40 GHz (with 16GB RAM): I notice run-times of 8 to 9 seconds with 4 processes (and slower for 2 processes, and even slower for serial).</p> <p>HOWEVER, this only utilizes 65 to 73% of my processor.<br> Increasing the process count to 6 utilizes 95% to 100% of the processor, but with a runtime of 11 seconds. Memory is still sitting around 20% </p> <p>Increase this count to 8 and the processor sits constantly at 100%, but runtime is now 12 seconds. Memory is just fine.</p> <p>I can't post everything, but below is the multiprocessing call (with the arguments removed). Is there anything I can do to utilize more of the processor without a slow-down? I'd also appreciate any help understanding why this phenomena is occurring. </p> <p>Multiprocessing call:</p> <pre><code> step = np.int8(pop_size/4) pol = Pool(processes=4) res = pol.starmap_async(SimWorker, ((i, i+step,pop,"a bunch of other arguments") for i in range(0, pop_size, step))) fitnessdict = res.get() fitnessdict = np.asarray(fitnessdict) for i in range(0,pop_size,step): for p in range(i,i+step): fitness[p] = fitnessdict[i/step,p] </code></pre> <p>SimWorker:</p> <pre><code>def SimWorker(start, stop, pop, "a bunch of other arguments"): """ Run a batch of sims """ for p in range(start, stop): fitness[p] = Sim_T(pop[p],"a bunch of other arguments") return(fitness) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload