multithreading on one shared array

17 visualizaciones (últimos 30 días)
mmm
mmm el 18 de Dic. de 2012
I have an array with 1xN elements, and I want to use 4 or more workers (cores) to work, in parallel, on this array. Each worker takes some elements from that array and manipulate them. For example, worker1 will take 3 elements, worker2 will take the next 2 and so on. These workers will work in parallel.
How can these workers be synchronized to work well? It seems like this would require a shared memory between multiple CPUs.
I need each worker read different size of data from that array at the same time: for example:
arr=1:100; % the common array
serv1 = 3; % random numbers
serv2 = 2; % random numbers
serv3 = 1; % random numbers
serv4 = 1; % random numbers I need at the same time worker1 read array(1:serv1), and worker 2 reads array(serv1+1:serv1+serv2) and worker3 reads array(serv1+serv2+1:serv1+serv2+serv3) and so on, and then manipulate the function on them

Respuesta aceptada

Jason Ross
Jason Ross el 18 de Dic. de 2012
This previous Answer might get you going in the right driection.
  1 comentario
mmm
mmm el 18 de Dic. de 2012
the way how every worker choose from my array is random, I dont want to distribute my array equally between the workers

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by