mpir icon indicating copy to clipboard operation
mpir copied to clipboard

When building Skylake AVX Lib or dll get build error

Open zakelwe opened this issue 6 years ago • 7 comments

Hello, firstly MPIR is great. I have it working fine for the mpir_gc and my program using it works fine. I compiled it as the recommended way after installing YASM etc and no issues. However I always had an issue with Skylake AVX being built on VS17, the solution is noted here and kindly raised with Microsoft by Brian and a solution found ==> https://github.com/wbhart/mpir/issues/229

So I went through the steps listed,downloading the master mpir zip again, used python config to give me the skylake option(s) and it appeared in the VS17 mpir.sln. I selected for build the skylake lib or dll option and I get

1>------ Build started: Project: lib_mpir_skylake_avx, Configuration: Release x64 ------ 1>building MPIR for skylake\avx (x64) from directory mpn\x86_64w\skylake\avx 1>creating mpir.h for x64 1>creating config.h from vs17\cdata\mpn\x86_64w\skylake\avx\

1>Assembling add_err1_n.asm ==> x64\Release\add_err1_n.obj 1>C:\mpir\msvc\vsyasm.targets(81,5): error MSB3721: The command ""C:\Program Files\yasm"vsyasm.exe -Xvc -f x64 -g cv8 -i "......\mpn\x86_64w\" -o "x64\Release\mpn\add_err1_n.obj" -rnasm -pnasm ......\mpn\x86_64w\skylake\avx\add_err1_n.asm" exited with code 1.****

1>Done building project "lib_mpir_skylake_avx.vcxproj" -- FAILED. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I have YASM in the default directory, and I assume from January it is the latest version. it works well for the mpir_gc I used before, and I am not sure where I am going wrong.

As an aside, if Skylake is only 1 or 2 % quicker than the generic code that currently works, then perhaps not to worry about this, it would be nice to have a speedup though "for free".

Apologies if this is user error or RTFM. This is the first programming I have done since the mid 90's using Borland Turbo C, so a bit rusty !

Many thanks for any tips.

Andy

zakelwe avatar Feb 25 '19 16:02 zakelwe

I am also having problems integrating VSYASM with MPIR. I have two computers with Windows 10 Professional, one using VS2015CE and the other using VS2017CE. I am using MPIR 3.0.0 on both computers and I started by following section 2.4 of its documentation to build the dll_mpir_gc project. This went very smoothly and the program linked to the library and ran well on both machines.

My VS2017CE machine has a sandy bridge processor and my VS2015CE machine has a skylake AVX processor, so I am naturally interested in building assembler optimised libraries for them. On the VS2017CE machine I got the error described in Issue #229. whichever assembler optimised project I tried to build and I haven't been able to resolve this. On the VS2015CE machine I managed to build the dll_mpir_core2 project and my program linked to the library and ran without any problems, but when I tried to build the dll_mpir_skylake_avx project I got almost identical error messages.

I would really like to know which versions of MPIR and VSYASM are fully compatible with each other and where I can download them.

puzzleking2000 avatar Mar 06 '19 13:03 puzzleking2000

Hello Puzzleking2000,

Thanks for advising you also got a similar issue, so it is not just me. While I wait a reply could you advise what percentage gain you got on the core2 compared to generic MPIR? Of course this depends on you project, but it would be nice to know the benefits of these bespoke files.

Many thanks

Andy

zakelwe avatar Mar 09 '19 10:03 zakelwe

Andy,

I found that the core2 library ran at the same speed as the generic C library. This didn't surprise me very much because the core2 instruction set is very much a subset of the skylake AVX instruction set and the Visual C++ compiler generates very efficient code.

My application would benefit greatly from the vector instructions in AVX so I'm keen to find out how to build this library for MPIR.

Regards

Pete

zakelwe wrote:

Hello Puzzleking2000,

Thanks for advising you also got a similar issue, so it is not just me. While I wait a reply could you advise what percentage gain you got on the core2 compared to generic MPIR? Of course this depends on you project, but it would be nice to know the benefits of these bespoke files.

Many thanks

Andy

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/wbhart/mpir/issues/268#issuecomment-471163664, or mute the thread https://github.com/notifications/unsubscribe-auth/AuDAJljtmz1YqeeTHdgrKaSPv_P0OylGks5vU4b9gaJpZM4bQNmB.

puzzleking2000 avatar Mar 09 '19 15:03 puzzleking2000

Hello Pete

Thanks for replying, that is good to know. I guess we both sit tight now and await a reply from the guru.

Have a very nice weekend

Andy


From: puzzleking2000 [mailto:[email protected]] Sent: 09 March 2019 15:36 To: wbhart/mpir Cc: zakelwe; Author Subject: Re: [wbhart/mpir] When building Skylake AVX Lib or dll get build error (#268)

Andy,

I found that the core2 library ran at the same speed as the generic C library. This didn't surprise me very much because the core2 instruction set is very much a subset of the skylake AVX instruction set and the Visual C++ compiler generates very efficient code.

My application would benefit greatly from the vector instructions in AVX so I'm keen to find out how to build this library for MPIR.

Regards

Pete

zakelwe wrote:

Hello Puzzleking2000,

Thanks for advising you also got a similar issue, so it is not just me. While I wait a reply could you advise what percentage gain you got on the core2 compared to generic MPIR? Of course this depends on you project, but it would be nice to know the benefits of these bespoke files.

Many thanks

Andy

You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/wbhart/mpir/issues/268#issuecomment-471163664, or mute the thread

<https://github.com/notifications/unsubscribe-auth/AuDAJljtmz1YqeeTHdgrKaSPv _P0OylGks5vU4b9gaJpZM4bQNmB>.

You are receiving this because you authored the thread. Reply to this email directly, view it https://github.com/wbhart/mpir/issues/268#issuecomment-471190476 on GitHub, or mute <https://github.com/notifications/unsubscribe-auth/AtTzUrYQJI_JH3fv358fJTyu7 8M-WsoTks5vU9T8gaJpZM4bQNmB> the thread. <https://github.com/notifications/beacon/AtTzUgT0t3LqlcYLQsjEzjLlU-IuC0lUks5 vU9T8gaJpZM4bQNmB.gif>

zakelwe avatar Mar 09 '19 16:03 zakelwe

@zakelwe and @puzzleking2000 - a little while back I also had some issues building with the latest Visual Studio, and found Brian had fixes ready but that hadn't been cleanly merged to trunk (the wbhart repo). I merged those build changes here, and I've had no problems since. Perhaps it will work for you: https://github.com/KevinHake/mpir

As for the speedups you will see with different optimizations, it will vary a lot. For my latest project, the optimized version was 3x - 4x faster than gc! Also interesting to note, is that across several modern cpus (Ryzen, Skylake, Coffee Lake), for my particular case the /Haswell/ AVX build performed better than the Skylake AVX build (about ~3% difference). I haven't investigated it, I just use the older optimizations.

KevinHake avatar Mar 16 '19 15:03 KevinHake

Thanks for the suggestion but it doesn't work for me. I tried it on my VS2017CE environment and built the dll_mpir_gc project successfully but I couldn't build assembler libraries. I ran the mpir_config.py script and selected the sandy bridge option but when I tried to build the dll_mpir_sandybridge project I saw the .asm and .c files being compiled but the link failed with LNK1104 cannot open file 'x64\Release\mpn\add_err1_n.obj'.

KevinHake wrote:

@zakelwe https://github.com/zakelwe and @puzzleking2000 https://github.com/puzzleking2000 - a little while back I also had some issues building with the latest Visual Studio, and found Brian had fixes ready but that hadn't been cleanly merged to trunk (the wbhart repo). I merged those build changes here, and I've had no problems since. Perhaps it will work for you: https://github.com/KevinHake/mpir

As for the speedups you will see with different optimizations, it will vary a lot. For my latest project, the optimized version was 3x - 4x faster than gc! Also interesting to note, is that across several modern cpus (Ryzen, Skylake, Coffee Lake), for my particular case the /Haswell/ AVX build performed better than the Skylake AVX build (about ~3% difference). I haven't investigated it, I just use the older optimizations.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wbhart/mpir/issues/268#issuecomment-473547346, or mute the thread https://github.com/notifications/unsubscribe-auth/AuDAJjBBKFwUVxhve4Bc-M7vZ7Q7tsBBks5vXQ6pgaJpZM4bQNmB.

puzzleking2000 avatar Mar 18 '19 12:03 puzzleking2000

Make sure you install the Microsoft Visual C++ 2010 Redistributable Package. vsyasm won't run without it, and being so old, most folks don't have it installed.

wjblanke avatar Jun 13 '20 05:06 wjblanke