GMP use in vcpkg on Windows

Marc Glisse marc.glisse at
Tue Sep 21 19:43:12 UTC 2021

On Tue, 21 Sep 2021, Neill Clift wrote:

> I just built a thin layer so I can run my addition chain code with GMP instead of boost fixed size integers. I am using the low level MPN_ routines.
> I got about an 8% improvement in performance. My integers are not that big though. I am currently trying to find an optimal addition chain for 2^141-1 so my calculation are limited to ~140 bits.
> I test performance with the much easier 2^145-1 test case. So 64 bit limbs are mostly going to be 2 in most calculations.
> I am seeing about 4% of the time in _gmpn_invert_limb. I am guessing for division (division and GCD are the most complicated thing I do) the code is calculating the inverse of the leading limb of the divisor?
> I use GMP in windows under vcpkg. I am wondering if people have experience with this.
> How can I check how GMP is configured (AVX2 etc, my main machine is a dual EPYC 7713 but I do have an AVX512 machine as well as a Broadwell)? I assume there is some output header file or something.
> I see that the divide code is not using say tzcnt type intrinsics for count_leading_zeros. I also see that we are generating security cookie code which is a waste for my application. I don't have much clue how this code is getting built at this point.


we do not maintain the VCPKG package. You can look at how the package is 
built here: . On 
windows, it looks like they use this fork: plus some minor patches. You are 
more likely to get details about those packages by asking them.

On a unix-like system (including mingw64 for windows), GMP's configure can 
detect the build system (epyc, broadwell, etc) and compile specifically 
for this system. Or you can use --enable-fat to get some runtime detection 
of the system (more portable but a bit less efficient). I don't know what 
they did for vcpkg. You could try building GMP from source with mingw64.

Marc Glisse

More information about the gmp-discuss mailing list