Multicore processing

This forum is for eXpress++ general support.
Message
Author
User avatar
rdonnay
Site Admin
Posts: 4734
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Multicore processing

#31 Post by rdonnay »

you can switch CPU but every Thread or RunShell() from EXE will run on same CPU like EXE
This is incorrect.

I wrote an Xbase++ application for a company that manufactures Hi-sensitivity metal detector portals.
This app needed to also have a camera application running that captured a video of people walking thru the portal.
The camera was using so much processor time that it would make the portal metal detection software fail because it communicates via IP with 2 microprocessors. I solved the problem by creating a separate camera program, also written in Xbase++, that runs on a different processor.
The Portal.Exe program launches the Camera.Exe program and then they communicate via a common shared file system.

Code: Select all

// Start of Portal.Exe
IF !DC_IsAppRunning('XbpDialog',cTitle,'CAMERA.EXE',.t.) .AND. Fexists('Camera.Exe')
  RunShell('','Camera.Exe',.t.,.t.)
ENDIF

// Start of Camera.Exe
IF DC_IsAppRunning('XbpDialog',cTitle,'CAMERA.EXE',.t.) .AND. Fexists('Camera.Exe')
  QUIT
ENDIF

DC_SetCpu(15,DC_Path(AppName(.t.))+'SetCpu.Smp')
The eXpress train is coming - and it has more cars.

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

Re: Multicore processing

#32 Post by Auge_Ohr »

rdonnay wrote:
you can switch CPU but every Thread or RunShell() from EXE will run on same CPU like EXE
I solved the problem by creating a separate camera program, also written in Xbase++, that runs on a different processor.
OK, you have 2 x Xbase++ Applikation and each is running on assign CPU.
this Technique is used e.g. when running Xbase++ Application on Terminal Server for each Session.

you also can start a Runshell(CMD) from a Xbase++ Application on any CPU but you can not start many Runshell() from same Main Xbase++ Application on different CPU like Victorio want to do
Yes, this I want,

Code: Select all

Runshell("1","program1"...)
Runshell("2","program1"...)
Runshell("3","program1"...)
Runshell("4","program1"...)
you can also "switch" CPU "on-fly" at Runtime while running different Threads http://bb.donnay-software.com/donnay/vi ... f=2&t=1135 but it always run on 1 CPU and Memory

only a real multi-threading DLL/ OCX like Mappoint.OCX seems to use all CPU in Taskmanager which Xbase++ (> v1.3) when calculate Route.
rdonnay wrote:The Portal.Exe program launches the Camera.Exe program and then they communicate via a common shared file system.
the communication between 2 x EXE is next Problem ...
greetings by OHR
Jimmy

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

Re: Multicore processing

#33 Post by Victorio »

"you can not start many Runshell() from same Main Xbase++ Application on different CPU"

hmm this is important. :think:

ok, and if I run several applications from batch file for example start.bat:
main.exe
moduleforcpu1.exe
moduleforcpu2.exe
...
main.exe show window with menu etc.
modules scan in cycle shared database, where is jobs waiting to process, for secure collision may be modules set to test this database to separate time, with offset (for example 5 sec.)
In real process will be :
moduleforcpu1 read job database on time hh:mm:00
moduleforcpu2 read job databse on time hh:mm:10
moduleforcpu2 read job databse on time hh:mm:20
...
if one from modules get job, set in database from waiting to processing
after process set to ready, and read again job database
modules can be in hide, or show only little window where is status info about processed job.

I know, this is very primitive system wery wery far from multithread system :oops:

Cliff Wiernik
Posts: 605
Joined: Thu Jan 28, 2010 9:11 pm
Location: Steven Point, Wisconsin USA
Contact:

Re: Multicore processing

#34 Post by Cliff Wiernik »

According to Roger's example, he is starting portal.exe, which is on 1 cpu and via runshell() starts the camera.exe and the camera.exe program changes to the next cpu number. So an application spawned via runshell() is on a different cpu.

You are saying it can not be done, which appears to be contrary to what Roger's experience has been.

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

Re: Multicore processing

#35 Post by Auge_Ohr »

Cliff Wiernik wrote:You are saying it can not be done, which appears to be contrary to what Roger's experience has been.
if your EXE, start from RunShell(), do "switch" CPU itself it is no Problem.

if you "switch" CPU in Main and than call RunShell() it will run on that CPU,
but if you have called other RunShell() before ( "many RunShell()" ) they will on same CPU as Main.
greetings by OHR
Jimmy

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

Re: Multicore processing

#36 Post by Auge_Ohr »

i start with c:\ALASKA\XPPW32\SOURCE\samples\solution\smp\smprun.prg

Code: Select all

Thread():new():start("stress")
DO WHILE .T.
    nCpu := SmpGetCPU()
1st Line i calling a Thread to make some "Stress" to CPU.

Code: Select all

    IF SmpSetCPU(nCpu) = 0
       ? "Kann CPU-Maske nicht setzen auf:" + var2char(nCpu)
    END
    RunShell(var2char(nCpu),'Stress.Exe',.t.,.t.)
ENDDO
now i disable 1st line with Thread and add RunShell() just before ENDDO. this is my Result
Run8Core.jpg
Run8Core.jpg (363.67 KiB) Viewed 13849 times
please verify my Result with include Source what i*m doing wrong while my Gadget show only CPU 1 working
RUNSHELL.ZIP
(2.1 KiB) Downloaded 696 times
greetings by OHR
Jimmy

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Multicore processing

#37 Post by Eugene Lutsenko »

Is it possible to get a real performance improvement program by using multiple cores?

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

Re: Multicore processing

#38 Post by Victorio »

I do not see, where is my last post...
I do some test, to my main application I put two buttons, PROCES 1 and PROCES 2.
First run Runshell smprun1.exe where is fix set CPU1, and second set to CPU 2

Here is result, running both CPUs,
Multi_CPU.jpg
Multi_CPU.jpg (750.61 KiB) Viewed 13841 times

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

Re: Multicore processing

#39 Post by Auge_Ohr »

Victorio wrote:Here is result, running both CPUs
you run Demo where the calling Xbase++ SMPRUNx.EXE does "switch itself" to CPU you choise.
this is like Terminal Server Session where you assign a CPU to every Thread.

what we talk about is "switch CPU" of MAIN where you Runshell() external Application like CALC.EXE on other CPU ...
greetings by OHR
Jimmy

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

Re: Multicore processing

#40 Post by Victorio »

now I understand it. You mean, some existing application which have not "switch" to switch cpu ?.

Post Reply