The ParallelGenomeListEvaluator class is a direct replacement for SimpleGenomeListEvaluator that decodes and evaluates genomes in parallel on multiple execution threads. The number of threads can be passed to the class constructor, otherwise it defaults to the value of Environment.ProcessorCount which yields the number of logical processors, this includes multiple cores on a chip and also Hyperthreading(HT) cores. E.g. a quad core Intel Core i7 with HT will provide eight logical cores.

Parallelization is achieved using the Thread and WaitHandle classes available in .Net 2, as such compatibility with Mono is maintained (Parallel Extensions are not used in this class).

Parallelizing k-means

When running tests using the XOR and Binary-6-Multiplexer problem domains it was observed that the CPU was not fully utilizing all cores. The reason for this is that these problem domains require very little CPU work and so the k-means speciation algorithm takes up the majority of CPU time in these tests. An obvious response to this is to parallelize k-means.

In tests it was found that the majority of time was taken up by the FindClosestSpecie() method which in turn calls IDistanceMetric.MeasureDistance() many times. Parallelizing this method is straightforward but resulted in a significant slow-down, a possible reason being that the workload in that method is broken down into teh number of species at most and as such the breakdown of work is coarse/chunky. Parallelizing elsewhere in the algorithm required slightly more effort but does result in a significant speedup on multicore CPUs.

Parallel Extensions

The parallel k-means experiments used Microsoft's Parallel Extensions (PE):

Three versions of these extensions are currently in the wild:
  1. .Net 4.0. Parallel Extensions are part of .Net 4.0 (released April 2010).
  2. Parallel Extensions have also been available as part of Reactive Extensions for .Net(Rx) for use on .Net 2.0, 3.0, 3.5.
  3. Microsoft Parallel Extensions June 2008 CTP (Community Technology Preview). This version contained some issues and was not redistributable, it's also no longer available online but some may still be using it.
  4. There is a Mono version of Parallel Extensions but it is not yet part of the Mono releases. The source code was produced as part of the Google Summer of Code(SOC) 2008 ( I experimented with building the DLL in Mono and using it on Windows as a way to get a version of PE that would be platform agnostic; However, I observed some problems and so that route may not be productive.
Any references to the Microsoft versions of PE should be easily resolved in Mono by switching to the Mono SOC code DLL. You will however need to obtain the source from SVN and build it using either the mono command line or MonoDevelop.

The .Net PE is dependent on various modications and fixes that are part of .Net 3.5. Strictly speaking it will run on .Net 2.0 but you may experience problems, at the very least you will need to refer to the System.Core.dll that is part of .Net 3.5. You can however safely do this from older versions of Visual Studio (I'm using 2005) so long as you have installed .Net 3.5 (3.5 is just a layer of DLLs on top of .Net 2 but with some bug fixes to .Net 2).

Server Garbage Collection

Under windows .Net applications on multi-core machines can opt to use a different garbage collection scheme more suited to servers and which operates on multiple threads. In tests SharpNEAT running on an Intel Corei7 with the server GC enabled did run approximately 5-10% faster. To enable this the following section of configuration XML needs to be placed in the SharpNEAT.exe.config file:

<?xml version="1.0" encoding="utf-8" ?>
    <gcServer enabled="true"/>


Design Considerations For Parallel Programming