multithreading on one shared array
17 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!