Page 4 of 7

Re: Multicore processing

Posted: Wed Nov 18, 2015 4:47 pm
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')

Re: Multicore processing

Posted: Wed Nov 18, 2015 5:54 pm
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 ...

Re: Multicore processing

Posted: Thu Nov 19, 2015 5:38 am
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:

Re: Multicore processing

Posted: Thu Nov 19, 2015 9:05 am
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.

Re: Multicore processing

Posted: Thu Nov 19, 2015 10:58 am
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.

Re: Multicore processing

Posted: Thu Nov 19, 2015 9:01 pm
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 13875 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

Re: Multicore processing

Posted: Fri Nov 20, 2015 1:59 am
by Eugene Lutsenko
Is it possible to get a real performance improvement program by using multiple cores?

Re: Multicore processing

Posted: Fri Nov 20, 2015 2:49 am
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 13867 times

Re: Multicore processing

Posted: Fri Nov 20, 2015 11:59 am
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 ...

Re: Multicore processing

Posted: Fri Nov 20, 2015 1:41 pm
by Victorio
now I understand it. You mean, some existing application which have not "switch" to switch cpu ?.