For example if you have the following loop structure locally:

- Code: Select all
`for (i = 0; i < loopsi; i++) {`

for (j = 0; j < loopsj; j++) {

result = i + j;

myarray[i][j] = result;

}

}

On the workers you only get the jobidx parameter which goes from 1 to number of jobs. If in the above case both loopsi and loopj would be 5, the number of jobs will be 25. Therefore you need to recompute the values of i and j on the worker code. In MATLAB you could use ind2sub function, but in C you need to do it yourself:

- Code: Select all
`int i = (jobidx - 1) % loopsi;`

int j = ((jobidx - 1) / loopsi) % loopsj;

Please see attached codes for full working example.