Problem with Processor Affinity when calling programs from AutoIT

3 posts in this topic

Have a master program that constantly calls a series of sub-programs.  The sub-programs are copies of one master sub-program - the only difference is a filename each is passed as a command line parameter when calling the sub-program.   I'd like to take advantage of the number of cores of the system where these programs will eventually run so I'd like the master program to run on CPU 0 and each of the sub programs run on its own CPU (the system has 24 cores).

When the master program is run with no process affinity set (running on all cores), the sub-programs can be set with the appropriate affinity (core1.exe runs on CPU1, core2.exe runs on CPU2, etc).  When I start the master program with a shortcut using /affinity 1 (to run only on CPU0), all the sub-programs run on CPU0 as well - they do not get the appropriate affinity as they do when the master program runs on all cores.

I've tried two different ways to set the process affinity as shown below:


    $ProcessID = run($ProgramDir & "\Secondaries\" & $ProcessName & " " & $FileName, "", @SW_HIDE)
    ProcessWait ($ProcessName)
    _WinAPI_SetProcessAffinityMask($ProcessID, 2^$Core)


And the second way:


    $Submit = "start /affinity " & 2 ^ $Core & " " & $ProgramDir & "\Secondaries\" & $ProcessName & " " & $FileName
    run(@ComSpec & " /C " & $Submit,"", @SW_HIDE)

The sleep option is to prevent multiple processes being created for a CPU.

Any ideas?



Share this post

Link to post
Share on other sites

#2 ·  Posted (edited)

I believe the second way should be:

$Submit = "start /affinity " & 2 ^ $Core & ' "' & $ProgramDir & "\Secondaries\" & $ProcessName & '"  "' & $FileName & '"'

This is to avoid the path to be interpreted as multiple parameters.

Edited by genius257

Share this post

Link to post
Share on other sites

Thanks for responding.  The new line is definitely being handled differently.  Getting an error that Windows cannot find the file name being passed by $FileName.

Will look into it further this evening.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now