Normal Topic multi core processor (Read 889 times)
wase
Junior Member
**
Offline


Always looking for a good
code

Posts: 57
Location: Austria
Joined: Jun 22nd, 2004
multi core processor
Feb 12th, 2008 at 6:37pm
Print Post Print Post  
hi together

i want to use the full performance of my system with a quard core intel. but i get only the performance of one processor of my system. so is there a way to speed up my calculation?

the problem is my code has 3*n complexity and n is about 20.000 so it takes a while until the calc is done.

if anybody knowes an answer please help

-sebastian
  
Back to top
ICQ ICQ  
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: multi core processor
Reply #1 - Feb 12th, 2008 at 6:41pm
Print Post Print Post  
Sesame does take advantage of multiple processors, but you would mainly see it do so in a multi-client environment. Perhaps we can help you optimize your calculation instead?
« Last Edit: Feb 12th, 2008 at 7:57pm by Hammer »  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
wase
Junior Member
**
Offline


Always looking for a good
code

Posts: 57
Location: Austria
Joined: Jun 22nd, 2004
Re: multi core processor
Reply #2 - Feb 12th, 2008 at 6:49pm
Print Post Print Post  
ok thats the best way to get a faster result!

and i have to admit that my code is not optimal.

but i can post it here if this is ok. maybe you have some great ideas.

[code]
var vStammdaten as String
var vStammdatenSort as String
var vStammdatenSortArray as Array[20] of string
var vCompareArray as Array[20,3] of string
var vLagerdaten as String
var vLagerDatenSav as string
var vLagerSubDaten as String
var vLagerSubDatenSav as String
var vStammLength as int
var vLagerLength as int
var vStammSplit as string
var vStammSplitSav as String
var vStammSplitArt as string
var vCompare as String
var vSucheLager as string
var vSucheLAgerSub as string
var vFileopen as int
var vfileopen1 as int

var i as int
var j as int = 0
var vtemp as string

vfileopen = fileopen("e:\sesame\zoutput.txt")
vfileopen1 = fileopen("e:\sesame\zstammsub.txt")

vStammdaten = @insert("e:\sesame\stammv1.txt")
vLagerdaten =  @xlookupSourceListAll("10lager.db","z","ZTG_Datei!Abteilungsnummer","Artikelnummer;InternNr;Bezeichnung;Datum;Rueckgabedatum;BruttoVKVE")
if @error then
{
     writeln("xlu lager schief gegangen")
     stop
}
vLagerDatenSav = vLagerDaten
vLagerSubDaten =  @xlookupSourceListAll("10Lager.db","z..","ART_EAN!ArtNr","ArtNr;EAN;MWST;Preis_B;Preis_N")
if @error then
{
     writeln("xlu lagerSub schief gegangen")
     stop
}


vLagerSubDatenSav = vLagerSubDaten

setstringarrayseparator(@newline())
vStammLength = @countstringarray(vStammdaten)
vLagerLength = @CountStringArray(vLagerDaten)
restorestringarrayseparator()

for i = 1 to vStammLength
     vTemp = split(vStammDaten,@Newline())

     vStammdatenSortArray[1] = @mid(vTemp,5,6)
     vStammdatenSortArray[2] = @mid(vTemp,11,60)
     vStammdatenSortArray[3] = @mid(vTemp,79,3)
     vStammdatenSortArray[4] = @mid(vTemp,82,2)
     vStammdatenSortArray[5] = @mid(vTemp,84,32)
     vStammdatenSortArray[6] = @mid(vTemp,116,2)
     vStammdatenSortArray[7] = @mid(vTemp,118,1)
     vStammdatenSortArray[8] = @mid(vTemp,71,4)
     vStammdatenSortArray[9] = @mid(vTemp,75,4)
     vStammdatenSortArray[10] = @mid(vTemp,119,18)
     vStammdatenSortArray[11] = @mid(vTemp,137,1)
     vStammdatenSortArray[12] = @mid(vTemp,138,5)
     vStammdatenSortArray[13] = @mid(vTemp,143,15)
     vStammdatenSortArray[14] = @mid(vTemp,158,15)
     vStammdatenSortArray[15] = @mid(vTemp,174,4)
     vStammdatenSortArray[16] = @mid(vTemp,184,2) +"."+ @mid(vTemp,182,2) +"."+ @mid(vTemp,178,4)
     vStammdatenSortArray[17] = @mid(vTemp,192,2) +"."+ @mid(vTemp,190,2) +"."+ @mid(vTemp,186,4)
     vStammdatenSortArray[18] = @mid(vTemp,200,2) +"."+ @mid(vTemp,198,2) +"."+ @mid(vTemp,194,4)
     vStammdatenSortArray[19] = @mid(vTemp,1,2) + @left(vTemp,1)

     if vStammdatenSortArray[7] = @Str(3) then vStammdatenSortArray[7] = "M"
     if vStammdatenSortArray[7] = @Str(2) then vStammdatenSortArray[7] = "K"
     if vStammdatenSortArray[7] = @Str(1) then vStammdatenSortArray[7] = "P"

     while @left(vStammdatenSortArray[1],1) = "0"
     {
           vStammdatenSortArray[1] = @mid(vStammdatenSortArray[1],2,6)
     }

     while @left(vStammdatenSortArray[9],1) = "0"
     {
           vStammdatenSortArray[9] = @mid(vStammdatenSortArray[9],2,4)
     }

     vStammdatenSort = vstammdatensort +
                 vStammdatenSortArray[7] + vStammdatenSortArray[1] + " " + vStammdatenSortArray[9] + ";" +
                 vStammdatenSortArray[2] + ";" +
                 vStammdatenSortArray[3] + ";" +
                 vStammdatenSortArray[4] + ";" +
                 vStammdatenSortArray[5] + ";" +
                 vStammdatenSortArray[6] + ";" +
                 vStammdatenSortArray[7] + ";" +
                 vStammdatenSortArray[8] + ";" +
                 vStammdatenSortArray[9] + ";" +
                 vStammdatenSortArray[10] + ";" +
                 vStammdatenSortArray[11] + ";" +
                 vStammdatenSortArray[12] + ";" +
                 vStammdatenSortArray[13] + ";" +
                 vStammdatenSortArray[14] + ";" +
                 vStammdatenSortArray[15] + ";" +
                 vStammdatenSortArray[16] + ";" +
                 vStammdatenSortArray[17] + ";" +
                 vStammdatenSortArray[18] + ";" +
                 vStammdatenSortArray[19] + "$#$"

     writeln("teilen und neu zusammenbauen: " + i)
     if @mod(i,50) = 0 then cls()

next

vLagerSubDaten = @Replace(vLagerSubDaten,"=","#")

vLagerSubDaten = @Replace(vLagerSubDaten,";","$#$")
vStammdatenSort = @Replace(vStammdatenSort,"$#$",@NewLine())
vStammdatenSort = @Replace(vStammdatenSort,";","$#$")
vLagerDaten = @Replace(vLagerDaten,";","$#$")


setstringarrayseparator(@newline())
vStammdatenSort = @SortStringArray(vStammdatenSort,0)
vLagerdaten = @sortStringArray(vLagerdaten,0)
vLagerSubDaten = @SortStringArray(vLagerSubDaten,0)
restorestringarrayseparator()

vStammdatenSort = @Replace(vStammdatenSort,"$#$",";")
vLagerSubDaten = @Replace(vLagerSubDaten,"$#$",";")

for i = 1 to vStammLength
     vStammSplit = split(vStammDatenSort,@NewLine())
     vStammSplitSav = vStammSplit
     vStammSplitArt = split(vStammSplit,";")
     setstringarrayseparator(@newline())
     vSucheLager = @searchstringarray(vLagerDaten,vStammSplitArt+"$#$..")
     vSucheLagerSub = @searchStringArray(vLagerSubDaten,"Z???"+vStammSplitArt+"#..")
     restorestringarrayseparator()

setstringarrayseparator(@newline())
     if @countstringarray(vSucheLager) > 1 then
     {
           vSucheLager = split(vSucheLager,@Newline())
//            filewriteln(vfileopen1,vsuchelager)
     }
     if @countstringarray(vSucheLagerSub) > 1 then
     {
           vSucheLagerSub = split(vSucheLagerSub,@Newline())
     }
restorestringarrayseparator()


     if @len(vSucheLager) > 0 and @len(vSucheLagerSub) < 2 then
     {
           writeln("##################### so a schas ################" + vstammsplitart)
           filewriteln(vfileopen1,vLagerSubDaten)
     }
     if @len(vSucheLager) > 0 and @len(vsuchelagersub) > 0
     {
           vSucheLager = @Replace(vsuchelager,"$#$",";")
           vCompare = vCompare + "$#$" + vStammsplitSav + "|" +vSucheLager + "|" + vSucheLagerSub
     }

     writeln("teilen 2 " + i)
     if @mod(i,50) = 0 then cls()


next


vCompare = @Replace(vCompare,"$#$",@NewLine())
vCompare = @Replace(vCompare," ","")

setstringarrayseparator(@newline())
vStammLength = @countstringarray(vCompare)
restorestringarrayseparator()

for i = 1 to vStammLength

     vStammDaten = Split(vCompare,@NewLine())
     vStammDaten = split(vCompare,"|")
     vLagerDaten = split(vCompare,"|")
     vLagerSubDaten = split(vCompare,"|")

     for j = 1 to 19
           vCompareArray[j,1] = split(vStammDaten,";")
     next

     vTemp                  = split(vLagerDaten,";")
     vCompareArray[1,2]      = split(vLagerDaten,";")
     vCompareArray[2,2]      = split(vLagerDaten,";")
     vCompareArray[16,2]      = split(vLagerDaten,";")
     vCompareArray[17,2]      = split(vLagerDaten,";")
     vCompareArray[13,2]      = split(vLagerDaten,";")

     vCompareArray[1,3]      = split(vLagerSubDaten,";")
     vCompareArray[10,3]      = split(vLagerSubDaten,";")
     vCompareArray[15,3]      = split(vLagerSubDaten,";")
     vCompareArray[13,3]      = split(vLagerSubDaten,";")
     vTemp                  = split(vLagerSubDaten,";")
     
     if @Int(vCompareArray[10,1]) <> @Int(vCompareArray[10,3]) and vCompareArray[10,3]<>"" then //EAN Vergleich
     {
           filewriteln(vfileopen,"EAN-Aenderung" + vCompareArray[10,1] + " "+vCompareArray[10,3])
           xPost("10lager.db", @left(vCompareArray[1,2],@len(vCompareArray[1,2])-@len(vCompareArray[9,1]))+" "+vCompareArray[9,1]+"\=1","Art_EAN!ArtNr",@Int(vCompareArray[10,1]),"EAN","")
           if @error then filewriteln(vfileopen1,"posting EAN nicht erfolgt: " + vCompareArray[1,1])
           vTemp = "J"
     }
     
     if @TN(vCompareArray[13,1])/1000 <> @TN(vCompareArray[13,2]) then  //BruttoPreis
     {

           filewriteln(vfileopen,"Preisaenderung" + vCompareArray[13,1] + " "+vCompareArray[13,2])
           xPost("10lager.db", @left(vCompareArray[1,1],@len(vCompareArray[1,1])-@len(vCompareArray[9,1]))+" "+vCompareArray[9,1],"ZTG_Datei!Artikelnummer",@TN(vCompareArray[13,1])/1000,"BruttoVkVE","")
           xPost("10lager.db", @left(vCompareArray[1,2],@len(vCompareArray[1,2])-@len(vCompareArray[9,1]))+" "+vCompareArray[9,1]+"\=1","Art_EAN!ArtNr",@TN(vCompareArray[13,1])/1000,"Preis_B","")
           if @error then filewriteln(vfileopen1,"posting Preis nicht erfolgt: " + vcomparearray[1,1])
           vTemp = "J"            
     }

     if @TD(vCompareArray[16,1]) <> @TD(vCompareArray[16,2]) then  //Lieferdatum
     {
           filewriteln(vfileopen,"Lieferdatum" + vCompareArray[16,1] + " "+vCompareArray[16,2])
           xPost("10lager.db", @left(vCompareArray[1,1],@len(vCompareArray[1,1])-@len(vCompareArray[9,1]))+" "+vCompareArray[9,1],"ZTG_Datei!Artikelnummer",@TD(vCompareArray[16,1]),"Datum","")
           if @error then filewriteln(vfileopen1,"posting lieferdatum nicht erfolgt: " + vcomparearray[1,1])
           vTemp = "J"
     }
     
     if @TD(vCompareArray[17,1]) <> @TD(vCompareArray[17,2]) then  //Rückgabedatum
     {
           filewriteln(vfileopen,"Remissionsdatum" + vCompareArray[17,1] + " "+vCompareArray[17,2])
           xPost("10lager.db", @left(vCompareArray[1,1],@len(vCompareArray[1,1])-@len(vCompareArray[9,1]))+" "+vCompareArray[9,1],"ZTG_Datei!Artikelnummer",@TD(vCompareArray[17,1]),"RueckgabeDatum","")
           if @error then filewriteln(vfileopen1,"posting rückgabedatum nicht erfolgt: " + vcomparearray[1,1])
           vTemp = "J"
     }
     if vTemp = "J" then filewriteln(vFileOpen,"######## "+vCompareArray[1,1]+" "+vCompareArray[1,2]+" #######")

     writeln("vergleichen: " + i)
     if @mod(i,50) = 0 then cls()


next
fileclose(vFileopen)
fileclose(vFileopen1)

restorestringarrayseparator()

[/code]

this is the full code.

thanks in the front

-sebastian
  
Back to top
ICQ ICQ  
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: multi core processor
Reply #3 - Feb 12th, 2008 at 7:12pm
Print Post Print Post  
Wase,

There is a lot going on here. There is File I/O, X-commands, lots of parsing, etc. Speed can probably be increased at a number of points in this code, depending on which version of Sesame you have.

Optimization often depends on making use of knowledge of the specifics. In order to get maximum speed out of this, we will need to see 10lager.db and these external files you are reading/writing. We also need to know if this code is in 10lager.db or in a different application.

In addition, because this is a complicated piece of code, a good analysis and optimization run is several hours of work. I can't just point at a line or two and say "do this instead". 

If you want to, you can get in touch with Support (support@lantica.com) and we can work out how to approach this.

  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
wase
Junior Member
**
Offline


Always looking for a good
code

Posts: 57
Location: Austria
Joined: Jun 22nd, 2004
Re: multi core processor
Reply #4 - Feb 12th, 2008 at 7:29pm
Print Post Print Post  
the code is in a stand allone database.

now the version is 1.1.4 because i have to convert a hole system to the new version before i can convert this program. and this is a lot of work.

the inserted file is at http://www.presseangebot.at/download/stammv1.exe (unzip first)

the data in the 10lager.db is the same as in the file up but used in a sesame database (about 15 to 19 Mb).

the output is only for logging the events.

but i would be happy if you just could give me those "do this instead".

this program is used to update the 10lager.db with the data from the file. i want to run this one every second night so the runtime shuld be under 3 hours or something like that.

i will try myself to optimise it myself.
if it does not work at all i will contact the support.


-sebastian
  
Back to top
ICQ ICQ  
IP Logged
 
MP
Full Member
***
Offline



Posts: 104
Joined: Sep 3rd, 2007
Re: multi core processor
Reply #5 - Feb 12th, 2008 at 7:41pm
Print Post Print Post  
[quote author=wase link=1202841463/0#2 date=1202842149]ok thats the best way to get a faster result![/quote]
Speed optimizations related to multiple processors are only relevant in a multi-user client/server environment.  This is because the only time Sesame spawns multiple threads is when it is handling inbound client requests on the server. On the client side, Sesame is always running on a single thread.  Thus, only the machine running the Sesame server instance needs to be a multi-processor machine.  There is no direct benefit gained by running a Sesame client on a multi-processor machine.

See Page 530 of the Sesame 2 user's guide for more detail.
  
Back to top
 
IP Logged