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.
0 个评论
采纳的回答
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 Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!