pinterf / mvtools

mvtools plugin for avisynth
155 stars 17 forks source link

Building with Intel C++ in MS Visual Studio #48

Closed DTL2020 closed 6 months ago

DTL2020 commented 3 years ago

It looks some non-compatibility of provided MS visual studio projects with Intel C++ build tools. When try to switch 1 .cpp file or all project to Intel C++ build toos - the visual studio project die. It no more can open project properties nor build executable. The only way to fix is to replace project files to old ones. Same with VS2017 and VS2019.

Though it is possible to build at least some .cpp files with Visual Studio 2019 (headers ?) and Intel C++ from command line (into compatible for further building with VS2019 .lib file). PlaneofBlocks and PlaneofBlocks_avx2 tested. So it looks (most of./some/all) .cpp files are compatible with Intel C++ (and headers from VS2019) but something wrong in project config files. So Intel automated build in VS can not convert project for building with Intel C++ and damages config/project irreversibly.

I tried to make hardware-family optimized builds by Intel C++ compiler.

Current working workaround:

  1. Set properties of Intel-build .cpp files as excluded from build in MS VS project.
  2. Compile these .cpp from command line environment of Intel C++ into .obj and pack into .lib file (with lib tool).
  3. Put .lib file into linker additional dependencies in MS VS project.
  4. Start build into MS VS.

If this issue ca not be resolved fast enough - may be provide icl command-line build batch file with sources and special VS project config with excluded from build (most of) files and linker config for using externally build .lib.

My current icl build file (for Release) is:

icl /IC:\cpp\mvtools-test_new_Esa_sp2\Sources\include\ /IC:\cpp\mvtools-test_new_Esa_sp2\Sources /FAs /D__AVX2__ /tune:skylake /Qm64 /O3 /Ot /Oi /Qunroll /Qunroll-aggressive /Qalign-loops:32 -EHsc /c /MD /Z7 PlaneOfBlocks_avx2.cpp

lib /OUT:PlaneofBlocks_avx2.lib PlaneofBlocks_avx2.obj

Important options are /c for building .obj and /MD for some 'dynamic'. /Z7 for inserting program database if profiling with source view required. /FAs for output assembly files may be skipped.

DTL2020 commented 3 years ago

Some more findings - the MV_FORCEINLINE is not compatible in built .obj/.lib with VisualStudio linker. Linker error - function not found. Still hope it can be resolved with command line options to intelC++ compiler (or visual studio).

pinterf commented 3 years ago

Next week I'm gonna experiment with Intel.

DTL2020 commented 3 years ago

Yes - it will be very nice if VisualStudio MVtools project will be fully compatible with totaly automated build with IntelC++ from IDE. Currently it looks have some issues with headers or versions of intel scripts for MSBuild. Also very strange why VisualStudio project is damages to death if even try to switch to IntelC++ build tools from IDE. Though it looks MVtools for VisualStudio is manually hacked project only partly compatible - it do not lists all project files into solution explorer, do not allow to add new files in the solution (even already present and build in the solution) from IDE. May be it also causes Intel scripts to ruine project complelety when trying to switch to Intel build tools.

DTL2020 commented 3 years ago

The ltest commit works mostly OK. But there is need a way to determine which Intel .dlls need to be distributed with executable. At the build system they are exist in system path and executable work. But at the system without Intel build tools installed the executable at start throws error about 'module not found' and not display the required .dll name.

DTL2020 commented 3 years ago

It looks intelC++ build require distribution of libmmd.dll and svml_dispmd.dll.

Also the multi-file IPO build looks fastest so it is good to enable /Qipo in the intel c++ build project. It may not always build OK - sometime throw ipo error about asm .obj files but rebuild with single file IPO or simply another rebuild looks like fixes it issue.

DTL2020 commented 2 years ago

The Multi-file IPO typically fails with default settings from repository (Visual Studio 2019 + Intel Compiler 19.1). Looks like solution - enable optimizations for exact microarchitecture (CoffeLake or other). Or enable AVX2 instructions set. Need to find the exact combination that fixes Multi-file IPO build in the future.

pinterf commented 6 months ago

Updated to Intel 2024.1