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

Refactor CMake logic for the CUDA compiler #3582

Merged
merged 31 commits into from
Apr 20, 2020

Commits on Mar 14, 2020

  1. Define C++ version and load CUDA first

    Fixes a regression from 1e3fc3b: the Boost version depends on
    the CUDA version for Intel, therefore CUDA must be loaded first,
    but the CUDA version depends on the C++ version, so C++14 must be
    defined at the top of the file.
    jngrad committed Mar 14, 2020
    Configuration menu
    Copy the full SHA
    2d1f600 View commit details
    Browse the repository at this point in the history
  2. Load the CUDA compiler selected by the user

    The user can now provide the name of the CUDA compiler as a CMake
    flag instead of modifying CMake variables to bypass the guessing
    mechanism. CMake fails if the selected compiler is not found. The
    FindCUDACompiler helper file was split into separate .cmake files.
    jngrad committed Mar 14, 2020
    Configuration menu
    Copy the full SHA
    c271344 View commit details
    Browse the repository at this point in the history
  3. Check the CUDA version for all compilers

    The minimum CUDA version is 9.0 for NVCC and 8.0 for Clang. For the
    Clang compiler and the Clang-based HIP compiler, the minimum version
    that is tested in CI is 6.0.0.
    jngrad committed Mar 14, 2020
    Configuration menu
    Copy the full SHA
    f148cca View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    8008f8d View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    57e1e99 View commit details
    Browse the repository at this point in the history
  6. Remove outdated CMake advice

    The ESPResSo CMake project now has proper dependencies for every
    target in the source code, documentation and tests. It is no longer
    necessary to delete the build directory to start a fresh build.
    jngrad committed Mar 14, 2020
    Configuration menu
    Copy the full SHA
    64a13a5 View commit details
    Browse the repository at this point in the history
  7. New CUDA compiler selection mechanism in CI

    Explicitly toggle GPU code on/off with WITH_CUDA and select the
    compiler with WITH_CUDA_COMPILER.
    jngrad committed Mar 14, 2020
    Configuration menu
    Copy the full SHA
    6bac9e9 View commit details
    Browse the repository at this point in the history
  8. Make the default value of WITH_CUDA option OFF

    With the CUDA compiler guessing mechanism removed, the user must
    explicitly states if CUDA is available and which compiler to use.
    jngrad committed Mar 14, 2020
    Configuration menu
    Copy the full SHA
    b1277d8 View commit details
    Browse the repository at this point in the history
  9. Patch hipcc environment variables in ROCm 3.X

    In ROCm 3.0 and 3.1, environment variables for hipcc and hcc are
    overriden by incorrect paths (espressomd/docker#156). This causes
    CMake to generate an incorrect linking command for EspressoCore.so:
    in `/opt/rocm/bin/hipcc_cmake_linker_helper /opt/rocm -fPIC ...`,
    either path `/opt/rocm` is an empty string, or both the linker path
    and path `/opt/rocm` are empty strings. Calling `find_package()`
    twice with an overriden `HCC_PATH` fixes the linking command.
    jngrad committed Mar 14, 2020
    Configuration menu
    Copy the full SHA
    932a3e9 View commit details
    Browse the repository at this point in the history
  10. Print CMake version during configuration

    Knowing the CMake version is extremely useful when reviewing CMake
    logs attached in bug reports.
    jngrad committed Mar 14, 2020
    Configuration menu
    Copy the full SHA
    662d03f View commit details
    Browse the repository at this point in the history
  11. Modern CMake: naming convention for CUDA variables

    The C++ standard used for CUDA code is set in `CMAKE_CUDA_STANDARD`.
    Variable `CMAKE_CUDA_VERSION` was renamed to `MINIMAL_CUDA_VERSION`
    for clarity.
    jngrad committed Mar 14, 2020
    Configuration menu
    Copy the full SHA
    f8457a3 View commit details
    Browse the repository at this point in the history
  12. Fix nvcc compiler error

    The nvcc `-O<N>` optimization flag can only take a number.
    jngrad committed Mar 14, 2020
    Configuration menu
    Copy the full SHA
    929e16c View commit details
    Browse the repository at this point in the history
  13. Fix clang compiler error

    Cannot compile CUDA code with coverage enabled using Clang.
    jngrad committed Mar 14, 2020
    Configuration menu
    Copy the full SHA
    4447570 View commit details
    Browse the repository at this point in the history

Commits on Mar 16, 2020

  1. Refactor optimization flags, simplify CI script

    Rewrite CUDA flags based on the CXX flags:
    
    CMAKE_CXX_FLAGS_DEBUG = -O0 -g
    CMAKE_CXX_FLAGS_RELEASE = -O3 -DNDEBUG
    CMAKE_CXX_FLAGS_MINSIZEREL = -Os -DNDEBUG
    CMAKE_CXX_FLAGS_RELWITHDEBINFO = -O2 -g -DNDEBUG
    
    Add a COVERAGE build type that uses -O0 for host and -O3 for
    device. This replaces the logic in the CI script that had to touch
    `CMAKE_CXX_FLAGS` and `CUDA_NVCC_FLAGS`. The -O0 optimization flag
    for host avoids ending up with source code lines in the gcov output
    with neither hit or miss. According to `man gcov`:
    
    > compile your code without optimization if you plan to use gcov
    > because the optimization, by combining some lines of code into
    > one function, may not give you as much information as you need
    jngrad committed Mar 16, 2020
    Configuration menu
    Copy the full SHA
    8061ba8 View commit details
    Browse the repository at this point in the history
  2. Remove obsolete CI options

    jngrad committed Mar 16, 2020
    Configuration menu
    Copy the full SHA
    df04e08 View commit details
    Browse the repository at this point in the history
  3. Refactor build type and CUDA compiler selection

    Generate a warning for incorrect build types and override them with
    'Release'. Move the `set(CMAKE_BUILD_TYPE CACHE)` declaration out
    of the conditional such that its help message always gets displayed
    in cmake/ccmake. List the possible values as properties to allow
    cycling in ccmake and cmake-gui (instead of manually typing them).
    Same thing for WITH_CUDA_COMPILER. This is achieved by creating a
    wrapper around the `option()` function that accepts an enum value
    (stored as a string) instead of a boolean value.
    jngrad committed Mar 16, 2020
    Configuration menu
    Copy the full SHA
    47e8418 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    6865fe9 View commit details
    Browse the repository at this point in the history
  5. Add oversubscription guard

    The same guard is used in the CMake logic for Python tests.
    jngrad committed Mar 16, 2020
    Configuration menu
    Copy the full SHA
    ff2f98f View commit details
    Browse the repository at this point in the history

Commits on Apr 2, 2020

  1. Configuration menu
    Copy the full SHA
    b8e22a9 View commit details
    Browse the repository at this point in the history
  2. Add a RelWithAssert build type

    The "release with assertions" build type restores the original
    behavior of the CI pipeline for non-coverage CI jobs: -O3 for
    faster tests and -g to get a minimal backtrace in GDB.
    jngrad committed Apr 2, 2020
    Configuration menu
    Copy the full SHA
    74c4c4c View commit details
    Browse the repository at this point in the history
  3. Test the Release build type in CI

    The original `build_cmake.sh` logic was accidentally compiling
    ESPResSo with optimization flag -O0 in job "installation", leading
    to a significant slowdown in CI.
    jngrad committed Apr 2, 2020
    Configuration menu
    Copy the full SHA
    5e67a3a View commit details
    Browse the repository at this point in the history
  4. Print the complete list of CMake options

    Move all the if/else logic for CMake options above the function call
    that prints shell variables to display the full CMake command in CI.
    jngrad committed Apr 2, 2020
    Configuration menu
    Copy the full SHA
    dcbc98f View commit details
    Browse the repository at this point in the history

Commits on Apr 3, 2020

  1. Configuration menu
    Copy the full SHA
    a109f6c View commit details
    Browse the repository at this point in the history
  2. Apply clang-format

    jngrad committed Apr 3, 2020
    Configuration menu
    Copy the full SHA
    6b87f2a View commit details
    Browse the repository at this point in the history
  3. Factor out coverage flags

    jngrad committed Apr 3, 2020
    Configuration menu
    Copy the full SHA
    de9f0b3 View commit details
    Browse the repository at this point in the history

Commits on Apr 17, 2020

  1. Configuration menu
    Copy the full SHA
    7336b0b View commit details
    Browse the repository at this point in the history
  2. Modern CMake

    Use interface libraries for compiler flags instead of populating
    variable with global scope that are injected in the compilation and
    linking commands of all libraries (e.g. CMAKE_CXX_FLAGS). Remove
    duplicated compile flags. Give meaningful names to variables in
    FindCUDA* CMake files. Document CMake policies and add CMP0025 to
    distinguish between Clang and AppleClang. Replace simple if/else
    blocks by generator expressions.
    jngrad committed Apr 17, 2020
    Configuration menu
    Copy the full SHA
    50342b6 View commit details
    Browse the repository at this point in the history
  3. Simplify HIP detection

    Move ROCm path patching logic in FindCUDACompilerHIP.cmake and
    check only the HIP version.
    jngrad committed Apr 17, 2020
    Configuration menu
    Copy the full SHA
    be61c3a View commit details
    Browse the repository at this point in the history
  4. Fix Travis shell error

    The double quotes were not removed by the shell interpreter.
    jngrad committed Apr 17, 2020
    Configuration menu
    Copy the full SHA
    b798fab View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    b53e4c9 View commit details
    Browse the repository at this point in the history
  6. Correctly detect CUDA versions with Clang

    Clang returns "version unknown" for unsupported CUDA libraries,
    or doesn't return a version string (depending on CMAKE_CXX_FLAGS),
    causing the CMake regex to store the complete Clang stdout in the
    CUDA_VERSION variable instead of a valid version number. This is
    now fixed, and the CUDA version is now shown as <major>.<minor>.
    jngrad committed Apr 17, 2020
    Configuration menu
    Copy the full SHA
    58978df View commit details
    Browse the repository at this point in the history