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

add windows ci setting #471

Merged
merged 12 commits into from
Mar 18, 2020
3 changes: 3 additions & 0 deletions .github/workflows/osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@ jobs:
cmake .. -DBUILD_SHARED_LIBS=${{ matrix.config.shared }} -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }}
make -j8
ctest -j10
- name: install
run: |
cd build
make install
make test_install
157 changes: 157 additions & 0 deletions .github/workflows/windows-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
name: Windows-build

on: [push]

jobs:
windows_cuda:
name: cuda102/release/shared (only compile)
runs-on: [windows-latest]
steps:
- uses: actions/checkout@v2
- name: setup
run: |
choco install cuda -y
- name: configure
run: |
$env:ChocolateyInstall = Convert-Path "$((Get-Command choco).Path)\..\.."
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
refreshenv
mkdir build
cd build
$env:PATH="$pwd\windows_shared_library;$env:PATH"
cmake -DGINKGO_BUILD_CUDA=ON -DGINKGO_BUILD_OMP=OFF ..
tcojean marked this conversation as resolved.
Show resolved Hide resolved
cmake --build . -j8 --config Release

windows_ref:
strategy:
fail-fast: false
matrix:
config:
- {shared: "ON", build_type: "Debug", name: "reference/debug/shared"}
- {shared: "OFF", build_type: "Release", name: "reference/release/static"}
# Debug static needs too much storage
# - {shared: "OFF", build_type: "Debug", name: "reference/debug/static"}
name: msvc/${{ matrix.config.name }}
runs-on: [windows-latest]
steps:
- uses: actions/checkout@v2
- name: shared_env
if: matrix.config.shared == 'ON'
run: |
echo "::set-env name=origin_path::$env:PATH"
echo "::add-path::$pwd\build\windows_shared_library"
- name: debug_env
if: matrix.config.build_type == 'Debug'
run: |
echo "::set-env name=CXXFLAGS::/bigobj"
- name: configure
run: |
mkdir build
cd build
cmake -DBUILD_SHARED_LIBS=${{ matrix.config.shared }} -DGINKGO_BUILD_CUDA=OFF -DGINKGO_BUILD_OMP=OFF ..
cmake --build . -j8 --config ${{ matrix.config.build_type }}
ctest . -C ${{ matrix.config.build_type }}
pratikvn marked this conversation as resolved.
Show resolved Hide resolved
- name: install_shared_env
if: matrix.config.shared == 'ON'
run: |
echo "::set-env name=PATH::C:\Program Files (x86)\Ginkgo\lib;$env:origin_path"
- name: install
run: |
cd build
cmake --install . --config ${{ matrix.config.build_type }}
cmake --build . --target test_install --config ${{ matrix.config.build_type }}

windows_mingw:
strategy:
fail-fast: false
matrix:
config:
- {shared: "ON", build_type: "Debug", name: "omp/debug/shared"}
- {shared: "OFF", build_type: "Release", name: "omp/release/static"}
name: mingw/${{ matrix.config.name }}
runs-on: [windows-latest]
steps:
- uses: actions/checkout@v2
- name: shared_env
if: matrix.config.shared == 'ON'
run: |
echo "::set-env name=origin_path::$env:PATH"
echo "::add-path::$pwd\build\windows_shared_library"
- name: debug_env
if: matrix.config.build_type == 'Debug'
run: |
echo "::set-env name=CXXFLAGS::-Wa,-mbig-obj"
- name: configure
# Use cmd to remove the path easily
run: |
set PATH=%PATH:C:\Program Files\Git\bin;=%
set PATH=%PATH:C:\Program Files\Git\usr\bin;=%
mkdir build
cd build
cmake -G "MinGW Makefiles" -DBUILD_SHARED_LIBS=${{ matrix.config.shared }} -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} ..
cmake --build . -j8
ctest .
shell: cmd
- name: install_shared_env
if: matrix.config.shared == 'ON'
run: |
echo "::set-env name=PATH::C:\Program Files (x86)\Ginkgo\lib;$env:origin_path"
- name: install
run: |
set PATH=%PATH:C:\Program Files\Git\bin;=%
set PATH=%PATH:C:\Program Files\Git\usr\bin;=%
cd build
cmake --install .
cmake --build . --target test_install
shell: cmd

windows_cygwin:
strategy:
fail-fast: false
matrix:
config:
- {shared: "ON", build_type: "Debug", name: "omp/debug/shared"}
- {shared: "OFF", build_type: "Release", name: "omp/release/static"}
name: cygwin/${{ matrix.config.name }}
runs-on: [windows-latest]
steps:
- run: git config --global core.autocrlf input
- uses: actions/checkout@v2
- name: setup
run: |
choco install cygwin -y
choco install cyg-get -y
cyg-get cmake make gcc-g++ git
- name: shared_static_env
run: |
echo "::set-env name=shared_ON_path::;$pwd\build\windows_shared_library"
echo "::set-env name=shared_OFF_path::"
- name: debug_env
if: matrix.config.build_type == 'Debug'
run: |
echo "::set-env name=CXXFLAGS::-Wa,-mbig-obj"
- name: configure
run: |
path C:\tools\cygwin\bin%shared_${{ matrix.config.shared }}_path%
mkdir build
cd build
bash -c "cmake -DBUILD_SHARED_LIBS=${{ matrix.config.shared }} -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} .."
bash -c "make -j8"
bash -c "make test"
shell: cmd
- name: install_shared
if: matrix.config.shared == 'ON'
run: |
path C:\tools\cygwin\bin
cd build
bash -c "make install"
bash -c "export PATH=/usr/local/lib:$PATH && make test_install"
shell: cmd
- name: install_static
if: matrix.config.shared == 'OFF'
run: |
path C:\tools\cygwin\bin
cd build
bash -c "make install"
bash -c "make test_install"
shell: cmd
33 changes: 24 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
endif()

if (BUILD_SHARED_LIBS)
if(BUILD_SHARED_LIBS)
set(GINKGO_STATIC_OR_SHARED SHARED)
else()
set(GINKGO_STATIC_OR_SHARED STATIC)
Expand All @@ -99,11 +99,11 @@ if(GINKGO_BUILD_TESTS)
include(CTest)
endif()

if (GINKGO_WITH_CLANG_TIDY)
if(GINKGO_WITH_CLANG_TIDY)
find_program(GINKGO_CLANG_TIDY_PATH clang-tidy)
endif()

if (GINKGO_WITH_IWYU)
if(GINKGO_WITH_IWYU)
find_program(GINKGO_IWYU_PATH iwyu)
endif()

Expand All @@ -117,14 +117,14 @@ check_include_file_cxx(cxxabi.h GKO_HAVE_CXXABI_H)
# Automatically find PAPI and search for the required 'sde' component
set(GINKGO_HAVE_PAPI_SDE 0)
find_package(PAPI OPTIONAL_COMPONENTS sde)
if (PAPI_sde_FOUND)
if(PAPI_sde_FOUND)
set(GINKGO_HAVE_PAPI_SDE 1)
endif()

set(GINKGO_HIP_PLATFORM_NVCC 0)
set(GINKGO_HIP_PLATFORM_HCC 0)

if (GINKGO_BUILD_HIP)
if(GINKGO_BUILD_HIP)
# GINKGO_HIPCONFIG_PATH and HIP_PATH are set in cmake/hip_path.cmake
if(GINKGO_HIPCONFIG_PATH)
execute_process(COMMAND ${GINKGO_HIPCONFIG_PATH} --platform OUTPUT_VARIABLE GINKGO_HIP_PLATFORM)
Expand All @@ -150,6 +150,7 @@ configure_file(${Ginkgo_SOURCE_DIR}/include/ginkgo/config.hpp.in
include(cmake/build_helpers.cmake)
include(cmake/hip_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)
Expand Down Expand Up @@ -229,18 +230,32 @@ endif()
configure_file(${Ginkgo_SOURCE_DIR}/cmake/ginkgo.pc.in
${Ginkgo_BINARY_DIR}/ginkgo.pc @ONLY)

# WINDOWS NVCC has " inside the string, add escape charater to avoid config problem.
ginkgo_modify_flags(CMAKE_CUDA_FLAGS)
ginkgo_modify_flags(CMAKE_CUDA_FLAGS_DEBUG)
ginkgo_modify_flags(CMAKE_CUDA_FLAGS_RELEASE)
ginkgo_install()

set(GINKGO_TEST_INSTALL_COMMAND "${Ginkgo_BINARY_DIR}/test_install/test_install")
if (GINKGO_BUILD_CUDA)
set(GINKGO_TEST_INSTALL_COMMAND "${GINKGO_TEST_INSTALL_COMMAND}" && "${Ginkgo_BINARY_DIR}/test_install/test_install_cuda")
if(MSVC)
# Set path/command with $<CONFIG>
set(GINKGO_TEST_INSTALL_COMMAND "${Ginkgo_BINARY_DIR}/test_install/$<CONFIG>/test_install")
if(GINKGO_BUILD_CUDA)
set(GINKGO_TEST_INSTALL_COMMAND "${GINKGO_TEST_INSTALL_COMMAND}" "${Ginkgo_BINARY_DIR}/test_install/$<CONFIG>/test_install_cuda")
endif()
else()
set(GINKGO_TEST_INSTALL_COMMAND "${Ginkgo_BINARY_DIR}/test_install/test_install")
if(GINKGO_BUILD_CUDA)
set(GINKGO_TEST_INSTALL_COMMAND "${GINKGO_TEST_INSTALL_COMMAND}" "${Ginkgo_BINARY_DIR}/test_install/test_install_cuda")
endif()
endif()
add_custom_target(test_install
COMMAND ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} -H${Ginkgo_SOURCE_DIR}/test_install
-B${Ginkgo_BINARY_DIR}/test_install
-DCMAKE_PREFIX_PATH=${CMAKE_INSTALL_PREFIX}/${GINKGO_INSTALL_CONFIG_DIR}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
COMMAND ${CMAKE_COMMAND} --build ${Ginkgo_BINARY_DIR}/test_install
# `--config cfg` is ignored by single-configuration generator.
# `$<CONFIG>` is always be the same as `CMAKE_BUILD_TYPE` in single-configuration generator.
COMMAND ${CMAKE_COMMAND} --build ${Ginkgo_BINARY_DIR}/test_install --config $<CONFIG>
COMMAND ${GINKGO_TEST_INSTALL_COMMAND}
COMMENT "Running a test on the installed binaries. This requires running `(sudo) make install` first.")

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

[![Build status](https://gitlab.com/ginkgo-project/ginkgo-public-ci/badges/develop/pipeline.svg)](https://github.com/ginkgo-project/ginkgo/commits/develop)
[![OSX-build](https://github.com/ginkgo-project/ginkgo/workflows/OSX-build/badge.svg)](https://github.com/ginkgo-project/ginkgo/actions?query=workflow%3AOSX-build)
[![Windows-build](https://github.com/ginkgo-project/ginkgo/workflows/windows-build/badge.svg)](https://github.com/ginkgo-project/ginkgo/actions?query=workflow%3AWindows-build)
[![codecov](https://codecov.io/gh/ginkgo-project/ginkgo/branch/develop/graph/badge.svg)](https://codecov.io/gh/ginkgo-project/ginkgo)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=ginkgo-project_ginkgo&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=ginkgo-project_ginkgo)
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=ginkgo-project_ginkgo&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=ginkgo-project_ginkgo)

[![CDash dashboard](https://img.shields.io/badge/CDash-Access-blue.svg)](http://my.cdash.org/index.php?project=Ginkgo+Project)
[![Documentation](https://img.shields.io/badge/Documentation-latest-blue.svg)](https://ginkgo-project.github.io/ginkgo/doc/develop/)
[![License](https://img.shields.io/github/license/ginkgo-project/ginkgo.svg)](./LICENSE)
Expand Down
7 changes: 4 additions & 3 deletions cmake/GinkgoConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ set(GINKGO_CUSPARSE_LIBRARIES @CUSPARSE@)
set(GINKGO_CUDA_LIBRARIES @CUDA_RUNTIME_LIBS@)
set(GINKGO_CUDA_TOOLKIT_INCLUDE_DIRECTORIES "@CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES@")

set(GINKGO_CUDA_FLAGS "@CMAKE_CUDA_FLAGS@")
set(GINKGO_CUDA_FLAGS_DEBUG "@CMAKE_CUDA_FLAGS_DEBUG@")
set(GINKGO_CUDA_FLAGS_RELEASE "@CMAKE_CUDA_FLAGS_RELEASE@")
set(GINKGO_CUDA_FLAGS "@CMAKE_CUDA_FLAGS_MODIFY@")
set(GINKGO_CUDA_FLAGS_DEBUG "@CMAKE_CUDA_FLAGS_DEBUG_MODIFY@")
set(GINKGO_CUDA_FLAGS_RELEASE "@CMAKE_CUDA_FLAGS_RELEASE_MODIFY@")

# OpenMP
set(GINKGO_OPENMP_VERSION @OpenMP_CXX_VERSION@)
Expand All @@ -130,6 +130,7 @@ set(GINKGO_OPENMP_FLAGS "@OpenMP_CXX_FLAGS@")

# Provide useful HIP helper functions
include(${CMAKE_CURRENT_LIST_DIR}/hip_helpers.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/windows_helpers.cmake)

# NOTE: we do not export benchmarks, examples, tests or devel tools
# so `third_party` libraries are currently unneeded.
Expand Down
25 changes: 4 additions & 21 deletions cmake/build_helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,8 @@ function(ginkgo_check_shared_library name)
endif()
endfunction()

function(ginkgo_switch_windows_link lang from to)
foreach(flag_var
"CMAKE_${lang}_FLAGS" "CMAKE_${lang}_FLAGS_DEBUG" "CMAKE_${lang}_FLAGS_RELEASE"
"CMAKE_${lang}_FLAGS_MINSIZEREL" "CMAKE_${lang}_FLAGS_RELWITHDEBINFO"
)
if(${flag_var} MATCHES "/${from}")
string(REGEX REPLACE "/${from}" "/${to}" ${flag_var} "${${flag_var}}")
endif(${flag_var} MATCHES "/${from}")
if(${flag_var} MATCHES "-${from}")
string(REGEX REPLACE "-${from}" "-${to}" ${flag_var} "${${flag_var}}")
endif(${flag_var} MATCHES "-${from}")
set(${flag_var} "${${flag_var}}" CACHE STRING "" FORCE)
endforeach()
endfunction()

macro(ginkgo_switch_to_windows_static lang)
ginkgo_switch_windows_link(${lang} "MD" "MT")
endmacro()

macro(ginkgo_switch_to_windows_dynamic lang)
ginkgo_switch_windows_link(${lang} "MT" "MD")
macro(ginkgo_modify_flags name)
# add escape before "
# the result var is ${name}_MODIFY
string(REPLACE "\"" "\\\"" ${name}_MODIFY "${${name}}")
endmacro()
22 changes: 17 additions & 5 deletions cmake/install_helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,23 @@ set(GINKGO_INSTALL_CONFIG_DIR "lib/cmake/Ginkgo")
set(GINKGO_INSTALL_MODULE_DIR "lib/cmake/Ginkgo/Modules")

function(ginkgo_install_library name subdir)
# install .so and .a files
install(TARGETS "${name}"
EXPORT Ginkgo
LIBRARY DESTINATION ${GINKGO_INSTALL_LIBRARY_DIR}
ARCHIVE DESTINATION ${GINKGO_INSTALL_LIBRARY_DIR}

if (WIN32 OR CYGWIN)
# dll is considered as runtime
install(TARGETS "${name}"
EXPORT Ginkgo
LIBRARY DESTINATION ${GINKGO_INSTALL_LIBRARY_DIR}
ARCHIVE DESTINATION ${GINKGO_INSTALL_LIBRARY_DIR}
RUNTIME DESTINATION ${GINKGO_INSTALL_LIBRARY_DIR}
)
else ()
# install .so and .a files
install(TARGETS "${name}"
EXPORT Ginkgo
LIBRARY DESTINATION ${GINKGO_INSTALL_LIBRARY_DIR}
ARCHIVE DESTINATION ${GINKGO_INSTALL_LIBRARY_DIR}
)
endif ()
endfunction()

function(ginkgo_install)
Expand Down Expand Up @@ -60,6 +71,7 @@ function(ginkgo_install)
"${Ginkgo_BINARY_DIR}/GinkgoConfig.cmake"
"${Ginkgo_BINARY_DIR}/GinkgoConfigVersion.cmake"
"${Ginkgo_SOURCE_DIR}/cmake/hip_helpers.cmake"
"${Ginkgo_SOURCE_DIR}/cmake/windows_helpers.cmake"
DESTINATION "${GINKGO_INSTALL_CONFIG_DIR}"
)
install(EXPORT Ginkgo
Expand Down
22 changes: 22 additions & 0 deletions cmake/windows_helpers.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function(ginkgo_switch_windows_link lang from to)
foreach(flag_var
"CMAKE_${lang}_FLAGS" "CMAKE_${lang}_FLAGS_DEBUG" "CMAKE_${lang}_FLAGS_RELEASE"
"CMAKE_${lang}_FLAGS_MINSIZEREL" "CMAKE_${lang}_FLAGS_RELWITHDEBINFO"
)
if(${flag_var} MATCHES "/${from}")
string(REGEX REPLACE "/${from}" "/${to}" ${flag_var} "${${flag_var}}")
endif(${flag_var} MATCHES "/${from}")
if(${flag_var} MATCHES "-${from}")
string(REGEX REPLACE "-${from}" "-${to}" ${flag_var} "${${flag_var}}")
endif(${flag_var} MATCHES "-${from}")
set(${flag_var} "${${flag_var}}" CACHE STRING "" FORCE)
endforeach()
endfunction()

macro(ginkgo_switch_to_windows_static lang)
ginkgo_switch_windows_link(${lang} "MD" "MT")
endmacro()

macro(ginkgo_switch_to_windows_dynamic lang)
ginkgo_switch_windows_link(${lang} "MT" "MD")
endmacro()
4 changes: 2 additions & 2 deletions omp/factorization/par_ilu_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,12 @@ void compute_l_u_factors(std::shared_ptr<const OmpExecutor> exec,

if (row > col) { // modify entry in L
auto to_write = sum / vals_u[row_ptrs_u[col + 1] - 1];
if (isfinite(to_write)) {
if (::gko::isfinite(to_write)) {
vals_l[row_l - 1] = to_write;
}
} else { // modify entry in U
auto to_write = sum;
if (isfinite(to_write)) {
if (::gko::isfinite(to_write)) {
vals_u[row_u - 1] = to_write;
}
}
Expand Down
Loading