Running single function with multple inputs on each different core.

조회 수: 1 (최근 30일)
Hello everyone, i am new to matlab and want to exceute my function for multiple input data to get faster results by using multiple cores.
Here is an abstract interpretation of my code:
parfor i=1:7
Result(:,i)= Func(i);
end
PROBLEM:
Func(): is madeup of several small functions , and they are executed in random order, which is not intended.
GOAL:
Execute Func(i) , such that:
Func(1): runs on Core-1
Func(2):runs on Core-2
........ so on upto 4 core.(I have 4-core i7-7700HQ).
QUESTION:
is it possicle to do so?.If yes, could any one please expalin with help of small example ?
Thanks in adavnce.

채택된 답변

Walter Roberson
Walter Roberson 2020년 6월 27일
Func(): is madeup of several small functions , and they are executed in random order, which is not intended.
The order that parfor iterations are executed in is deliberately unspecified, and can vary. However, the last iteration is one of the first started, so as to be able to initialize any output arrays to their full size.
Func(1): runs on Core-1
MATLAB does not provide any way to lock a process to a particular core. If you are using MS Windows then there are several ways that you can set a processor affinity; see a summary at http://smallvoid.com/article/winnt-process-affinity.html
Setting a processor affinity typically only helps when there is hardware attached to one particular node that you need to be able to interrupt faster -- you bind the interrupt handling process to a core on the board the hardware is most closely attached to. In other cases, setting processor affinity can reduce performance, as an affinity-bound process cannot switch to another available core when it is not in control of the core it set bound to. Remember that operating system activities, firewalls, anti-virus, browsers, user interfaces, and so on all need access to a core, so you cannot just bind one compute process per core and expect everything to go smoothly.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by