> I'm currently compiling the CryptoPP library to two target environments. 
>
> 1) Linux 64 using GCC compiler
> 2) Win 32 using Microsoft Visual Studio 
>

The biggest differences between X86 and X64 is additional registers count 
and size. Register count (or pressures) on X86 is why the library does not 
enable -fPIC by default. -fPIC takes away the EBX register on X86.

X64 uses up to 12 registers, so there's a lot more work area. See, for 
example, the AS_REG defines in CPU.h 
(https://github.com/weidai11/cryptopp/blob/master/cpu.h#L248).

Cache line sizes are also a little larger on X64 vs X86. I believe X86 uses 
a size of 32, while X64 uses 64 bytes.

I found that the Linux 64 version is 6 times faster that the Win 32 
> version. Is it right? Do you know any specific parameter to improve the 
> performance of the win 32 binary. I'm using a RELEASE target and setting 
> Visual Studio optimization parameters as OX (-O3). 
>

Windows spends a lot of time doing output to the console, and that's one of 
the reasons Windows is slower. That's also why MinGW is slow, too. Unix 
uses cout too, but the underlying implementation appears more efficient. 
Also see 
http://www.google.com/search?q=windows+c+improve+console+output+performance 
.

But there is another, not-so-readily apparent difference, and that is the 
CryptoPP::word size. On Linux, we are aggressive about using word128. In 
fact, we enable it if we find __SIZEOF_INT128__ defined by the 
preprocessor. INT128 is provided by the compilers, and it makes things 
lightening fast. Its a lot like INT64 in the 1990s when 32-bit was the 
norm. This was a recent change 
(https://github.com/weidai11/cryptopp/blob/master/config.h#L193).
 
Windows is limited to word64. I recently went looking to see if we could 
find something faster on Windows, but it appear to still be limited to 
64-bit words. I even dug through Intel's docs on SSE 4.1 ad 4.2.

The latest versions of GCC use SSE 4 extensively, and Windows does not. I 
think Windows uses abotu SSE2 and SSE3, but I'm not aware of it using SSE4. 
You can try to level things out a bit by adding CXXFLAGS+="-mno-sse4.1 
-mno-sse4.2". Also see 
https://gcc.gnu.org/onlinedocs/gcc-4.5.3/gcc/i386-and-x86_002d64-Options.html 
(and friends).

Also, -Os can produce faster code than -O3 because it keeps the caches 
hotter. For Windows, folks like Jeffrey Richter recommend using it. See, 
for example, http://www.amazon.com/dp/1572319968. (I think I read that book 
three times when I was younger, along with Robins, Petzold, Howard and 
LeBlanc's Windows books).

I tried using MinGW too, I built a version of CryptoPP using http://mxe.cc/ 
> but the performance is very similar to Visual Studio. Probably it is right 
> but surprise to me this difference. 
>

If you want Unix-on-Windows tools, then try Cygwin (if possible). Cygwin is 
less coupled to the OS and the Win32 API. It performs more like Unix and 
Linux. On the downside, you won't have access to Windows specific stuff, 
like WInsocks.

Jeff

-- 
-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscr...@googlegroups.com.
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
--- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cryptopp-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to