multithreading on one shared array

17 visualizzazioni (ultimi 30 giorni)
mmm
mmm il 18 Dic 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

Risposta accettata

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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by