How to set CPU affinity in Wine or CrossOver?

Solution 1:

Run the taskmgr.exe that comes with Wine, it allows you to set the affinity just like in Windows :).

I don't know how to set it permanently or automate setting it, though.

Possibly the same API that Windows uses for this task is present in Wine, which means that a Windows tool could be used for that task.

Edit:

I found a tool that does exactly that:

http://retired.beyondlogic.org/solutions/processutil/processutil.htm

Process -a name_of_exe 1 sets the affinity mask to processor 0.

Process -a name_of_exe 11 sets the affinity mask to processor 0 and 1.

... and so on.

See also:

http://en.wikipedia.org/wiki/Affinity_mask

Solution 2:

Setting processor affinity on OS X is not supported. There is no such system call that wine could make to achieve this functionality. The related bug for this at WineHQ is appropriately closed as a WONTFIX (Bug 30480 - Setting CPU affinity doesn't work on Macs).

See also this related SU question: "How to set processor affinity on OS X?".

So while Jens' answer is a valiant effort, Wine will silently (or not so silently, depending on WINEDEBUG) discard those API calls to set affinity on a Mac.

The workaround commonly cited is to use one of Xcode's developer tools (like Instruments) to limit the total number of active cores available to the entire system. Not pretty, but it works. Instruments.app Preferences: General Pane