Accelerate the MM multiplication code using a FastFlow farm accelerator.
You should look for computations (tasks) that may be executed in parallel within the sequential code. Then
Declare accelerator using a true parameter as the constructors parameter
farm<> myFarm(true);
and eventually start it with the call
myFarm.run_then_freeze()
To offload tasks to the accelerator use a
myFarm.offload(void * task)
method.
Aftern having offloaded all the tasks, offload an EOS
myFarm.offload((void *) FF_EOS);
To restrieve results from the accelerator use a
myFarm.load_result(void **)
Eventually, to await for accelerator termination, use a
myFarm.wait()
Accelerator should in principle use the spare cores of your machine. The total number of cores may be read (on Linux) as follows:
int cores = sysconf( _SC_NPROCESSORS_ONLN );
therefore in our case, being one core used by the mm main code, you shoul assume the accelerator may use up to
sysconf( _SC_NPROCESSORS_ONLN ) -1
cores.
Code here.
Appreciate the possiblities offered to accelerate existing code, with minimal programming effort.