How can I specify thread tasks?

조회 수: 16 (최근 30일)
Lew
Lew 2018년 8월 25일
댓글: Lew 2018년 8월 25일
I have to loop through all the n choose m combinations of the numbers 1:n. I have this algorithm:
vals = 1:m;
hasNext = true;
while(hasNext)
%do the task here
for M = m:-1:1
if vals(M)<n-m+M
vals(M) = vals(M)+1;
for MM = (M+1):m
vals(MM) = vals(M) + MM - M;
end
break;
end
if M==1
hasNext = false;
end
end
end
obviously parfor is not ideal here. I want to split the computation to multiple threads by splitting up the task to different sections and run that on different cores. LD;DR: Is it possible to do something like:
thread1.check(first part);
thread2.check(second part);
...

채택된 답변

Walter Roberson
Walter Roberson 2018년 8월 25일
You might want to use parfeval()
  댓글 수: 1
Lew
Lew 2018년 8월 25일
Wow, thanks! Meanwhile I was able to generate all the combinations and then do the parfor on that. But this is better as we don't have to use all the memory for the values.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Parallel Computing Toolbox에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by