Parallel Processing An Array/Array Appending
2 次查看(过去 30 天)
显示 更早的评论
I'm attempting to store data in internal memory (an array) until I'm ready to export the data to an excel document. However, my current implementation slows down my program after a while as I'm consistently 'growing' the array by adding another array to the end of it.
This is my current implementation:
memoryArray = [memoryArray, arrayToAdd] (x6)
I'm wondering if it would be easy to implement parallel programming to do something like this:
%Psuedo Code
serial code...
serial code tell parallel process workers to start the following:
memoryArray1 = [memoryArray1, arrayToAdd1] %memoryArray is a global variable
memoryArray2 = [memoryArray2, arrayToAdd2]
memoryArray3 = [memoryArray3, arrayToAdd3]
memoryArray4 = [memoryArray4, arrayToAdd4]
memoryArray5 = [memoryArray5, arrayToAdd5]
memoryArray6 = [memoryArray6, arrayToAdd6]
serial code continues without waiting for results..
Is this possible to do? Perhaps my array manipulations are highly inefficient? I'm wondering if it might be as simple as using an spmd block... I apologize for the poorly written question. Thanks :)
0 个评论
回答(1 个)
James Tursa
2016-7-29
编辑:James Tursa
2016-7-29
Can you save up all of the arrayToAdd stuff in a cell array and then cat all the results at once at the end to minimize the data copying? E.g., something like this:
arrayToAdd{1} = stuff;
arrayToAdd{2} = stuff;
arrayToAdd{3} = stuff;
arrayToAdd{4} = stuff;
arrayToAdd{5} = stuff;
arrayToAdd{6} = stuff;
:
memoryArray = [memoryArray, arrayToAdd{:}];
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 MATLAB Parallel Server 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!