linux.yml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. name: Linux
  2. on: [push, pull_request]
  3. jobs:
  4. build:
  5. name: ${{matrix.os}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.gpu}}
  6. runs-on: ubuntu-latest
  7. container: ${{matrix.os}}
  8. defaults:
  9. run:
  10. shell: bash -e -o pipefail {0}
  11. env:
  12. CCACHE_DIR: ${{github.workspace}}/ccache
  13. CMAKE_GENERATOR: Ninja
  14. DEBIAN_FRONTEND: noninteractive
  15. strategy:
  16. fail-fast: true
  17. matrix:
  18. os:
  19. - ubuntu:20.04
  20. - ubuntu:22.04
  21. build_type:
  22. - Release
  23. lib:
  24. - shared
  25. - static
  26. gpu:
  27. - cuda
  28. - no-cuda
  29. steps:
  30. - uses: actions/checkout@v3
  31. - name: Setup Dependencies
  32. run: |
  33. apt-get update
  34. apt-get install -y \
  35. build-essential \
  36. ccache \
  37. cmake \
  38. libbenchmark-dev \
  39. libblas-dev \
  40. libeigen3-dev \
  41. libgflags-dev \
  42. libgoogle-glog-dev \
  43. liblapack-dev \
  44. libmetis-dev \
  45. libsuitesparse-dev \
  46. ninja-build \
  47. wget
  48. # nvidia cuda toolkit shipped with 20.04 LTS does not support stream-ordered allocations
  49. - name: Setup CUDA toolkit repositories (20.04)
  50. if: matrix.gpu == 'cuda' && matrix.os == 'ubuntu:20.04'
  51. run: |
  52. wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb
  53. dpkg -i cuda-keyring_1.0-1_all.deb
  54. # nvidia cuda toolkit + gcc combo shipped with 22.04LTS is broken
  55. # and is not able to compile code that uses thrust
  56. # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1006962
  57. - name: Setup CUDA toolkit repositories (22.04)
  58. if: matrix.gpu == 'cuda' && matrix.os == 'ubuntu:22.04'
  59. run: |
  60. wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb
  61. dpkg -i cuda-keyring_1.0-1_all.deb
  62. - name: Setup CUDA toolkit
  63. if: matrix.gpu == 'cuda'
  64. run: |
  65. apt-get update
  66. apt-get install -y cuda
  67. echo "CUDACXX=/usr/local/cuda/bin/nvcc" >> $GITHUB_ENV
  68. - name: Cache Build
  69. id: cache-build
  70. uses: actions/cache@v3
  71. with:
  72. path: ${{env.CCACHE_DIR}}
  73. key: ${{matrix.os}}-ccache-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.gpu}}-${{github.run_id}}
  74. restore-keys: ${{matrix.os}}-ccache-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.gpu}}-
  75. - name: Setup Environment
  76. if: matrix.build_type == 'Release'
  77. run: |
  78. echo 'CXXFLAGS=-flto' >> $GITHUB_ENV
  79. - name: Configure
  80. run: |
  81. cmake -S . -B build_${{matrix.build_type}} \
  82. -DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \
  83. -DUSE_CUDA=${{matrix.gpu == 'cuda'}} \
  84. -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
  85. -DCMAKE_C_COMPILER_LAUNCHER=$(which ccache) \
  86. -DCMAKE_CXX_COMPILER_LAUNCHER=$(which ccache) \
  87. -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install
  88. - name: Build
  89. run: |
  90. cmake --build build_${{matrix.build_type}} \
  91. --config ${{matrix.build_type}}
  92. - name: Test
  93. if: matrix.gpu == 'no-cuda'
  94. run: |
  95. cd build_${{matrix.build_type}}/
  96. ctest --config ${{matrix.build_type}} \
  97. --output-on-failure \
  98. -j$(nproc)
  99. - name: Install
  100. run: |
  101. cmake --build build_${{matrix.build_type}}/ \
  102. --config ${{matrix.build_type}} \
  103. --target install