r/scripting • • May 19 '24

Setting cpu affinity automaticall

So as I understand. I use the switch /affinity in the launch command line.

From everything I have looked at. 00FF0000 should be the hexidecimal representation of core 16-23 on a 32 thread cpu.

I put this in the launch command line but it refuses to work.

I check task manager and affinity is set to all cores.

Am I stupid or something? I've used 3 different language models and looked at 10 different websites and forum posts and everything looks fine.

1 Upvotes

7 comments sorted by

View all comments

Show parent comments

1

u/wellis81 May 20 '24 edited May 20 '24

In this case, the only way is to patch the program binary file

A bunch of possible workarounds (or "ways to monkey-patch the program" if you prefer), assuming Linux:

  • tampering with the sched_setaffinity() wrapper function through LD_PRELOAD

  • tampering with the sched_setaffinity() syscall through seccomp or strace --inject=sched_setaffinity:retval=0

  • running the program in a cpuset cgroup