Hello, I am trying to use PARFOR in a loop which runs a strcmpi() function. The code is:
parfor i = 1:size(data_1,1)
idx = find(strcmpi(data_1{i,1},data_2(:,1)));
dd = data_2(idx,:);
for j = 1:size(dd,1)
fprintf(file,'%s\t%s\n',dd{j,1},dd{j,2}); % print to file
end
end
I am not able to slice the "data_2" which is a 31mn x 2 cell array due to which I am not able to run parfor. Can anyone suggest how I can modify this program for parfor? Moreover, will this effect the way I am printing the data in the file?
Thank you.

1 Kommentar

find(strcmpi(data_1{i,1},data_2(:,1)))
... you are expecting multiple matches?
Is either data_1(:,1) or data_2(:,1) a set of unique strings?

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Edric Ellis
Edric Ellis am 28 Nov. 2017
Bearbeitet: Edric Ellis am 28 Nov. 2017

0 Stimmen

The variable data_2 is not being sliced because every iteration of the parfor loop needs access to the whole array. This is not an error though - the code analyzer warning is simply telling you that the code is incurring extra communication because the whole of data_2 is being sent to each worker.

4 Kommentare

Anurag Passi
Anurag Passi am 28 Nov. 2017
So, why does the parpool sits idle and shuts off? Why am I not able to run it on parallel? What can be changed in this? Below is the actual error that I get.
Walter Roberson
Walter Roberson am 28 Nov. 2017
You are running out of memory trying to send the data to all of the workers. The data is converted to a byte stream and then the byte stream is sent to the workers and the workers reconstruct the objects; this requires a temporary copy of the data that could have you running out of memory.
Anurag Passi
Anurag Passi am 28 Nov. 2017
So I think maybe I should try some other way of working with this data. Thank you for your replies.
Walter Roberson
Walter Roberson am 28 Nov. 2017
If either data_1(:,1) or data_2(:,1) are sets of unique strings then ismember() can be used before-hand to find the indexing.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Hilfe-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