Hey Jeff,

on my machine (which does have AVX2) I can reproduce the ChaCha crash.

When debugging in release mode, the exception that is indicated to me is
"Access violation when trying to read at address 0x0000000000000000" for
line 257 in chacha-avx.cpp . When looking at the disassembly, it looks
like the issue is caused by a vbroadcasti128 ymm1,oword ptr [rcx] 
instruction with VS telling me RCX is 0 and it looks like RCX is also
the loop counter. When then comparing things to the source, it looks
like MSVC has pushed the computation of state1 back behind the main loop
(probably to save registers) and thus it seems like state_mm resolved to 0.

Also for some weird reason, VS 2017 emits warnings and errors for me
when just grabbing the master branch and trying to build. Namely:

  * It rejects the size_t i=0 in scrypt.cpp and requires the counter
    variable to be signed, here one could convert i to be int64_t and
    assert that parallel doesn't take a value greater than representable
    by int64_t, using eg numeric_limits.
  * It complains about a shadowed definition of block in aria.cpp,
    renaming the block variable outside the if-else to eg Keyblock
    should fix that.
  * It rejects pragma omp simd, probably because MSVC doesn't implement
    OpenMP 4?
      o There are two cases, one in scrypt and one in salsa
      o The one in salsa, if the pragma is removed it does generate
        vectorized adds automatically in release mode
      o The one in scrypt, it does not generate vectorized XORs, I'd
        assume this to be because it determined the move into a vector
        register is not worth it? Also speculative and out-of-order
        execution of the CPU should parallelize this pretty well using
        the multiple functional units.

Maybe the latter two errors were not caught, because the CI builds don't
use the openMP flag?

Also, when running the test suite, I noticed that when testing for mod 0
operations with a_exp_b_mod_c and a_times_b_mod_c there's an assert and
a throw. The former breakpoints in debug mode on VS every time, because
the test is trying to reach the throw.

I would PR the fixes for the compilation issues, but I'm not sure how to
properly resolve the pragma omp simd issue, ie whether to remove the
pragma entirely and hope that the compilers detect these (relatively
straightforward) loops, or to define a new macro that checks for OpenMP
4 and generates to pragma omp simd if so or to just locally ifdef MSVC out?

BR

JPM


Am 09.11.2018 um 04:13 schrieb Jeffrey Walton:
>
>
> On Thursday, November 8, 2018 at 4:36:46 PM UTC-5, Jeffrey Walton wrote:
>
>     ...
>     We tested it on Unix and Linux, OS X, Solaris and Windows. We had
>     to make several tweaks to config.h and cpu.cpp, but it was a clean
>     cut-in. I would not be surprised if we needed a few more tweaks,
>     but I don't expect any major issues in the future.
>
>     The commit of interest is
>     https://github.com/weidai11/cryptopp/commit/d9011f07d2d5
>     <https://github.com/weidai11/cryptopp/commit/d9011f07d2d5> . Also
>     see https://github.com/weidai11/cryptopp/issues/735
>     <https://github.com/weidai11/cryptopp/issues/735> .
>
>
> It looks like Windows is a sore spot. Specifically, VS2017 x64 Release
> builds.
> https://ci.appveyor.com/project/noloader/cryptopp/builds/20159656 .
>
> I don't have a Windows machine with AVX2 to test it further.
>
> Can someone with a AVX2 and a Windows machine test ChaCha built with
> VS2017, please. You should only need to run 'cryptest.exe tv chacha'.
>
> Jeff
>
>
> -- 
> You received this message because you are subscribed to "Crypto++
> Users". More information about Crypto++ and this group is available at
> http://www.cryptopp.com and
> http://groups.google.com/forum/#!forum/cryptopp-users.
> ---
> 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 [email protected]
> <mailto:[email protected]>.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to "Crypto++ Users". More 
information about Crypto++ and this group is available at 
http://www.cryptopp.com and 
http://groups.google.com/forum/#!forum/cryptopp-users.
--- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to