Page 1 of 1

cd_setcpu

Posted: Tue May 03, 2016 9:16 am
by omni
Roger,

I am using your example and have for a while. A new client has 16 cpu's`Can that be handled by increasing the vars.

LOCAL nHnd := 0 // file handle
LOCAL nLast := 1 // last CPU used
LOCAL aSet := {} // processor array
LOCAL nSet // default new bitmask
LOCAL i // counter

//DEFAULT cFile := GetEnv('WINDIR') + '\Temp\SetCpu.Smp'
DEFAULT cFile := vdrive+"\oiswin\SetCpu.Smp"
DEFAULT nCPU := 15
// 15 = 4 CPUs
// 7 = 3 CPUs
// 3 = 2 CPUs
// 1 = 1 CPU

nSet := nCPU

FOR i := 1 to 32 // count processors
IF nCPU // processor present
aadd(aSet, i) // add processor id to list
ENDIF
NEXT

IF len(aSet) > 1 // more then one processor
IF Fexists(cFile)
nHnd := Fopen(cFile, FO_READWRITE)
IF nHnd > 0 // file is open
nLast := Val(Freadstr(nHnd, 2))+ 1 // get last processor
IF nLast > len(aSet) // check against available processors
nLast := 1 // recycle number
ENDIF
Fseek(nHnd, 0, FS_SET) // place pointer at bof
Fwrite(nHnd, StrZero(nLast, 2)) // write to file
Fclose(nHnd) // close file
ENDIF
ELSE // first time round
nHnd := Fcreate(cFile, FC_NORMAL)
IF nHnd > 0 // file is created and open
Fwrite(nHnd, StrZero(nLast, 2)) // write to file
Fclose(nHnd) // close file
ENDIF
ENDIF

FOR i := 1 to 32 // create new bitmask
nSet := (i = aSet[nLast]) // switch on appropriate bit
NEXT

DllCall("xpprt1.dll", DLL_CDECL, "_sysSetCPU", nSet)

ENDIF

RETURN nil

Thanks

Fred
Omni

Re: cd_setcpu

Posted: Tue May 03, 2016 9:54 am
by rdonnay
A new client has 16 cpu's`Can that be handled by increasing the vars.
I am not sure.
It depends on the undocumentated Xbase++ function _sysSetCPU().

Xbase++ 2.0 has two new functions: SetLogicalProcessor() and GetLogicalProcessor().

Possibly they wrote these functions to handle more CPUs.

Re: cd_setcpu

Posted: Tue May 03, 2016 12:33 pm
by omni
Tested and it appears anything over 4 goes back to cpu 1.

Will check out those new features when i get a chance.

thanks

Re: cd_setcpu

Posted: Tue May 03, 2016 1:06 pm
by Auge_Ohr
omni wrote:Tested and it appears anything over 4 goes back to cpu 1.
hm ... how did you test ?
try original Alaska Sample c:\ALASKA\XPPW32\SOURCE\samples\solution\smp\smprun.prg with these Value

Code: Select all

2 ^ (x-1)

//
1 = 1. CPU
2 = 2. CPU
4 = 3. CPU
8 = 4. CPU
16 = 5. CPU
32 = 6. CPU
64 = 7. CPU
128 = 8. CPU

// while i have only 8 CPU more not tested
256 = 9. CPU
512 = 10. CPU
1024 = 11. CPU
2048 = 12. CPU
4096  = 13. CPU
8192  = 14. CPU
16384 = 15. CPU
32768 = 16. CPU