[galib] Runnng GAlib in parallel usin OpenMp

Sina Porsa sina.porsa at gmail.com
Mon Aug 13 00:38:55 EDT 2012

Hi all
I want to use GAlib to solve a huge problem and as a result, I have to run
it in parallel.
Actually the evaluation of the objective function is the most time
consuming part in my code. (Evaluation of each genome/individual will take
about 2 secs).
I thought it may be helpful to evaluate different individuals in a
population in parallel to improve the total simulation time.
I decided to test if I can use OpenMP . So I modified the GAPopulation.cpp
file as below

Original code:
GAPopulation::DefaultEvaluator(GAPopulation & p){
for(int i=0; i<p.size(); i++){

Modified code:
GAPopulation::DefaultEvaluator(GAPopulation & p){
  #pragma omp parallel for num_threads(64) // I am using 64 threads
 for(int i=0; i<p.size(); i++){

And the results were shocking!!
During evaluation of the first generation, the  evaluator runs in parallel
and uses all 64 available threads. But for the rest of the simulation, it
only uses 4-5 of the threads.

Another wired thing is that this problem only happens if I use
GASteadyStateGA or GAIncrementalGA. But if I chang to GASimpleGA, I will
not have this problem and the simulation uses all 64 available threads.

Any idea what is causing this problem and how can I solve it?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mit.edu/pipermail/galib/attachments/20120813/e4ac4187/attachment.htm

More information about the galib mailing list