Skip to content

Commit

Permalink
descr switch static/shared, hwloc off on win/mac, mv third_party buil…
Browse files Browse the repository at this point in the history
…d, restore MSVC static build

- Add description of possible issue when switiching static/shared with MSVC in INSTALL.md
- HWLOC is default OFF on win/mac and force set off when turning on
- move the third party build after flag configuration
  • Loading branch information
yhmtsai committed Apr 14, 2021
1 parent 279cb0e commit acf9d6d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/windows-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
$env:PATH="$env:PATH;$pwd\build\windows_shared_library"
mkdir build
cd build
cmake -DCMAKE_CXX_FLAGS=/bigobj -DCMAKE_CXX_FLAGS_DEBUG="/MDd /Zi /Ob1 /Od /RTC1" -DGINKGO_BUILD_CUDA=OFF -DGINKGO_BUILD_OMP=OFF ..
cmake -DCMAKE_CXX_FLAGS=/bigobj -DBUILD_SHARED_LIBS=${{ matrix.config.shared }} -DCMAKE_CXX_FLAGS_DEBUG="/MDd /Zi /Ob1 /Od /RTC1" -DGINKGO_BUILD_CUDA=OFF -DGINKGO_BUILD_OMP=OFF ..
cmake --build . -j4 --config ${{ matrix.config.build_type }}
ctest . -C ${{ matrix.config.build_type }} --output-on-failure
- name: install
Expand Down
46 changes: 26 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ set(GINKGO_HIP_AMDGPU "" CACHE STRING
"The amdgpu_target(s) variable passed to hipcc. The default is none (auto).")
option(GINKGO_JACOBI_FULL_OPTIMIZATIONS "Use all the optimizations for the CUDA Jacobi algorithm" OFF)
option(BUILD_SHARED_LIBS "Build shared (.so, .dylib, .dll) libraries" ON)
option(GINKGO_BUILD_HWLOC "Build Ginkgo with HWLOC. Default is ON. If a system HWLOC is not found, then we try to build it ourselves. Switch this OFF to disable HWLOC." ON)
if(MSVC OR WIN32 OR CYGWIN OR APPLE)
option(GINKGO_BUILD_HWLOC "Build Ginkgo with HWLOC. Default is OFF. Ginkgo does not support HWLOC on Windows/MacOS" OFF)
else()
option(GINKGO_BUILD_HWLOC "Build Ginkgo with HWLOC. Default is ON. If a system HWLOC is not found, then we try to build it ourselves. Switch this OFF to disable HWLOC." ON)
endif()
option(GINKGO_INSTALL_RPATH "Set the RPATH when installing its libraries." ON)
option(GINKGO_INSTALL_RPATH_ORIGIN "Add $ORIGIN (Linux) or @loader_path (MacOS) to the installation RPATH." ON)
option(GINKGO_INSTALL_RPATH_DEPENDENCIES "Add dependencies to the installation RPATH." OFF)
Expand Down Expand Up @@ -169,6 +173,11 @@ if(PAPI_sde_FOUND)
set(GINKGO_HAVE_PAPI_SDE 1)
endif()

# Switch off HWLOC for Windows and MacOS
if(GINKGO_BUILD_HWLOC AND (MSVC OR WIN32 OR CYGWIN OR APPLE))
set(GINKGO_BUILD_HWLOC OFF CACHE BOOL "Build Ginkgo with HWLOC. Default is OFF. Ginkgo does not support HWLOC on Windows/MacOS" FORCE)
message(WARNING "Ginkgo does not support HWLOC on Windows/MacOS, switch GINKGO_BUILD_HWLOC to OFF")
endif()
if(GINKGO_BUILD_HWLOC)
# By default always use external HWLOC
set(GINKGO_USE_EXTERNAL_HWLOC 1)
Expand All @@ -178,10 +187,6 @@ else()
set(GINKGO_HAVE_HWLOC 0)
message(STATUS "HWLOC is being forcibly switched off")
endif()
# Switch off HWLOC for Windows and MacOS
if(MSVC OR WIN32 OR CYGWIN OR APPLE)
set(GINKGO_HAVE_HWLOC 0)
endif()

# We keep using NVCC/HCC for consistency with previous releases even if AMD
# updated everything to use NVIDIA/AMD in ROCM 4.1
Expand Down Expand Up @@ -211,6 +216,21 @@ if(GINKGO_BUILD_HIP)
endif()


if(MSVC)
# This is modified from
# https://gitlab.kitware.com/cmake/community/wikis/FAQ#dynamic-replace
include(cmake/windows_helpers.cmake)
if(BUILD_SHARED_LIBS)
ginkgo_switch_to_windows_dynamic("CXX")
ginkgo_switch_to_windows_dynamic("C")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
else()
ginkgo_switch_to_windows_static("CXX")
ginkgo_switch_to_windows_static("C")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS FALSE)
endif()
endif()

# Try to find the third party packages before using our subdirectories
include(cmake/package_helpers.cmake)
ginkgo_find_package(GTest "GTest::GTest;GTest::Main" FALSE 1.8.1)
Expand All @@ -222,26 +242,12 @@ if(GINKGO_HAVE_HWLOC)
set(GINKGO_USE_EXTERNAL_HWLOC 0)
endif()
endif()
# third_party needs to be after flag modification.
add_subdirectory(third_party) # Third-party tools and libraries

# Load CMake helpers
include(cmake/build_helpers.cmake)
include(cmake/install_helpers.cmake)
include(cmake/windows_helpers.cmake)

# This is modified from
# https://gitlab.kitware.com/cmake/community/wikis/FAQ#dynamic-replace
if(MSVC)
if(BUILD_SHARED_LIBS)
ginkgo_switch_to_windows_dynamic("CXX")
ginkgo_switch_to_windows_dynamic("C")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
else()
ginkgo_switch_to_windows_static("CXX")
ginkgo_switch_to_windows_static("C")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS FALSE)
endif()
endif()

configure_file(${Ginkgo_SOURCE_DIR}/include/ginkgo/config.hpp.in
${Ginkgo_BINARY_DIR}/include/ginkgo/config.hpp @ONLY)
Expand Down
10 changes: 7 additions & 3 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ Ginkgo adds the following additional switches to control what is being built:
* `-DGINKGO_HIP_AMDGPU="gpuarch1;gpuarch2"` the amdgpu_target(s) variable
passed to hipcc for the `hcc` HIP backend. The default is none (auto).
* `-DGINKGO_BUILD_HWLOC={ON, OFF}` builds Ginkgo with HWLOC. If system HWLOC
is not found, Ginkgo will try to build it. Default is `ON`.
is not found, Ginkgo will try to build it. Default is `ON` on Linux. Ginkgo
does not support HWLOC on Windows/MacOS, so the default is `OFF` on Windows/MacOS.
* `-DGINKGO_BUILD_DOC={ON, OFF}` creates an HTML version of Ginkgo's documentation
from inline comments in the code. The default is `OFF`.
* `-DGINKGO_DOC_GENERATE_EXAMPLES={ON, OFF}` generates the documentation of examples
Expand Down Expand Up @@ -99,7 +100,7 @@ Ginkgo adds the following additional switches to control what is being built:
list of architectures. Supported values are:

* `Auto`
* `Kepler`, `Maxwell`, `Pascal`, `Volta`, `Turing` `Ampere`
* `Kepler`, `Maxwell`, `Pascal`, `Volta`, `Turing`, `Ampere`
* `CODE`, `CODE(COMPUTE)`, `(COMPUTE)`

`Auto` will automatically detect the present CUDA-enabled GPU architectures
Expand Down Expand Up @@ -175,7 +176,10 @@ Depending on the configuration settings, some manual work might be required:
2. `ld` issue (If building Ginkgo as static library, this is not needed)
* `cmake -DGINKGO_COMPILER_FLAGS="-Wpedantic -O1" <other parameters> <source_folder>` (`GINKGO_COMPILER_FLAGS` is `-Wpedantic` by default)
* add `-O1` in the environement variable `CXX_FLAGS` or `CMAKE_CXX_FLAGS`
* Build Ginkgo in _MinGW_:
* Possible issue when switching static/shared of Ginkgo with MSVC in the same build directory:\
If occurs mixing MD or MT runtime library issue when enable `GINKGO_BUILD_BENCHMARKS`, it means the third-party flags are not updated correctly.
Need to turn off `GINKGO_SKIP_DEPENDENCY_UPDATE` (`-DGINKGO_SKIP_DEPENDENCY_UPDATE=OFF`) to update the third-party flags.
* Build Ginkgo in _MinGW_:\
If encountering the issue `cc1plus.exe: out of memory allocating 65536 bytes`, please follow the workaround in
[reference](https://www.intel.com/content/www/us/en/programmable/support/support-resources/knowledge-base/embedded/2016/cc1plus-exe--out-of-memory-allocating-65536-bytes.html),
or trying to compile ginkgo again might work.
Expand Down

0 comments on commit acf9d6d

Please sign in to comment.