Multi core CPU

This forum is for eXpress++ general support.
Message
Author
STLau
Posts: 11
Joined: Mon Feb 08, 2010 11:35 pm

Re: Multi core CPU

#11 Post by STLau »

I attach the print screen for the error.
Attachments
error.GIF
error.GIF (19.04 KiB) Viewed 14873 times

User avatar
Tom
Posts: 1173
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Multi core CPU

#12 Post by Tom »

Hi, Stu.

Is "XppRt1.DLL" in the path of your program? What version is it (run "xppload" to get version information)? The error message is an eXpress++-error, so you don't run the Alaska-sample from ..\Source\Samples\Solution\Smp, but something else. Does this work at your site?
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

STLau
Posts: 11
Joined: Mon Feb 08, 2010 11:35 pm

Re: Multi core CPU

#13 Post by STLau »

Hi Tom

There is no problem when I run from ..\Source\Samples\Solution\Smp. The problem arise only when I copy and paste the SMP code into my own program.
When I remove the SMP code, my application run well. Once I add in the SMP code, runtime error occur. I am still using xbase 1.8 and express build 236.

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

Re: Multi core CPU

#14 Post by Auge_Ohr »

hi,
STLau wrote:There is no problem when I run from ..\Source\Samples\Solution\Smp.
...
Once I add in the SMP code, runtime error occur.
where did you add what Code ? please show us some Line of Code how you have implement it ...
greetings by OHR
Jimmy

STLau
Posts: 11
Joined: Mon Feb 08, 2010 11:35 pm

Re: Multi core CPU

#15 Post by STLau »

I have removed all codes and left with very simple program as attached. You can build the exe and run it to see the runtime error.
if you remove the 3 lines as indicated in the program, there will be no error.

Attached is x123.prg and x123.xpj.

STLau
Posts: 11
Joined: Mon Feb 08, 2010 11:35 pm

Re: Multi core CPU

#16 Post by STLau »

#include "dcdialog.ch"
#include "dcbitmap.ch"
#include "dcicon.ch"
#include "appevent.ch"
#include "xbp.ch"
#include "inkey.ch"
#include "dcmsg.ch"
#include "dll.ch"

Procedure appsys
RETURN



PROCEDURE MAIN
LOCAL GETOPTIONS,GETLIST:={},oApp:=SetAppWindow(),oXbp,nCPU

MSGBOX('TEST 1')
** remove this 3 lines will have no error
*----------------------------------------
thread():new():start("stress")
Ncpu:=smpgetcpu()
msgbox(str(Ncpu))
*----------------------------------------
MSGBOX('TEST 2')
DCREAD GUI
RETURN


FUNCTION SMPGETCPU()
LOCAL I
I:=DLLCALL("XPPRT1.DLL",DLL_CDECL,"_SYSGETCPU")
RETURN I

procedure stress()
local a:={3,2,1,0}
do while .t.
asort(a)
enddo
return

* xpj ---------------------------------------------

[PROJECT]
COMPILE = xpp
COMPILE_FLAGS = /q /n /m /p /dll:DYNAMIC
DEBUG = yes
GUI = yes
LINKER = alink
LINK_FLAGS =
RC_COMPILE = arc
RC_FLAGS = -v
OBJ_FORMAT = COFF
X123.XPJ

[X123.XPJ]
X123.EXE
[X123.EXE]
DCLIPX.LIB
X123.PRG


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

Re: Multi core CPU

#17 Post by Auge_Ohr »

STLau wrote:I:=DLLCALL("XPPRT1.DLL",DLL_CDECL,"_SYSGETCPU")
this is WRONG !!!
oError:args :
-> VALTYPE: C VALUE: Xpprt1.dll
-> VALTYPE: N VALUE: 8
-> VALTYPE: C VALUE: _SYSGETCPU
oError:canDefault : J
oError:canRetry : N
oError:canSubstitute: N
oError:cargo : NIL
oError:description : Unbekannte Funktion
oError:filename :
oError:genCode : 21
oError:operation : dllPrepareCall
ist must be "lower()"

Code: Select all

i := DllCall("Xpprt1.dll",DLL_CDECL, "_sysGetCPU")
greetings by OHR
Jimmy

STLau
Posts: 11
Joined: Mon Feb 08, 2010 11:35 pm

Re: Multi core CPU

#18 Post by STLau »

Hi Auge_Ohr

Yes, the problem is solved. Never thought of such possible cause. Thank you very much for your help.

regards

STLau
Posts: 11
Joined: Mon Feb 08, 2010 11:35 pm

Re: Multi core CPU

#19 Post by STLau »

After implementing the DC_setcpu() as provided by Roger, the assignment of CPU core works, however, the assignment is based on the last CPU# saved in the file created. Therefore, it can end up with a situation where the same core is running for a few application when all application in other core quit.

eg, I execute 12 times the same program on a 4 CORE CPU. The Core use is 0123 0123 0123 for a start. But when the program ended in core 1,2 and 3. It will left with core 0 runnning for 3 appilcation.

I would like to know is there a way to detect the next available CPU and assign to that CPU instead of sequentially allocate to the next CPU.

Regards

User avatar
Markus Walter
Posts: 54
Joined: Thu Jan 28, 2010 12:49 am
Location: Germany

Re: Multi core CPU

#20 Post by Markus Walter »

Hello,

i think that would be useless. Even if you test the load of the core units in this moment, you can't look in the future. Perhaps one core is now with small load, but in the next second a task which runs on this core unit generates a big load... In my opinion analyzing cpu loads could only help if we could switch a running task from one unit to another, but this is not possible with xbase or if the os can do the job, but this isn't possible with xbase-exes, too.
I use a random algorithsm and this works good (exp. on Terminal Server)...
-----------------
Greetings
Markus Walter

Post Reply