Board index » delphi » Re: Fastcode CharPosRev B&V 0.6.2

Re: Fastcode CharPosRev B&V 0.6.2


2006-11-28 10:45:52 PM
delphi14
Hi John
Can you explain why the function call in the errortrap is different from the
call in the validation function?
My functions have a bug but it is not reveiled in the ErrorTrap call.
Quote
Result := CharPosRevFunction(Ch, S) = 0;
if not Result then
begin
ErrorTrap(VALIDATENO, Ch, S);
The Length field or the refcount field must be different there.
Best regards
Dennis Kjaer Christensen
----------------------------------------------------------------------------
----
Jeg beskyttes af den gratis SPAMfighter til privatbrugere.
Den har indtil videre sparet mig for at f?6011 spam-mails
Betalende brugere får ikke denne besked i deres e-mails.
Hent en gratis SPAMfighter her.
 
 

Re: Fastcode CharPosRev B&V 0.6.2

"Dennis" <XXXX@XXXXX.COM>writes
Quote
Hi John

Perhaps we should give this function another name.

function CharPosRev_JOH_IA32_4_a(SearchChar : Char; const S: string) :
pshuflw xmm0, xmm0, 0
pshufd xmm0, xmm0, 0 {All 16 Bytes of xmm0 = cl}
movdqu xmm1, [eax+edx] {Check Last 16 Chars}
pcmpeqb xmm1, xmm0
pmovmskb ecx, xmm1

What about?

function CharPosRev_JOH_SSE2_1_a(SearchChar : Char; const S: string) :
As corrected further up in this thread.
--
regards,
John
The Fastcode Project:
www.fastcodeproject.org/
 

Re: Fastcode CharPosRev B&V 0.6.2

Hi
The bug in my SSE2 functions is very simple
@LoopStartBig :
movdqu xmm0,[edx+ecx-15]
pcmpeqb xmm0,xmm1
pmovmskb ebx,xmm0
test bx,bx
jnz @MatchX
sub ecx,16
cmp ecx,4 <----------------------------- should be 16
jnl @LoopStartBig
The validation must be pretty weak when it did not discover that. Good we
fixed that.
Best regards
Dennis Kjaer Christensen
----------------------------------------------------------------------------
----
Jeg beskyttes af den gratis SPAMfighter til privatbrugere.
Den har indtil videre sparet mig for at f?6011 spam-mails
Betalende brugere får ikke denne besked i deres e-mails.
Hent en gratis SPAMfighter her.
 

Re: Fastcode CharPosRev B&V 0.6.2

"Dennis" <XXXX@XXXXX.COM>writes
Quote
Hi John

Can you explain why the function call in the errortrap is different from
the
call in the validation function?

My functions have a bug but it is not reveiled in the ErrorTrap call.

>Result := CharPosRevFunction(Ch, S) = 0;
>if not Result then
>begin
>ErrorTrap(VALIDATENO, Ch, S);

The Length field or the refcount field must be different there.
The call to the ErrorTrap procedure increments the string reference count
You can see this if you put a watch on:-
pintegerarray(cardinal(s)-8)^
--
regards,
John
The Fastcode Project:
www.fastcodeproject.org/
 

Re: Fastcode CharPosRev B&V 0.6.2

Hi
My MMX functions also have a bug
@LoopStartBig :
movq mm1,[edx+ecx-7]
pcmpeqb mm1,mm0
packsswb mm1,mm1
movd ebx,mm1
test ebx,ebx
jnz @MatchX
sub ecx,8
cmp ecx,4 <-------------------------8
jnl @LoopStartBig
@LoopEndBig :
This bug is found found by the new validation and I made this to get it
function TMainForm.Validate16 : Boolean;
var
I, Iref, J, RefCountS, RefCountSold, K : Integer;
S, Sold : String;
SearchChar : Char;
const
VALIDATE14MAX : Integer = 25500;
VALIDATENO : Cardinal = 16;
begin
StatusBar1.SimpleText := 'Running Validate16';
Update;
Result := True;
S := '';
for J := 1 to VALIDATE14MAX do
begin
for K := 1 to 255 do
begin
SearchChar := Char(K);
//Iref := CharPosRevRef(SearchChar, S);
Iref := 0;
Sold := S;
try
I := CharPosRevFunction(SearchChar, S);
if I <>Iref then
begin
ErrorTrap(VALIDATENO, SearchChar, S);
Result := False;
Exit;
end;
if Length(S) <>Length(Sold) then
begin
ErrorTrap(VALIDATENO, SearchChar, S);
Result := False;
Exit;
end;
RefCountS := GetRefCount(S);
RefCountSold := GetRefCount(Sold);
if RefCountS <>RefCountSold then
begin
ErrorTrap(VALIDATENO, SearchChar, S);
Result := False;
Exit;
end;
except
ErrorTrap(VALIDATENO, SearchChar, S);
Result := False;
end;
end;
S := S + #0;
end;
end;
Best regards
Dennis Kjaer Christensen
----------------------------------------------------------------------------
----
Jeg beskyttes af den gratis SPAMfighter til privatbrugere.
Den har indtil videre sparet mig for at f?6011 spam-mails
Betalende brugere får ikke denne besked i deres e-mails.
Hent en gratis SPAMfighter her.
 

Re: Fastcode CharPosRev B&V 0.6.2

Hi John
Yes I see it. Thanks.
Can you make a validation function for not reading across page boundaries?
Best regards
Dennis Kjaer Christensen
----------------------------------------------------------------------------
----
Jeg beskyttes af den gratis SPAMfighter til privatbrugere.
Den har indtil videre sparet mig for at f?6011 spam-mails
Betalende brugere får ikke denne besked i deres e-mails.
Hent en gratis SPAMfighter her.
 

Re: Fastcode CharPosRev B&V 0.6.2

I don't think 25500 loops are necessary. Setting VALIDATE14MAX to 272
(256+16) should be sufficient (and much faster)
--
regards,
John
The Fastcode Project:
www.fastcodeproject.org/
Quote
function TMainForm.Validate16 : Boolean;

VALIDATE14MAX : Integer = 25500;
 

Re: Fastcode CharPosRev B&V 0.6.2

Hi
Quote
I don't think 25500 loops are necessary. Setting VALIDATE14MAX to 272
(256+16) should be sufficient (and much faster)
And allow the use of a 16 byte register for the length and the loop counter?
Because we do not have the money to pay for the CPU's to run ;-)
Best regards
Dennis Kjaer Christensen
----------------------------------------------------------------------------
----
Jeg beskyttes af den gratis SPAMfighter til privatbrugere.
Den har indtil videre sparet mig for at f?6011 spam-mails
Betalende brugere får ikke denne besked i deres e-mails.
Hent en gratis SPAMfighter her.
 

Re: Fastcode CharPosRev B&V 0.6.2

Hi
Quote
And allow the use of a 16 byte register for the length and the loop
counter?
I think 16 bit would be enough ;-)
Longer strings will set more bits of the length field. We could validate
against longer strings without validation agains all of them. I will make a
validation function with exponential length increase instead of linear.
Best regards
Dennis Kjaer Christensen
----------------------------------------------------------------------------
----
Jeg beskyttes af den gratis SPAMfighter til privatbrugere.
Den har indtil videre sparet mig for at f?6011 spam-mails
Betalende brugere får ikke denne besked i deres e-mails.
Hent en gratis SPAMfighter her.