help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Paralleling in Octave


From: Maria Jose Casas Serrano
Subject: Paralleling in Octave
Date: Mon, 20 Apr 2020 19:46:15 +0200

Hi,
It’s the first time I’m trying to parallelise some code and I’m stuck in a basic concept that I hope someone could help me with.
 
First, I’ll try to explain what my code is about. I’m doing Evolutionary Computation and I have a large population of elements that represent the genomes of modelled plants. This population should be evaluated by a fitness function and then, some of the elements will evolve depending on the probabilities of some genetic operators.

The bottleneck happens when evaluating them so, I thought that I could parallelise that part of the code. 

A simplified example (with a population of 10 elements) is the following:

P =
{
  [1,1] = G
  [1,2] = +[-G]GG
  [1,3] = +[[GG]G]
  [1,4] = G-[-GG]
  [1,5] = GG+GG[-GG]
  [1,6] = []
  [1,7] = [-G]GGG
  [1,8] = [--[[G]]]
  [1,9] = +G+GGG
  [1,10] = [[GG]]
}

mytest.m 

inputparam2 = 0.01;
inputparam3 = 0.2;

logger.initSLF4O();

numCores = nproc();

timeStart = tic();
fun = @(idx) evaluationParallel(P{idx,:}, inputparam2, inputparam3);
[outputparam1, outputparam2, outputparam3] = pararrayfun(numCores - 1, fun, rows(P), "UniformOutput", false);

elapsed_time = toc(timeStart);
logger.info("mytest: Elapsed time %d", elapsed_time);

-----------------------------------------------------------------------------------------------------------------------------------
evaluationParallel.m

function [outputparam1, outputparam2, outputparam3] = evaluationParallel(individual, inputparam2, inputparam3)

logger.initSLF4O();

 # TODO: Remove it. Only for testing reasons
logger.info("evaluationParallel: individual %s", individual);
logger.info("evaluationParallel: inputparam2 %f", inputparam2);
logger.info("evaluationParallel: inputparam3 %f", inputparam3);
# END TODO

logger.info("evaluationParallel: Building the phenotype of the individual %s", individual);
[outputparam3{individual}, height, width, branchesnumber] = LsystemGenerator(individual);

logger.info("evaluationParallel: Calculating the aspect ratio of the individual %s", individual);
[outputparam1(:,individual), outputparam2(:,individual)] = getAspectRatio(height, width, branchesnumber, inputparam2, inputparam3);


endfunction

---------------------------------------------------------------------------------------------------------------------------------
However in the “inputparam2” and “inputparam3” parameters, the evaluationParallel function is receinving the second and third elements of the population.

Do you know what I am doing wrong? Perhaps I misunderstood the parallelisation concept but I thought I could apply it in a piece of code meanwhile there weren’t dependencies with the rest of the process.

Thanks in advance

Cheers

Maria J


reply via email to

[Prev in Thread] Current Thread [Next in Thread]