Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows support #281

Closed
tcojean opened this issue Mar 27, 2019 · 4 comments
Closed

Windows support #281

tcojean opened this issue Mar 27, 2019 · 4 comments
Labels
is:bug Something looks wrong. plat:windows This is related to the Windows Operating system reg:build This is related to the build system.
Milestone

Comments

@tcojean
Copy link
Member

tcojean commented Mar 27, 2019

Visual Studio related problems

A potential issue are the compiler differences between Visual Studio and G++/Clang. It is possible that Ginkgo requires some bug fixes for proper Visual Studio support.

Shared library building

A known issue is that build fails on Windows due to missing shared libraries.

Seems that this stackoverflow question is related: https://stackoverflow.com/questions/33062728/cmake-link-shared-library-on-windows

It seems there is this generate_export_header command in CMake, which has to be done for every shared library we create, and the source code should be modified accordingly: https://cmake.org/cmake/help/v3.9/module/GenerateExportHeader.html

Some resources related to this:

@tcojean tcojean added is:bug Something looks wrong. reg:build This is related to the build system. labels Mar 27, 2019
@pratikvn pratikvn added the plat:windows This is related to the Windows Operating system label Sep 10, 2019
@yhmtsai
Copy link
Member

yhmtsai commented Sep 10, 2019

Windows has the following options to compile C++ program.

  1. Windows Subsystem for Linux (WSL)
    -- The compilation is not different from ubuntu.
    -- WSL 2 may support GPU access in the future. (But they set GPU access as the highest priority about two years ago)
  2. MinGW
    It can be used by cmd or powershell. However, CUDA can not be compiled by MinGW.
  3. Cygwin
    it depends on the installation of gcc.
  4. Visual Studio
    -- The only one supports CUDA compilation in Windows.

I tried to see how to compile ginkgo static library in Visual Studio without CUDA.
I record the problem and how I solve it.

  1. it can not recognize the overloaded template with enable_if correctly.
    For example,
template <typename T>
        static xstd::enable_if_t<is_complex<T>()> write_entry_impl(
            std::ostream &, const T &) {}
template <typename T>
        static xstd::enable_if_t<!is_complex<T>()> write_entry_impl(
            std::ostream &, const T &) {}

The compiler complain that the functions are redefined.
It can works with set the second template argument as template <typename T, int = 0>
The workaround solution can use this, to add one specified key.

  1. isfinite is defined without any namespace, so the possible solution is similar to clang compiler.
    I only rename it in my try.
  2. In core/test/stream the output 1234abcd -> 00001234abcd are different. the default string format might be different.
    e.g. Use ptrstream << std::hex << "0x" << reinterpret_cast<gko::uintptr>(&dummy); to ensure the same format here
  3. Compiler can not find the correct function for clone(LinOp *). The line should use x->clone() not clone(x)

After doing these fixes, Visual Studio can compile ginkgo static library without CUDA.

@tcojean tcojean mentioned this issue Oct 14, 2019
26 tasks
@tcojean tcojean added this to the v1.1.0 milestone Oct 14, 2019
@tcojean
Copy link
Member Author

tcojean commented Oct 14, 2019

I am tentatively adding this to the v1.1.0 milestone as we have pretty much everything for this (except for merging @yhmtsai #351 PR). If this still needs a lot of stabilization and is not ready, this can be removed. We should at least have partial windows support (MinGW was merged and we are hopefully still compatible).

@yhmtsai
Copy link
Member

yhmtsai commented Oct 17, 2019

For the MSVC unrecognized SFINAE, use constexpr member of struct not constexpr function.
original version:

template <typename T>
        static xstd::enable_if_t<is_complex<T>()> write_entry_impl(
            std::ostream &, const T &) {}
template <typename T>
        static xstd::enable_if_t<!is_complex<T>()> write_entry_impl(
            std::ostream &, const T &) {}

Fixed version

template <typename T>
        static xstd::enable_if_t<is_complex_s<T>::value> write_entry_impl(
            std::ostream &, const T &) {}
template <typename T>
        static xstd::enable_if_t<!is_complex_s<T>::value> write_entry_impl(
            std::ostream &, const T &) {}

For exporting shared library, set CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE to let cmake automatically export the symbols.

@tcojean
Copy link
Member Author

tcojean commented Oct 18, 2019

We now have full windows support, so I will close this although it is still a good reference to point people to.

@tcojean tcojean closed this as completed Oct 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is:bug Something looks wrong. plat:windows This is related to the Windows Operating system reg:build This is related to the build system.
Projects
None yet
Development

No branches or pull requests

3 participants