Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 08, 2016, 10:15:37 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: CPU Affinity  (Read 6884 times)

broken85

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 88
    • View Profile
    • Donate to Member
CPU Affinity
« on: November 29, 2006, 11:21:51 AM »
Mouser,

do you think it would be possible to at some point incorporate a forced CPU affinity into ProcessTamer (in the same manner as you can force a priority for a particular process)? I've got a dual-core at home and sometimes find that I want or need to change the CPU affinity on some processes.

The option only shows up if you have a dual-core or multiple CPUs, but it is a right-click option in the Task Manager to set it. I'd like to use it with ProcessTamer as I already have a number of forced priorities and it would be sweet to set the affinity automatically when opening a certain app.

I have no idea what actually goes on on the back-end but if you think it would be a possibility I'd be happy to give you any information, testing, etc. on my dual-core machine with x64 at home.

Not urgent, and maybe not even feasible, but just a thought. Thanks!
--
Ben M

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,412
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: CPU Affinity
« Reply #1 on: November 29, 2006, 01:29:54 PM »
I plan to add this without a doubt, just have to find a little time to emerse myself affinity stuff.

wr975

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 369
    • View Profile
    • Donate to Member
Re: CPU Affinity
« Reply #2 on: May 10, 2007, 04:19:26 PM »
Here's a little AHK tool to set affinity of processes, to make better use of multi-core CPUs. I made it for own personal use (for my always running AHK script, as I recently got a dual-core CPU) but thought someone would've interest in it, so here's a self-running version.

It's doing the same thing as the $15 shareware "S.A.D. Dual-Core-Tuner" and is perhaps an useful solution until ProcessTamer  :-* can do such thing. It is monitoring the system for certain tasks to appear and sets the specified CPU affinity. It's no longer necessary to open task-manager and set the affinity manually. The tasks and CPU affinity have to be written in a configuration file (.ini).


Instructions:
- Download and start.

Notes:
  • To edit this file, right-click the tray icon and select "configure". This will open notepad and reload the configuration. If you edit the ini file manually, you've to restart the tool.
  • Creating a shortcut in your startup folder is a good idea.

Credits:
Copied some lines from "IdleRun" by Skrommel. Pure genius.  :Thmbsup:

AHK Source:
Spoiler

; Most clever parts of this script copied from "IdleRun" by Skrommel (http://www.donationcoder.com)
; ---------------------------


;#NoTrayIcon 
#SingleInstance force
#Persistent

IfNotExist,Task Affinity.ini
{
msgbox, 48, Task Affinity - First launch?, Configuration file "Task Affinity.ini" not found!`n`nPlease edit and restart.
Fileappend,[settings]`n`nTask = newsleecher.exe`,lame.exe`,mp3gain.exe`,quickpar.exe`,hksfv.exe`n`nAffinity = 2`n`n`n`n; Affinity can be:`n; ----------------`n; 1 = first core`n; 2 = second core`n; ...,Task Affinity.ini
Run,Notepad "Task Affinity.ini"
ExitApp
}

TrayMenu:
Menu,Tray,NoStandard
Menu,Tray,Add,Configure,TrayConfigure
Menu,Tray,Add,Exit,TrayMenuExit


IniRead,Task,Task Affinity.ini,settings,Task
IniRead,Task_Affinity,Task Affinity.ini,settings,Affinity

SetTimer, Tasks, 1000
Return

TrayConfigure:
RunWait,Notepad "Task Affinity.ini"
Reload
Return

TrayMenuExit:
ExitApp


Tasks:
Loop,parse,Task,`,
{
   Process,Exist,%A_LoopField%
   if errorlevel <> 0
      {
      Affinity_pid:=ErrorLevel
      Affinity_Process:=DllCall("OpenProcess","UInt",0x1F0FFF,"Int",false,"UInt",Affinity_pid)
      DllCall("SetProcessAffinityMask","UInt",Affinity_Process,"UInt",Task_Affinity)
      DllCall("CloseHandle","UInt",Affinity_Process)
      }
}



Edit: New version. Won't use external process.exe anymore.

« Last Edit: May 12, 2007, 04:38:32 AM by wr975 »

broken85

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 88
    • View Profile
    • Donate to Member
Re: CPU Affinity
« Reply #3 on: May 10, 2007, 05:14:37 PM »
Your script looks great wr975, I can't wait to get home and try it out!

I'm curious as to what it actually does; which processes does it change the affinity of? Or is it CPU load-based?

I thought maybe looking into S.A.D. Dual-Core-Tuner would give me more info, but all the information I have pulled up so far has been in German and I am much too lazy (or is that "busy at work") to translate at the moment. I'll check more into this tonight too! Anything that will increase the usefulness of my dual core processor deserves further investigation. And I'm glad we already have an AHK alternative thanks to wr975!

beyondlogic.org isn't a bad site either, seems like it has some useful administrative tools! Thanks for the link  :Thmbsup:

--
Ben M

Ampa

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 592
  • I am cute ;)
    • View Profile
    • MonkeyDash - 2 Player strategy boardgame
    • Donate to Member
Re: CPU Affinity
« Reply #4 on: May 10, 2007, 05:15:07 PM »
SMP SeeSaw, by Mike Lin,  is a little freeware util that allows easy management of dual-cpu affinities...

Quote from: the author
SMP Seesaw is a utility for dual-CPU or dual-core computers that controls how Windows balances the compute load between the two processors. By default, Windows balances the processing load to both CPUs as evenly as possible among all programs. SMP Seesaw provides a convenient means to change the processor affinities for all running programs at once. In particular, the most common use is to dedicate one of your processors to a single program, thereby improving the performance or responsiveness of that program.

An aside... I like Mike's use of 'glaring eyes' above his donation button - he must have read THIS research.

broken85

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 88
    • View Profile
    • Donate to Member
Re: CPU Affinity
« Reply #5 on: May 10, 2007, 06:15:17 PM »
Cool find Ampa, I will have to check that one out as well!

I wonder if AMD's Dual Core Optimizer is affected by any of this software?


Aside to an aside: Hasn't the 'glaring eyes' concept been around in some form or another for many years? (eg. "Big Brother is watching!" and the associated images it conjures of a poster of some authority figure staring and/or pointing at you). Take away people's sense of privacy and they will likely be much less sure of themselves and their actions... Now we're just applying it to less-socially-damaging concepts :D (and they even imply it might help combat anti-socialism, though I chuckle reading that).
--
Ben M

wr975

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 369
    • View Profile
    • Donate to Member
Re: CPU Affinity
« Reply #6 on: May 10, 2007, 06:22:50 PM »
@broken85
You'll need to edit the ini file (instructions inside) or just use SMPSeeSaw.

@Ampa
Thanks for the link. Too bad I didn't find this tool myself. I only found Dual-Core-Tuner and a quite horrible freeware solution by Tom's Hardware. SMP SeeSaw would've been exactly what I was looking for.

Edit: Just tested SeeSaw and it seems to be a GUI for Task-Manager only. It does not change affinity on new tasks (automatically) and does not save the configuration. Pity. Would've been a nice app to use with very low memory usage.
« Last Edit: May 10, 2007, 06:47:35 PM by wr975 »