-
Notifications
You must be signed in to change notification settings - Fork 572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update PrimePas.dpr #264
Update PrimePas.dpr #264
Conversation
Performance improved version that nearly doubles performance.
Performance improved Delphi code. |
See my pull request #365 - Adding the Inline compiler hint for getbit and clear bit also doubles performance. I see you have elminated those methods in any case so that seems consistent. I note also there is some discussion the comments that |
@KimMadsen I made a pull request against your patch-1 branch for converting the dictionary to static. |
I am new here and I have not made any contributions yet. But I found a way to improve the current Delphi implementation. Instead of procedure TPrimeSieve.ClearBit(Index: Integer); we could use procedure TPrimeSieve.ClearBit(const Index: Integer); I have observed a 2.1853% increase of passes without the Exit; call. Sorry if the indention isn't working all that well in this editor. Salut, |
Hey Mathias,
There are branches far ahead of the master.
See Issue 264 #264
and I also have a pull request KimMadsen#1 against KimAMadsens branch from my (misspelled ) branch https://github.com/glenkleidon/Primes/tree/path-1_gk
Rutger has made an issue for us to resolve all of our updates into one release.
#316 <#316>
So far Kim has not responded.
Glen.
From: mathias-burbach ***@***.***>
Sent: Saturday, 10 July 2021 7:36 PM
To: PlummersSoftwareLLC/Primes ***@***.***>
Cc: Glen Kleidon ***@***.***>; Comment ***@***.***>
Subject: Re: [PlummersSoftwareLLC/Primes] Update PrimePas.dpr (#264)
I am new here and I have not made any contributions yet. But I found a way to improve the current Delphi implementation.
Instead of
procedure TPrimeSieve.ClearBit(Index: Integer);
begin
if (Index mod 2) = 0 then
Exit;
FBitArray[Index div 2] := False;
end;
we could use
procedure TPrimeSieve.ClearBit(Index: Integer);
begin
if (Index mod 2) = 1 then
FBitArray[Index div 2] := False;
end;
I have observed a 2.18% increase of passes without the Exit; call.
Sorry if the indention isn't working all that well in this editor.
Salut,
Mathias
—
You are receiving this because you commented.
Reply to this email directly, <#264 (comment)> view it on GitHub, or <https://github.com/notifications/unsubscribe-auth/AE6JMPZSQ6KJZYEYVLVRPTTTXAH6RANCNFSM47YN4C6A> unsubscribe. <https://github.com/notifications/beacon/AE6JMP5F4OVLSDBJYDXXCCTTXAH6RA5CNFSM47YN4C6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOGRHTKQY.gif>
|
Hello Glen, Thanks your reply. You are right I was not aware of the more recent branch #264. I have downloaded it and find it extremely educational to compare the old version against the newer version. :-) If I run the latest branch on my Delphi VMware virtual machine I get to 9046 passes for 32bit. I wondered if there is a chance to further improve this by using unsigned integers like NativeUInt and convert the passes into NativeUInt too? But that slowed it down slightly. I thought it could help to increment the counter on less bytes, but it seems Inc works best on dword. So with my limited assembler knowledge it seems that there is not much more that I can contribute. But thanks for all the improvements anyhow and giving me the chance to study them. Salut, |
Probably,
But the biggest bottleneck is setting the bit array.
I am just testing re-implementation of Dave’s original GetBit and ClearBit to be identical to the C++ code (and then inlining them) – I cant see why it wouldn’t run at the same speed as the C++ code then.
Glen.
From: mathias-burbach ***@***.***>
Sent: Sunday, 11 July 2021 5:59 PM
To: PlummersSoftwareLLC/Primes ***@***.***>
Cc: Glen Kleidon ***@***.***>; Comment ***@***.***>
Subject: Re: [PlummersSoftwareLLC/Primes] Update PrimePas.dpr (#264)
Hello Glen,
Thanks your reply. You are right I was not aware of the more recent branch #264 <#264> .
I have downloaded it and find it extremely educational to compare the old version against the newer version. :-)
If I run the latest branch on my Delphi VMware virtual machine I get to 9046 passes for 32bit.
I wondered if there is a chance to further improve this by using unsigned integers like NativeUInt and convert the passes into NativeUInt too? But that slowed it down slightly. I thought it could help to increment the counter on less bytes, but it seems Inc works best on dword.
So with my limited assembler knowledge it seems that there is not much more that I can contribute.
But thanks for all the improvements anyhow and giving me the chance to study them.
Salut,
Mathias
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#264 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AE6JMP356AJZZZ5XQCOQCZLTXFFLTANCNFSM47YN4C6A> . <https://github.com/notifications/beacon/AE6JMPZGGZRKNLYIG2QOBPTTXFFLTA5CNFSM47YN4C6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOGRIYNSQ.gif>
|
I built the current C++ version on the same machine as my patch for Kim’s solution.
My latest Delphi version runs as fast as the c++ solution now. But its no longer strictly apples for apples as Kim’s solution reduces the array size by 50% by not allocating memory for the unus(able) even number array records. The C++ one doesn’t do that. If it did, then likely it would be faster again.
#316
Glen.
From: ***@***.*** ***@***.***>
Sent: Sunday, 11 July 2021 6:03 PM
To: 'PlummersSoftwareLLC/Primes' ***@***.***>
Subject: RE: [PlummersSoftwareLLC/Primes] Update PrimePas.dpr (#264)
Probably,
But the biggest bottleneck is setting the bit array.
I am just testing re-implementation of Dave’s original GetBit and ClearBit to be identical to the C++ code (and then inlining them) – I cant see why it wouldn’t run at the same speed as the C++ code then.
Glen.
From: mathias-burbach ***@***.*** ***@***.***> >
Sent: Sunday, 11 July 2021 5:59 PM
To: PlummersSoftwareLLC/Primes ***@***.*** ***@***.***> >
Cc: Glen Kleidon ***@***.*** ***@***.***> >; Comment ***@***.*** ***@***.***> >
Subject: Re: [PlummersSoftwareLLC/Primes] Update PrimePas.dpr (#264)
Hello Glen,
Thanks your reply. You are right I was not aware of the more recent branch #264 <#264> .
I have downloaded it and find it extremely educational to compare the old version against the newer version. :-)
If I run the latest branch on my Delphi VMware virtual machine I get to 9046 passes for 32bit.
I wondered if there is a chance to further improve this by using unsigned integers like NativeUInt and convert the passes into NativeUInt too? But that slowed it down slightly. I thought it could help to increment the counter on less bytes, but it seems Inc works best on dword.
So with my limited assembler knowledge it seems that there is not much more that I can contribute.
But thanks for all the improvements anyhow and giving me the chance to study them.
Salut,
Mathias
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#264 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AE6JMP356AJZZZ5XQCOQCZLTXFFLTANCNFSM47YN4C6A> . <https://github.com/notifications/beacon/AE6JMPZGGZRKNLYIG2QOBPTTXFFLTA5CNFSM47YN4C6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOGRIYNSQ.gif>
|
@KimMadsen Do you still want to pursue getting this PR merged? The same question applies to #281. |
Closing this based on comments made in #281. |
Performance improved version that nearly doubles performance.
Description
Contributing requirements
drag-race
as the target branch.