Re: Fastcode UpperCase B&V 3.0



I made a new test for this

> Then we must be sure that there are no problems regarding the benchmarking
> order of functions.

procedure TMainForm.Button2Click(Sender: TObject);
var
I1, I2, J : Integer;

begin
for J := 1 to 10 do
begin
for I1 := 0 to FunctionSelectionRadioGroup.Items.Count-1 do
begin
FunctionSelectionRadioGroup.ItemIndex := I1;
BenchmarkButtonClick(nil);
Update;
end;
for I2 := FunctionSelectionRadioGroup.Items.Count-1 downto 0 do
begin
FunctionSelectionRadioGroup.ItemIndex := I2;
BenchmarkButtonClick(nil);
Update;
end;
end;
end;

This test runs the new Aleksandr functions just before and just after a
function that raises exceptions.

and made a SSE3 function based on one of John's SSE2 functions to provoke
exceptions on my Opteron 240

function UpperCaseJOH_SSE3_a(const S: string): string;
const
B05 : array[1..2] of Int64 = ($0505050505050505, $0505050505050505);
B65 : array[1..2] of Int64 = ($6565656565656565, $6565656565656565);
B20 : array[1..2] of Int64 = ($2020202020202020, $2020202020202020);
asm
xchg eax, edx
test edx, edx {Test for S = ''}
jz system.@LStrSetLength {Return Empty String}
mov ecx, edx {Addr(S)}
mov edx, [edx-4]
test edx, edx
jle system.@LStrSetLength {Return Empty String}
push ebx
push ecx {Addr(S)}
push edx {Length}
mov ebx, eax {Addr(Result)}
call system.@LStrSetLength {Create Result String}
pop ecx {Length}
pop eax {Addr(S)}
mov edx, [ebx] {Result}
cmp ecx, 16
jl @@Small
lddqu xmm2, B05
movdqu xmm3, B65
movdqu xmm4, B20
add eax, ecx
add edx, ecx
neg ecx
@@LargeLoop:
movdqu xmm0, [eax+ecx]
movdqu xmm1, xmm0
paddb xmm1, xmm2
pcmpgtb xmm1, xmm3
pand xmm1, xmm4
psubb xmm0, xmm1
movdqu [edx+ecx], xmm0
add ecx, 16
and ecx, -16 {Prevent Read Past Last Character}
jnz @@LargeLoop {Loop until all Characters Done}
pop ebx
ret
@@Small:
push ebp
lea ebp, UppercaseLookUp
@@SmallLoop:
sub ecx, 1
movzx ebx, [eax+ecx]
movzx ebx, [ebp+ebx]
mov [edx+ecx], bl
jg @@SmallLoop
pop ebp
pop ebx
end;

Regards
Dennis


.


Quantcast