Multicore processing

This forum is for eXpress++ general support.
Message
Author
User avatar
Auge_Ohr
Posts: 1414
Joined: Wed Feb 24, 2010 3:44 pm

Re: Multicore processing

#41 Post by Auge_Ohr »

Victorio wrote:now I understand it. You mean, some existing application which have not "switch" to switch cpu ?.
YES.
you have to implement those SMP Function to all Xbase++ Application which you want to run on other CPU than first CPU

p.s.
0x0f = 15 = CPU0, CPU1, CPU2, and CPU3 (1+2+4+8 = 15) does NOT work with Xbase++ > v1.5 any more.
greetings by OHR
Jimmy

Victorio
Posts: 631
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: Multicore processing

#42 Post by Victorio »

Hi Jimmy :
Please , I do not understand what you mean in last post :
p.s.
0x0f = 15 = CPU0, CPU1, CPU2, and CPU3 (1+2+4+8 = 15) does NOT work with Xbase++ > v1.5 any more.

(Now I have on my PC with 4 cores/CPU 4 running application, 1. on CPU1,2. on CPU2,...
I set it with parameter 1,2,4,8. )

User avatar
Auge_Ohr
Posts: 1414
Joined: Wed Feb 24, 2010 3:44 pm

Re: Multicore processing

#43 Post by Auge_Ohr »

Victorio wrote:Please , I do not understand what you mean in last post :
p.s.
0x0f = 15 = CPU0, CPU1, CPU2, and CPU3 (1+2+4+8 = 15) does NOT work with Xbase++ > v1.5 any more.
older Xbase++ Version have work with more than 1 CPU.
i point to Function DC_SetCpu(15, ...)
Victorio wrote:(Now I have on my PC with 4 cores/CPU 4 running application, 1. on CPU1,2. on CPU2,...
I set it with parameter 1,2,4,8. )
you can enable all CPU but with Xbase++ Version > v1.5 you Application will slow down and moving Mouse is a pain ...
greetings by OHR
Jimmy

Victorio
Posts: 631
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: Multicore processing

#44 Post by Victorio »

excuse me, Jimmy, you mean, in older Xbase can run app on more than one CPU in one time ?
for example I run app and this use all 4 CPUs ?

"DC_SetCpu( <nCPUs>, <cFile> ) -> nil
<nCPUs> is a number representative of the number of CPUs on the computer.
The default is 15 (4 CPUs).
Use 15 if 4 CPUs
Use 8 if 3 CPUs
Use 3 if 2 CPUs
Use 1 if 1 CPU"

but I use to set CPU this :
FUNCTION SmpSetCPU(nCpuMask)
LOCAL rc
rc := DllCall("Xpprt1.dll",DLL_CDECL, "_sysSetCPU", nCpuMask)
RETURN rc

I do not know, if it is good solution, I have not tested it on 64bit Windows.

But If I tested it on Windows 7 32bit with 4GB ram and i5 INTEL 3.2Ghz processor with 4 cores, have problem with temperature !!!
if running 4 application every on own CPU
Computer beeping :shock: and temperature was about 70 - 72 degrees celsius.
That it is not good solution, I must control performance to prevent this.

User avatar
Auge_Ohr
Posts: 1414
Joined: Wed Feb 24, 2010 3:44 pm

Re: Multicore processing

#45 Post by Auge_Ohr »

Victorio wrote:excuse me, Jimmy, you mean, in older Xbase can run app on more than one CPU in one time ?
YES but Alaska have change it ... when activeX and GUI Thread arrive.
Victorio wrote:

Code: Select all

"DC_SetCpu( <nCPUs>, <cFile> ) -> nil
// does include
DllCall("xpprt1.dll", DLL_CDECL, "_sysSetCPU", nSet)
so it does the same.
Victorio wrote:But If I tested it on Windows 7 32bit with 4GB ram and i5 INTEL 3.2Ghz processor with 4 cores, have problem with temperature !!!
if running 4 application every on own CPU
Computer beeping :shock: and temperature was about 70 - 72 degrees celsius.
That it is not good solution, I must control performance to prevent this.
i did had same Problem with my i7-QM2630 but the Temperature ( < 100°) is no Problem ... it is the noise from CPU Fan ;)

Question : how much CPU % does 1 of your Application need ?

Code: Select all

FOR i := 1 TO iMax
  // do_something
  SLEEP(1)
NEXT
without SLEEP(1) the loop might take 100%
greetings by OHR
Jimmy

Victorio
Posts: 631
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: Multicore processing

#46 Post by Victorio »

Now running 1 application on CPU 1 and use 100%
I can input sleep(1), what do it.
Fan noise is not problem, I have very silent PC, HP Z210 .
Attachments
cpu1.gif
cpu1.gif (14.27 KiB) Viewed 13197 times

User avatar
Auge_Ohr
Posts: 1414
Joined: Wed Feb 24, 2010 3:44 pm

Re: Multicore processing

#47 Post by Auge_Ohr »

Victorio wrote:Now running 1 application on CPU 1 and use 100%
I can input sleep(1), what do it.
seems your Application doing a lot of work.
if you show more Code we might help you to optimize it (please open new Thread)
Victorio wrote:Fan noise is not problem, I have very silent PC, HP Z210 .
OK.
Noise was my Reason to switch CPU every 60sec.
greetings by OHR
Jimmy

Victorio
Posts: 631
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: Multicore processing

#48 Post by Victorio »

Hi Jimmy,

Please tell me, what is a function POT2DEC() in your example ?

I examine switching random between CPU , it works, ok.
But this is, as you say not for performance , but only for fan noise.
Time processing is same, or little up (about 5%)

I want also examine put sleep(1) to my function in cycle, where is processing data, but time processing extremely up, not usable, no good. With sleep I used this :

cbprepinac:={||oTimer:=Thread():new(),;
oTimer:setInterval(10),;
oTimer:start("sleep",1)}
eval(cbprepinac)

this I do not know not work, ?

1. I want use all CPU , with running modules on every (each have own CPU swith, this is OK, so I do not test performance, if it will be better with run app on 4 CPU, or on 1 CPU, or 4 CPU with random swith every for example 100ms
This I want testing this weekend, after tests I say result.

2. I do not know, how can I prevent CPU usage to 100%, i can not slow process, I need control CPU utilization, and when go to for example 90%, put some "sleep" time.
I mean, it is difficult measure CPU utilization, and also need some thread.

3. I do in process cycle this :

cak++
if cak=5000
cak=0
sleep(1)
endif

and this down CPU utilization from 100% to about 95. This help me, but have negative effect to performance, about 5-10%.

This I want use in combination, every module running on own CPU and little down utilization from 100% to 90-95 to prevent halt PC.

I am very curious about the results ;)

User avatar
Auge_Ohr
Posts: 1414
Joined: Wed Feb 24, 2010 3:44 pm

Re: Multicore processing

#49 Post by Auge_Ohr »

Victorio wrote:Please tell me, what is a function POT2DEC() in your example ?
to assign a CPU you use

Code: Select all

nWorkCPU  := 2 ^INT(nStep-1)
if you "read" CPU No. this Function will reverse it

Code: Select all

FUNCTION POT2DEC(nPot)
LOCAL nRet  := 1
LOCAL nTest := 0
LOCAL nRest := 0

   nRest := nPot
   DO WHILE .T.
      nTest := (nRest / 2)
      IF nTest > 0.5
         nRest := nTest
         nRet++
      ELSE
         EXIT
      ENDIF
   ENDDO
RETURN STR(nRet,2)
Victorio wrote:

Code: Select all

cbprepinac:={||oTimer:=Thread():new(),;
		oTimer:setInterval(10),;
		oTimer:start("sleep",1)}
eval(cbprepinac)
this I do not know not work, ?
do you have a own Procedure "sleep" ...

if you have a Progressbar you would like have Code like this

Code: Select all

   xMax     := Lastrec()
   nEvery   := INT(xMax/100)
   xScale   := xMax*nEvery                // Scale to 100%
...
   IF ((nValue) % (nEvery)) == 0          // only every 1%
      nValue := oProgress:GetData()
      nValue += nEvery
      oProgress:SetData( nValue )
   ENDIF
Victorio wrote:2. I do not know, how can I prevent CPU usage to 100%, i can not slow process, I need control CPU utilization, and when go to for example 90%, put some "sleep" time.
I mean, it is difficult measure CPU utilization, and also need some thread.
if you got a Result with 100% it was in past ... and every Xbase++ DLL / ActiveX Call need (a lot) of Time.
i have not found any "live" Solution which works well with Xbase++ ... (but with harbour)

on a multithreading OS() it is not Programmers work to choise CPU ... normal are to use ALL CPUs
greetings by OHR
Jimmy

Victorio
Posts: 631
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: Multicore processing

#50 Post by Victorio »

Thank you, Jimmy

"on a multithreading OS() it is not Programmers work to choise CPU ... normal are to use ALL CPUs"

yes, but without random change CPU, Xbase app use only one CPU ,

It looks like, to reprogram some my function again to C++ , where this was very speed. I have utility in C++ (Borland C++) but works only on Windows 32bit, no 64bit., then I need 64bit compiler....

On Windows XP C++ utility use on same process only 20% CPU time....

Same algorithm with same proces with alaska utility (without GUI) use 100% CPU time and is 3-4x slower.

Post Reply