multithreading on one shared array

17 Ansichten (letzte 30 Tage)
mmm
mmm am 18 Dez. 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

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by