Convert code to run on parallel

조회 수: 4 (최근 30일)
Or Shem Tov
Or Shem Tov 2020년 3월 23일
댓글: Or Shem Tov 2020년 3월 26일
Hi guys,
I have a file that takes 340 seconds to run, I've learned just now that I can use my GPU instead of the CPU to run this code faster.
How is that done? is there any good recommendations for where and how to learn to use the Parallel computing toolbox?
Here's part of my code, if anyone can give me an example on it that'd be amazing.
%% Scan for news, filter them and assign tickers
for symboli = 1:NofStocks
newsone = news(cMoneyNet,'Number',NewsNum,'Symbol',symbol(symboli),'SearchTerm',term); % get news type 1
newstwo = news(cMoneyNet,'Number',NewsNum,'Symbol',symbol(symboli),'Category',category); % get news type 2
% Filter the news (type 1)
filteri = startsWith(newsone.ArticleTitle,"Analyst Actions") ...
| contains(newsone.ArticleTitle,"PT") ...
& not(contains(newsone.ArticleTitle,"OPTIONS"));
newsone = newsone(filteri,:);
% Assign a ticker to each piece of news
newsone.Ticker(:,1) = symbol(symboli);
newstwo.Ticker(:,1) = symbol(symboli);
% Join the news - type 1 and type 2
newsonetwo = vertcat(newsone,newstwo);
% Store the news from this ticker before moving to the next one
newsdata{symboli,1} = newsonetwo;
end

채택된 답변

Edric Ellis
Edric Ellis 2020년 3월 24일
  • It's hard to tell exactly what computations you're performing there. It would be better if you could give us a reproducible example of something that is particularly time-consuming in your workflow. Use the MATLAB Profiler to work out where this might be, and slim this down to a standlone piece of code that we can run.
  • The Profiler might already give you some idea as to where you can save time. It's always worthwhile improving your "serial" code as much as you can before you attempt to go parallel
  • Whether the GPU is appropriate depends very much on your problem type. GPUs are great when you have big chunks of numeric data on which you wish to apply vectorised operations. It looks like perhaps you have table data containing text, the GPU would not work for that, but perhaps process-based parallelism might help (i.e. using parfor).
  • It might help to look through this page telling you which Parallel Computing option might work best for you.
  댓글 수: 4
Edric Ellis
Edric Ellis 2020년 3월 25일
Ah, I've just found out that Money.Net doesn't allow multiple simultaneous connections in that form, so I don't think the code in my previous comment will work.
So, unfortunately it seems like if the news() call is the main bottleneck, there isn't currently any way to parallelise that piece.
Or Shem Tov
Or Shem Tov 2020년 3월 26일
I understand, thank you for your help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Parallel for-Loops (parfor)에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by