Set processor affinity for MATLAB engine (Windows 7)

前端 未结 3 955
萌比男神i
萌比男神i 2020-12-18 01:05

I\'m developing an application in c++. One of the components of the application uses Matlab (via the Matlab engine) for data processing. At the same time, a data acquisition

3条回答
  •  旧时难觅i
    2020-12-18 01:51

    I haven't tried this solution but it seems like it should work. Create a simple mex function that does the following:

    1. Call GetCurrentProcess to retrieve a handle to the MATLAB process
    2. Set the appropriate affinity mask for this process using SetProcessAffinityMask

    Now, when your application launches, just call this mex function as you would a regular MATLAB function (the mex function must be visible on the MATLAB path) and it should set processor affinity as you desire. You could even pass the affinity mask as an input to the function to make it more versatile.

提交回复
热议问题