News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

New right trim algo.

Started by hutch--, June 13, 2014, 01:14:42 AM

Previous topic - Next topic

dedndave

nidud StrTrim3
prescott w/htt
Intel(R) Pentium(R) 4 CPU 3.00GHz (SSE3)
------------------------------------------------------
36191   cycles - 0: standard (scasb)
21212   cycles - 1: rtrim1
20491   cycles - 2: rtrim2
11768   cycles - 3: new strlen (AgnerFog)
16217   cycles - 4: rtrimUltra (Masm32 len)
15518   cycles - 5: rtrim3
11998   cycles - 6: repeat 4 (AgnerFog)
10416   cycles - 7: rtrimUltra (MasmBasic Len) - SSE
8129    cycles - 8: strtrim unaligned - SSE

29498   cycles - 0: standard (scasb)
21395   cycles - 1: rtrim1
22650   cycles - 2: rtrim2
11830   cycles - 3: new strlen (AgnerFog)
15956   cycles - 4: rtrimUltra (Masm32 len)
14441   cycles - 5: rtrim3
11902   cycles - 6: repeat 4 (AgnerFog)
10443   cycles - 7: rtrimUltra (MasmBasic Len) - SSE
9087    cycles - 8: strtrim unaligned - SSE

31280   cycles - 0: standard (scasb)
21175   cycles - 1: rtrim1
23340   cycles - 2: rtrim2
11768   cycles - 3: new strlen (AgnerFog)
16005   cycles - 4: rtrimUltra (Masm32 len)
14263   cycles - 5: rtrim3
12082   cycles - 6: repeat 4 (AgnerFog)
10416   cycles - 7: rtrimUltra (MasmBasic Len) - SSE
8142    cycles - 8: strtrim unaligned - SSE

dedndave

Hutch #3
prescott w/htt @ 3.0 GHz
359 milliseconds rtrim1
328 milliseconds rtrim2
141 milliseconds rtrim3
438 milliseconds rtrim1
328 milliseconds rtrim2
141 milliseconds rtrim3
360 milliseconds rtrim1
328 milliseconds rtrim2
141 milliseconds rtrim3
375 milliseconds rtrim1
328 milliseconds rtrim2
141 milliseconds rtrim3

sinsi

hutch latest (use code tags, n00b)

125 milliseconds rtrim1
78 milliseconds rtrim2
62 milliseconds rtrim3

141 milliseconds rtrim1
78 milliseconds rtrim2
46 milliseconds rtrim3

125 milliseconds rtrim1
78 milliseconds rtrim2
47 milliseconds rtrim3

125 milliseconds rtrim1
94 milliseconds rtrim2
47 milliseconds rtrim3



sinsi

nidud latest

Intel(R) Core(TM) i7-3770K CPU @ 3.50GHz (SSE4)
----------------------------------------------------
13864   cycles - 0: standard (scasb)
13400   cycles - 1: rtrim1
11011   cycles - 2: rtrim2
4630    cycles - 3: new strlen (AgnerFog)
5866    cycles - 4: rtrimUltra (Masm32 len)
3843    cycles - 5: rtrim3
3542    cycles - 6: repeat 4 (AgnerFog)
2604    cycles - 7: rtrimUltra (MasmBasic Len) - SSE
1555    cycles - 8: strtrim unaligned - SSE

14328   cycles - 0: standard (scasb)
14194   cycles - 1: rtrim1
10710   cycles - 2: rtrim2
4967    cycles - 3: new strlen (AgnerFog)
6027    cycles - 4: rtrimUltra (Masm32 len)
3792    cycles - 5: rtrim3
3449    cycles - 6: repeat 4 (AgnerFog)
2669    cycles - 7: rtrimUltra (MasmBasic Len) - SSE
1642    cycles - 8: strtrim unaligned - SSE

13670   cycles - 0: standard (scasb)
14597   cycles - 1: rtrim1
10797   cycles - 2: rtrim2
4746    cycles - 3: new strlen (AgnerFog)
5665    cycles - 4: rtrimUltra (Masm32 len)
3872    cycles - 5: rtrim3
3487    cycles - 6: repeat 4 (AgnerFog)
2690    cycles - 7: rtrimUltra (MasmBasic Len) - SSE
1514    cycles - 8: strtrim unaligned - SSE


nidud

#34
deleted

Gunther

Results from rtrim:

Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz (SSE4)
------------------------------------------------------
140233  cycles - 500 ( 41) 0: strtrim
114064  cycles - 500 ( 53) 1: **failed** rtrim1
107836  cycles - 500 ( 50) 2: **failed** rtrim2
44405   cycles - 500 (319) 3: **failed** rtrim3
50526   cycles - 500 (103) 4: AgnerFog
49096   cycles - 500 ( 66) 5: AgnerFog (unaligned)
68013   cycles - 500 (  0) 6: **failed** rtrimUltra (Masm32 len)
27418   cycles - 500 (  0) 7: **failed** rtrimUltra (MasmBasic Len) - SSE
26399   cycles - 500 ( 60) 8: **failed** strtrim - SSE
--- ok ---

strlen:

Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz (SSE4)
------------------------------------------------------
113712  cycles - 50 (  0) 0: crt_strlen
189882  cycles - 50 (  0) 1: MASM32 - szLen()
21866   cycles - 50 (  0) 2: MasmBasic MbStrLen Len() - SSE
102459  cycles - 50 ( 86) 3: AgnerFog
100484  cycles - 50 ( 49) 4: AgnerFog unaligned
222688  cycles - 50 ( 94) 5: Dave
24659   cycles - 50 ( 45) 6: strlen SSE
--- ok ---

strstr:

Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz (SSE4)
------------------------------------------------------
382038  cycles - 50 ( 67) 1: strstr
379086  cycles - 50 ( 71) 2: x
376889  cycles - 50 ( 57) 4: x
382763  cycles - 50 ( 54) 5: x
382307  cycles - 50 ( 50) 7: x
--- ok ---


OS is Win 7-64, SP 1.

Gunther
You have to know the facts before you can distort them.

jj2007

Quote from: nidud on July 16, 2014, 09:20:31 PM
148115  cycles - 500 (  0) 6: **failed** rtrimUltra (Masm32 len)
102954  cycles - 500 (  0) 7: **failed** rtrimUltra (MasmBasic Len) - SSE

How do they fail? Where are they? I count 40 files in your archive, dispersed over three folders, but can't find my algos there (and they usually don't fail :icon_mrgreen:).

Besides, the various makeit.bat don't create any executable, so where is the testbed? Is it one folder higher:

test.exe
test.obj
strlen.exe
test.asm
strstr.exe
rtrim.exe
makeit.bat
?? All 4 exe files brutally fail with a GPF...

nidud

#37
deleted

jj2007

Quote from: nidud on July 18, 2014, 11:21:02 AM
Quote(and they usually don't fail :icon_mrgreen:).
arg:    db ' ',13,10,0 ; 000A0D20h
result: db ' ',00,10,0 ; 000A0020h

error: **failed** rtrimUltra (MasmBasic Len) - SSE

They don't fail, they just don't return what validate_x expects. Rtrim$() tells Let, Cat$() or Print where the trimmed string starts, and how many bytes are valid. In many cases, this is more efficient than shuffling bytes around.

nidud

#39
deleted

jj2007

include \masm32\MasmBasic\MasmBasic.inc      ; download
TheSrc      db "The source       ", 0
  Init
  mov esi, Cat$(Rtrim$(offset TheSrc))
  .While 1
      lodsb
      .Break .if !al
      Print Hex$(al), " "
  .Endw
  Inkey " - OK?"
  Exit
end start



54 68 65 20 73 6F 75 72 63 65  - OK?

;-)

nidud

#41
deleted

jj2007

Sorry, this intrigues me - and I can't reproduce the problems. Can you post source and exe, please?
Thanks :icon14:

jj2007

Again, can't see how to reproduce this one. Besides, what did you use to produce the Ascii 13 of \r ? cStyle$() doesn't recognise that escape character, just \t and \n.

include \masm32\MasmBasic\MasmBasic.inc      ; download
.code
TheSrc    db "The source       ", 0
TheR      db "  ", 9, 13, 13, 10, 0
start:
  Print "RTRIM$: |", Rtrim$("                Trim a string                "), "|",CrLf$
  Print "[", Rtrim$(cStyle$("1 \t\n\n")), "]", CrLf$
  Print "[", Rtrim$(cStyle$("  \t\n\n")), "]", CrLf$
  Print "[", Rtrim$(offset TheR), "]", CrLf$
  mov esi, Cat$(Rtrim$(offset TheSrc))
  .Repeat
      lodsb
      Print Hex$(al), " "
  .Until !byte ptr [esi]
  Inkey " - OK?"
  Exit
end start


Output:

RTRIM$: |                Trim a string|
[1]
[]
[]
54 68 65 20 73 6F 75 72 63 65  - OK?


Can you post your source and the crashing exe, please?

nidud

#44
deleted