Parallel processing using parfor or SPMD
Show older comments
Hi,
I am going to use Matlab's parallel processing capabilities within my code but I run into an error. I have trained a classifier using training data and now would like to be able to use test data and predict values.
Here is my code:
tic
interval=1000; % The max number of test data processed in each iteration.
n_all_test_data=20000000;
predict_all=[];
lim1=1;
parfor j=interval:interval:n_all_test_data
predict = classRF_predict(test_data(lim1:j,:),model);
predict_all=[predict_all;predict];
lim1=j+1;
end
toc
Here is the error I get
Error using testing_RF_final_ver1 (line 134)
Error: The temporary variable lim1 in a parfor is uninitialized.
See Parallel for Loops in MATLAB, "Uninitialized Temporaries".
I also changed the above code in the following way but it is much slower than using for loop.
tic
n_all_test_data=20000000;
predict_all=zeros(1,n_all_test_data);
parfor j=1:n_all_test_data
predict_all(j) = classRF_predict(test_data(j,:),model);
end
toc
My question is: Is there any way to speed up the processing using parfor or SPMD?
Thank you.
1 Comment
Mehdi Ravanbakhsh
on 22 Oct 2015
Accepted Answer
More Answers (0)
Categories
Find more on Parallel Computing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!