Forum > General
Conversion from C#
Blaazen:
Is this correct?
C#
--- Code: ---h32 ^= h32 >> 15;
--- End code ---
FPC
--- Code: ---h32 := h32 xor (h32 shr 15);
--- End code ---
Leledumbo:
yes
Blaazen:
Thanks. I'm converting xxHash (https://code.google.com/p/xxhash/) to FPC. My first attempt was to pass the original C code thru C2PAS32 (AstonShell) convertor but the code was a pure chaos for me - to many directives since it is the code for 32 and 64 bits and for little and big endian.
There are ports to other languages so I choosed C# 'cause it looked nice to me.
Luckily it gives me correct results now, I'll try to work on performance a little and I'll consider if it will be plain pascal or an object.
EDIT: I forgot to mention, I tried to Google for "xxHash delphi" - no luck. I also tried to find some documentation for xxHash but seems there's nothing around, only C code.
engkin:
--- Quote from: Blaazen on August 22, 2014, 05:30:16 pm ---I'm converting xxHash (https://code.google.com/p/xxhash/) to FPC.
--- End quote ---
According to the link:
--- Quote ---32-bits hash comparison (single thread, Windows Seven 32 bits, using Open Source's SMHasher on a Core 2 Duo @3GHz)
...
xxHash 5.4 GB/s 10
--- End quote ---
That's an impressive speed. I did not get anything near it here. :(
Blaazen:
On my machine (Core2Duo P7350@2GHz), I got following results:
From original C code:
--- Code: ---[v1@msi-NB xxHash-r35]$ ./xxHash /media/disk/v1/maverick.iso
*** xxHash tester 64-bits , by Yann Collet (Aug 20 2014) ***
Sanity check -- all tests ok
Loading /media/disk/v1/maverick.iso...
XXH32 : 728754176 -> 3259.9 MB/s 0xB62779A6
XXH32 (unaligned : 728754175 -> 2730.7 MB/s
XXH64 : 728754176 -> 3354.8 MB/s 0x55474CC558423F11
[v1@msi-NB xxHash-r35]$
--- End code ---
And FPC port:
--- Code: ---/media/disk/v1/maverick.iso
aLength 728754176
File loaded
Average time: 449.860ms
Average speed: 1544.912MB/s
B62779A6
...
/media/disk/v1/maverick.iso
aLength 728754176
File loaded
Average time: 276.780ms
Average speed: 2510.998MB/s
55474CC558423F11
--- End code ---
Results for 64-bits looks good, I see there a space for optimalizations but 32-bits results looks strange. To me it seems that GCC does some magic for 32-bit operations on 64-bit CPU because speed of FPC is almost exactly 50%.
EDIT:
I'm already at 3200MB/s with 64-bit version, it's 93% of GNU GCC. :)
Navigation
[0] Message Index
[#] Next page