Documentation Center

  • Trial Software
  • Product Updates


Global operation across all workers


res = gop(@F, x)
res = gop(@F, x, targetlab)



Function to operate across workers.


Argument to function F, should be same variable on all workers, but can have different values.


Variable to hold reduction result.


Lab to which reduction results are returned.


res = gop(@F, x) is the reduction via the function F of the quantities x from each worker. The result is duplicated on all workers.

The function F(x,y) should accept two arguments of the same type and produce one result of that type, so it can be used iteratively, that is,


The function F should be associative, that is,

F(F(x1, x2), x3) = F(x1, F(x2, x3))

res = gop(@F, x, targetlab) performs the reduction, and places the result into res only on the worker indicated by targetlab. res is set to [] on all other workers.


Calculate the sum of all workers' value for x.

res = gop(@plus,x)

Find the maximum value of x among all the workers.

res = gop(@max,x) 

Perform the horizontal concatenation of x from all workers.

res = gop(@horzcat,x)

Calculate the 2-norm of x from all workers.

res = gop(@(a1,a2)norm([a1 a2]),x)

See Also


Was this topic helpful?