How not to copy constant large data for every worker in spmd.

4 ビュー (過去 30 日間)
Davide Cataldo
Davide Cataldo 2020 年 8 月 20 日
コメント済み: Edric Ellis 2020 年 8 月 25 日
Hello everyone.
I am using a spmd statement as follows
spmd
n1 = 1+sizeClusters*(labindex-1);
n2 = sizeClusters*labindex;
my_output = my_function(Data1(:,n1:n2),Data2);
end
In this statement Data2 happens to be a very large matrix that is copied for each worker resulting in memory issues. Moreover, my_function needs to read all the values in Data2, therefore I cannot split it in portions like I do for Data1.
Such large matrix is constant and never modified into my_function, therefore such copying for each worker is totally unnecessary.
Is there a way to avoid to copy this large matrix and make the workers to (only) read from the same data?
  2 件のコメント
Matt J
Matt J 2020 年 8 月 20 日
The best strategy probably depends on what my_function is doing with Data2. Even if it eventually incorporates all of Data2 into whatever calculation it is doing, there surely has to be some way to break down the calculation into some sequential steps - there is no such thing as a digital computer that reads all data from a large array in perfect simultaneity...
Edric Ellis
Edric Ellis 2020 年 8 月 25 日
As Matt says, without any details of the operation of my_function, it's hard to know what's the best strategy here. For example, it might be possible to distribute the contents of Data2, and transfer the bits of Data1 as necessary.

サインインしてコメントする。

回答 (1 件)

Matt J
Matt J 2020 年 8 月 20 日
編集済み: Matt J 2020 年 8 月 20 日
Instead of reading Data2 into the workspace, you could keep it in a .mat file, and have each worker access it as needed through a matfile object.

カテゴリ

Help Center および File ExchangeParallel Computing についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by