sleef icon indicating copy to clipboard operation
sleef copied to clipboard

Installation, Configuration and Usage Under Windows

Open RoyiAvital opened this issue 7 years ago • 123 comments

Hello, I'm trying to install Sleef on Windows. My system is Windows 10 Pro 64 Bit with Visual Studio 2017 (15.5.6).

The problem is Cmake requires a file called CMakeLists.txt.
It seems this file is available in the master branch of GitHub yet it is not part of the Releases.
If one download the ZIP form GitHub Releases or SourceForge he doesn't get the CMakeLists.txt file.

What should I do? Go with Master (Which I assume isn't validated as stable releases) or is the any other way?

Thank You.

RoyiAvital avatar Feb 19 '18 12:02 RoyiAvital

Hello,

Please download the master branch in the git repository.

https://github.com/shibatch/sleef/archive/master.zip

shibatch avatar Feb 19 '18 12:02 shibatch

I downloaded and trying it.

Will cmake -G"Visual Studio 15 2017 Win64" -DBUILD_SHARED_LIBS=FALSE .. work to create Static Linked library in Windows?

By the way, any chance support Intel ICC on Windows (Better OpenMP support)?

Update I tried:

> `cmake -G"Visual Studio 15 2017 Win64" -DBUILD_SHARED_LIBS=FALSE ..`
> `cmake --build . --config Release -- /maxcpucount:1`

It yielded errors.

RoyiAvital avatar Feb 19 '18 12:02 RoyiAvital

For the static lib, I haven't tested. I will test it tomorrow. I don't have a license for using ICC on Windows.

shibatch avatar Feb 19 '18 12:02 shibatch

Is there a way to use GCC on Windows to generate Static Libraries on Windows?

Hopefully you will catch the issues preventing "Static Libraries" on Windows + MSVC.

Thank You.

RoyiAvital avatar Feb 19 '18 12:02 RoyiAvital

GCC on windows does not support the ABI for AVX. At this time, the only way is to use MSVC.

shibatch avatar Feb 19 '18 13:02 shibatch

Will it hit performance or the code is low level to be compiler insensitive?

By the way, ICC is free for Students and Academic use. So you may be able to get it as well.

RoyiAvital avatar Feb 19 '18 13:02 RoyiAvital

I didn't check the performance on windows. I only confirmed that it works correctly.

The licesnse for open source contributors only includes linux versions. The educator license requires icc to be installed in a classroom. My understanding is that there is no free license for windows icc.

shibatch avatar Feb 19 '18 13:02 shibatch

Have a look at Student - https://software.intel.com/en-us/qualify-for-free-software/student. It gives you license to any version.

Once you try the Static Build let me know and I will try it on my system.

Thank You.

RoyiAvital avatar Feb 19 '18 13:02 RoyiAvital

I am not a student anymore. :)

shibatch avatar Feb 19 '18 13:02 shibatch

Once you try the Static Build let me know and I will try it on my system.

@RoyiAvital , thanks for your interest in SLEEF! May I encourage you in submitting a patch that does exactly what you want?

fpetrogalli avatar Feb 19 '18 14:02 fpetrogalli

@fpetrogalli-arm , I wish I had the knowledge to get even close to understand what you do.
I can barely understand what exactly I need :-).

It seems like a great library. Hopefully once you have the Static Lib ready I will be able to try it on. Checking it and trying to report bugs, edge cases, etc... is something I can do and will do.

By the way, as a feature request, could you also add pre compiled LIB's (Windows, macOS, Linux) to the Releases on GitHub?

Thank You.

RoyiAvital avatar Feb 19 '18 14:02 RoyiAvital

@RoyiAvital Nobody is born with knowledge! I am sure you can handle this, you just need to give it a go. What kind of errors do you see when you run that command line?

cmake -G"Visual Studio 15 2017 Win64" -DBUILD_SHARED_LIBS=FALSE .. cmake --build . --config Release -- /maxcpucount:1

Can you past them here? I would try it myself but I don't have a windows/msvc machine.

fpetrogalli avatar Feb 19 '18 14:02 fpetrogalli

The problem with providing precompiled libs for windows is that it depends on the version of MSVC. I need to install every version of MSVC to build the libraries of all versions. I believe building the library yourself is simple enough.

shibatch avatar Feb 19 '18 14:02 shibatch

Hi, The erros were like that:

iutsimd.obj : error LNK2019: unresolved external symbol __imp_Sleef_x86CpuID referenced in function check_featureDP [<PathToSleef>\Sleef\sleef-master\build\src\libm-tester\iutsse4.vcxproj]
  iutsimd.obj : error LNK2019: unresolved external symbol __imp_Sleef_sind2_u35sse4 referenced in function do_test [<PathToSleef>\Sleef\sleef-master\build\src\libm-tester\iutsse4.vcxproj]
  iutsimd.obj : error LNK2019: unresolved external symbol __imp_Sleef_cosd2_u35sse4 referenced in function do_test [<PathToSleef>\Sleef\sleef-master\build\src\libm-tester\iutsse4.vcxproj]
  iutsimd.obj : error LNK2019: unresolved external symbol __imp_Sleef_sincosd2_u35sse4 referenced in function do_test [<PathToSleef>\Sleef\sleef-master\build\src\libm-tester\iutsse4.vcxproj]
  iutsimd.obj : error LNK2019: unresolved external symbol __imp_Sleef_tand2_u35sse4 referenced in function do_test [<PathToSleef>\Sleef\sleef-master\build\src\libm-tester\iutsse4.vcxproj]
  iutsimd.obj : error LNK2019: unresolved external symbol __imp_Sleef_asind2_u35sse4 referenced in function do_test [<PathToSleef>\Sleef\sleef-master\build\src\libm-tester\iutsse4.vcxproj]
  iutsimd.obj : error LNK2019: unresolved external symbol __imp_Sleef_acosd2_u35sse4 referenced in function do_test [<PathToSleef>\Sleef\sleef-master\build\src\libm-tester\iutsse4.vcxproj]
  iutsimd.obj : error LNK2019: unresolved external symbol __imp_Sleef_atand2_u35sse4 referenced in function do_test [<PathToSleef>\Sleef\sleef-master\build\src\libm-tester\iutsse4.vcxproj]
  iutsimd.obj : error LNK2019: unresolved external symbol __imp_Sleef_atan2d2_u35sse4 referenced in function do_test [<PathToSleef>\Sleef\sleef-master\build\src\libm-tester\iutsse4.vcxproj]
  iutsimd.obj : error LNK2019: unresolved external symbol __imp_Sleef_logd2_u35sse4 referenced in function do_test [<PathToSleef>\Sleef\sleef-master\build\src\libm-tester\iutsse4.vcxproj]
  iutsimd.obj : error LNK2019: unresolved external symbol __imp_Sleef_cbrtd2_u35sse4 referenced in function do_test [<PathToSleef>\Sleef\sleef-master\build\src\libm-tester\iutsse4.vcxproj]
  iutsimd.obj : error LNK2019: unresolved external symbol __imp_Sleef_sind2_u10sse4 referenced in function do_test [<PathToSleef>\Sleef\sleef-master\build\src\libm-tester\iutsse4.vcxproj]
  iutsimd.obj : error LNK2019: unresolved external symbol __imp_Sleef_cosd2_u10sse4 referenced in function do_test [<PathToSleef>\Sleef\sleef-master\build\src\libm-tester\iutsse4.vcxproj]
  iutsimd.obj : error LNK2019: unresolved external symbol __imp_Sleef_sincosd2_u10sse4 referenced in function do_test [<PathToSleef>\Sleef\sleef-master\build\src\libm-tester\iutsse4.vcxproj]
  iutsimd.obj : error LNK2019: unresolved external symbol __imp_Sleef_tand2_u10sse4 referenced in function do_test [<PathToSleef>\Sleef\sleef-master\build\src\libm-tester\iutsse4.vcxproj]
  iutsimd.obj : error LNK2019: unresolved external symbol __imp_Sleef_asind2_u10sse4 referenced in function do_test [<PathToSleef>\Sleef\sleef-master\build\src\libm-tester\iutsse4.vcxproj]
  iutsimd.obj : error LNK2019: unresolved external symbol __imp_Sleef_acosd2_u10sse4 referenced in function do_test [<PathToSleef>\Sleef\sleef-master\build\src\libm-tester\iutsse4.vcxproj]
  iutsimd.obj : error LNK2019: unresolved external symbol __imp_Sleef_atand2_u10sse4 referenced in function do_test [<PathToSleef>\Sleef\sleef-master\build\src\libm-tester\iutsse4.vcxproj]
  iutsimd.obj : error LNK2019: unresolved external symbol __imp_Sleef_atan2d2_u10sse4 referenced in function do_test [<PathToSleef>\Sleef\sleef-master\build\src\libm-tester\iutsse4.vcxproj]
  iutsimd.obj : error LNK2019: unresolved external symbol __imp_Sleef_logd2_u10sse4 referenced in function do_test [<PathToSleef>\Sleef\sleef-master\build\src\libm-tester\iutsse4.vcxproj]
  iutsimd.obj : error LNK2019: unresolved external symbol __imp_Sleef_cbrtd2_u10sse4 referenced in function do_test [<PathToSleef>\Sleef\sleef-master\build\src\libm-tester\iutsse4.vcxproj]
  iutsimd.obj : error LNK2019: unresolved external symbol __imp_Sleef_expd2_u10sse4 referenced in function do_test [<PathToSleef>\Sleef\sleef-master\build\src\libm-tester\iutsse4.vcxproj]

But like hundreds of them and for most of the sub compilation tasks (I'm not sure I know what happens there, it seems to compile many sub projects).

Regarding pre built version, since MSVC us now free in the community edition, no reason to support anything but the latest. It will make the entrance fees to use this project much lower. I'd do that for macOS and Linux as well.

RoyiAvital avatar Feb 19 '18 14:02 RoyiAvital

That's because you are trying to build static libs on windows. It seems that I need some modification to make it possible.

shibatch avatar Feb 19 '18 15:02 shibatch

@shibatch, concerning windows doesn't support AVX ABI on windows: There is indeed a problem with gcc on x64 (64bit) but not on 32bit (AFAIK):

[Mingw-w64-public] AVX support is broken in 64-bit mode! Will there ever be a fix? ...quote... Hello, first thanks for interesting in this subject, but sadly I have disappoint you about it, I fear. The cause for the inability to align to 32-byte alignment is neither to seek in gcc, nor in mingw-w64 itself. It is a consequence of the SEH-information required by the x64 ABI (see here as reference either msdn, or ibm's IA64 exception-specification).

As a consequence SIMD instructions requiring explicitly 32-byte aligned memory won't work and have to be replaced be (slower) instructions not requiring explicit alignment. The questions: is sleef affected by this at all?

carlkl avatar Feb 19 '18 20:02 carlkl

Hello @carlkl,

32-bit x86 support is kind of supplemental, and not fully tested on any of operating systems. It should work, but performance would be worse than the 64-bit library due to a smaller number of available registers.

64-bit AVX support is known to be broken.

shibatch avatar Feb 20 '18 04:02 shibatch

@RoyiAvital Building static libs with MSVC should be possible with the following code.

https://github.com/shibatch/sleef/archive/Enable_building_static_libs_on_MSVC.zip

shibatch avatar Feb 20 '18 07:02 shibatch

I have merged the static build on Windows in master (https://github.com/shibatch/sleef/commit/064e002916cbdfca04751b1f875b340b40e3dbe4). @shibatch , thank you for working on this.

@RoyiAvital , does this solve your problems when building on Windows?

fpetrogalli avatar Feb 20 '18 09:02 fpetrogalli

@fpetrogalli-arm , I finished running the script which went well. When linking the library, should I link all .lib files or only one of them?

RoyiAvital avatar Feb 20 '18 10:02 RoyiAvital

When linking the library, should I link all .lib files or only one of them?

You should link the library that you want to use. Which functions are invoking in your code? I have no experience on MSVC, but I suspect that you will have to tell the compiler and the library loader the place where you have installed the library.

For example, on linux if you invoke the following in your code on x86:

#include <sleef.h>

// ...
__m128 In = // some computation
__m128 Out = Sleef_expf4_u10(In);
// ...

You will have to invoke the compiler with a -lsleef command line flag to make sure that your code is linked against libsleef.so. The library file should be located in a directory listed in the environment variable LD_LIBRARY_PATH. I think MSVC have a similar mechanism.

fpetrogalli avatar Feb 20 '18 10:02 fpetrogalli

As you can see there are many libraries:

My question is, should I link all, or just sleef.lib.

Linking mechanism in MSVC is just like GCC.

RoyiAvital avatar Feb 20 '18 11:02 RoyiAvital

I see. The libraries are:

  • sleef.lib, for the math library (scalar and vector).
  • sleefdft.lib for the DFT library.

fpetrogalli avatar Feb 20 '18 11:02 fpetrogalli

OK, I managed to make all functions available.

Feature Request / Suggestion You expose functions only if __SSE__ / __AVX__ etc are defined. Those are flags usually used by the Compilers out there. Yet it has issues if I write code using intrinsic on my own (Namely I don't ask compiler for optimization) and want to generate code.

Hence I'd suggest the following:

#ifdef __SSE2__ -> #if defined __SSE2__ || __SLEEF_SSE_2 || _SLEEF_SIMD_FUNCTIONS

Now, the user has choice either use Compiler __SSE2__ which might have other effects or being specific with Sleef.
The __SLEEF_SIMD_FUNCTIONS__ will be the joker, namely will expose all functions for the user.

RoyiAvital avatar Feb 20 '18 11:02 RoyiAvital

@RoyiAvital It does not make sense to expose, for example, avx functions when AVX is not defined. If AVX is not defined, that means that the ABI for calling the AVX functions is not available.

shibatch avatar Feb 20 '18 12:02 shibatch

@shibatch , Well I don't want the compiler to Optimize to AVX (Namely the code won't run on Non AVX system). Yet I want it to generate AVX code. Hence I just include the AVX intrinsics, use AVX intrinsics, compile and it works perfectly. Now I can't do it with Sleef.

Anyhow, on windows I get Error LNK2001 unresolved external symbol __imp_Sleef_expf4_u10sse4. Could it be the library isn't "Behaving well". As other libraries in the project works perfectly.

RoyiAvital avatar Feb 20 '18 12:02 RoyiAvital

That's because MSVC does not automatically define AVX macro. Please manually define it when you use those functions. If you want to use a static lib, you also need to define SLEEF_STATIC_LIBS.

shibatch avatar Feb 20 '18 12:02 shibatch

I defined SLEEF_STATIC_LIBS and then got:

Error	LNK2001	unresolved external symbol Sleef_x86CpuID

RoyiAvital avatar Feb 20 '18 12:02 RoyiAvital

I'll check this tomorrow.

shibatch avatar Feb 20 '18 12:02 shibatch

@RoyiAvital How did you get that error? What source code are you trying to compile?

shibatch avatar Feb 20 '18 13:02 shibatch