Skip to content

Commit

Permalink
Merge pull request #1395 from lattice/feature/ghactions_cuda
Browse files Browse the repository at this point in the history
add github actions build for CUDA
  • Loading branch information
maddyscientist authored Aug 15, 2023
2 parents 5d8f528 + 929be03 commit 96f8756
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 35 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/cuda_githubactions_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: cuda_ghactions_build

on:
pull_request:
branches: [ "develop" ]

defaults:
run:
shell: bash

env:
BUILD_TYPE: STRICT
CCACHE_COMPILERCHECK: content

jobs:
build:
strategy:
matrix:
compiler: [g++-12, clang++-14]
runs-on: ubuntu-latest

steps:
- name: Install software
run: |
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb
sudo dpkg -i cuda-keyring_1.0-1_all.deb
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends ninja-build cmake libopenmpi-dev gfortran
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: cuda-compiler-12-1 cuda-libraries-dev-12-1 cuda-nvml-dev-12-1
execute_install_scripts: true

- uses: actions/checkout@v3

- name: Ccache for gh actions
uses: hendrikmuhs/ccache-action@v1.2.9
with:
key: ${{ github.job }}-${{ matrix.compiler }}
max-size: 2000M

- name: Configure CMake
run: >
cmake
-DCMAKE_CUDA_COMPILER=/usr/local/cuda-12.1/bin/nvcc
-DCMAKE_CXX_COMPILER=${{matrix.compiler}}
-DCMAKE_CUDA_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DQUDA_GPU_ARCH=sm_80 -DQUDA_GPU_ARCH_SUFFIX=virtual -DQUDA_JITIFY=ON
-DQUDA_MULTIGRID=ON
-DQUDA_MULTIGRID_NVEC_LIST=24
-DQUDA_MDW_FUSED_LS_LIST=4
-DQUDA_MPI=ON -DMPI_CXX_SKIP_MPICXX=ON
-DQUDA_PRECISION=10 -DQUDA_FAST_COMPILE_DSLASH=ON -DQUDA_FAST_COMPILE_REDUCE=ON
-GNinja
-B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build
run: cmake --build ${{github.workspace}}/build

- name: Install
run: cmake --install ${{github.workspace}}/build

17 changes: 7 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ set(CMAKE_CXX_FLAGS_DEVEL
"-g -O3"
CACHE STRING "Flags used by the C++ compiler during regular development builds.")
set(CMAKE_CXX_FLAGS_STRICT
"-O3"
"-Os"
CACHE STRING "Flags used by the C++ compiler during strict jenkins builds.")
set(CMAKE_CXX_FLAGS_RELEASE
"-O3 ${CXX_OPT}"
Expand All @@ -361,7 +361,7 @@ set(CMAKE_C_FLAGS_DEVEL
"-g -O3"
CACHE STRING "Flags used by the C compiler during regular development builds.")
set(CMAKE_C_FLAGS_STRICT
"-O3"
"-Os"
CACHE STRING "Flags used by the C compiler during strict jenkins builds.")
set(CMAKE_C_FLAGS_RELEASE
"-O3"
Expand Down Expand Up @@ -419,14 +419,11 @@ if(QUDA_DOWNLOAD_EIGEN)
CACHE STRING "Eigen use for QUDA_DOWNLOAD_EIGEN")
mark_as_advanced(QUDA_EIGEN_VERSION)
CPMAddPackage(
NAME
Eigen
VERSION
${QUDA_EIGEN_VERSION}
URL
https://gitlab.com/libeigen/eigen/-/archive/${QUDA_EIGEN_VERSION}/eigen-${QUDA_EIGEN_VERSION}.tar.bz2
DOWNLOAD_ONLY
YES)
NAME Eigen
VERSION ${QUDA_EIGEN_VERSION}
URL https://gitlab.com/libeigen/eigen/-/archive/${QUDA_EIGEN_VERSION}/eigen-${QUDA_EIGEN_VERSION}.tar.bz2
DOWNLOAD_ONLY YES
SYSTEM YES)
target_include_directories(Eigen SYSTEM INTERFACE ${Eigen_SOURCE_DIR})
install(DIRECTORY ${Eigen_SOURCE_DIR}/Eigen TYPE INCLUDE)
else()
Expand Down
16 changes: 14 additions & 2 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(CPM_DOWNLOAD_VERSION 0.36.0)
set(CPM_DOWNLOAD_VERSION 0.38.2)

if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
Expand All @@ -10,12 +10,24 @@ endif()

# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))

function(download_cpm)
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION}
)
endfunction()

if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
download_cpm()
else()
# resume download if it previously failed
file(READ ${CPM_DOWNLOAD_LOCATION} check)
if("${check}" STREQUAL "")
download_cpm()
endif()
unset(check)
endif()

include(${CPM_DOWNLOAD_LOCATION})
9 changes: 4 additions & 5 deletions lib/coarse_op.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@

namespace quda {

// For coarsening un-preconditioned operators we use uni-directional
// coarsening to reduce the set up code. For debugging we can force
// bi-directional coarsening.
static bool bidirectional_debug = false;

enum ComputeType {
COMPUTE_UV,
COMPUTE_LV,
Expand Down Expand Up @@ -983,6 +978,10 @@ namespace quda {
double mu_factor, bool allow_truncation, QudaDiracType dirac, QudaMatPCType matpc, bool need_bidirectional,
const int *fine_to_coarse, const int *coarse_to_fine)
{
// For coarsening un-preconditioned operators we use uni-directional
// coarsening to reduce the set up code. For debugging we can force
// bi-directional coarsening.
static bool bidirectional_debug = false;

// sanity checks
if (matpc == QUDA_MATPC_EVEN_EVEN_ASYMMETRIC || matpc == QUDA_MATPC_ODD_ODD_ASYMMETRIC)
Expand Down
24 changes: 9 additions & 15 deletions lib/dslash_coarse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,31 +660,25 @@ namespace quda {
}
};

static bool dslash_init = false;
static std::vector<DslashCoarsePolicy> policies(static_cast<int>(DslashCoarsePolicy::DSLASH_COARSE_POLICY_DISABLED), DslashCoarsePolicy::DSLASH_COARSE_POLICY_DISABLED);
static int first_active_policy=static_cast<int>(DslashCoarsePolicy::DSLASH_COARSE_POLICY_DISABLED);

// string used as a tunekey to ensure we retune if the dslash policy env changes
static char policy_string[TuneKey::aux_n];

static inline void enable_policy(DslashCoarsePolicy p) { policies[static_cast<std::size_t>(p)] = p; }

static inline void disable_policy(DslashCoarsePolicy p)
{
policies[static_cast<std::size_t>(p)] = DslashCoarsePolicy::DSLASH_COARSE_POLICY_DISABLED;
}

template <typename Launch>
class DslashCoarsePolicyTune : public Tunable {

static inline bool dslash_init = false;
static inline int first_active_policy = static_cast<int>(DslashCoarsePolicy::DSLASH_COARSE_POLICY_DISABLED);
// string used as a tunekey to ensure we retune if the dslash policy env changes
static inline char policy_string[TuneKey::aux_n] = {};
static inline std::vector<DslashCoarsePolicy> policies = {static_cast<int>(DslashCoarsePolicy::DSLASH_COARSE_POLICY_DISABLED), DslashCoarsePolicy::DSLASH_COARSE_POLICY_DISABLED};

static void enable_policy(DslashCoarsePolicy p) { policies[static_cast<std::size_t>(p)] = p; }

Launch &dslash;

bool tuneGridDim() const { return false; } // Don't tune the grid dimensions.
bool tuneAuxDim() const { return true; } // Do tune the aux dimensions.
static constexpr bool enable_coarse_shmem_overlap = Launch::enable_coarse_shmem_overlap();

public:
inline DslashCoarsePolicyTune(Launch &dslash) : dslash(dslash)
DslashCoarsePolicyTune(Launch &dslash) : dslash(dslash)
{
if (!dslash_init) {

Expand Down
7 changes: 4 additions & 3 deletions lib/targets/cuda/target_cuda.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
set(CMAKE_CUDA_EXTENSIONS OFF)

find_package(CUDAToolkit REQUIRED)
include(CheckLanguage)
check_language(CUDA)

set(QUDA_TARGET_CUDA ON)

Expand Down Expand Up @@ -242,6 +240,7 @@ target_include_directories(quda PRIVATE ${CMAKE_SOURCE_DIR}/include/targets/cuda
target_include_directories(quda PUBLIC $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include/targets/cuda>
$<INSTALL_INTERFACE:include/targets/cuda>)
target_include_directories(quda SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/include/targets/cuda/externals)
target_include_directories(quda_cpp SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/include/targets/cuda/externals)

# Specific config dependent warning suppressions and lineinfo forwarding

Expand All @@ -257,7 +256,9 @@ target_compile_options(
-Wreorder
$<$<CXX_COMPILER_ID:Clang>:
-Xcompiler=-Wno-unused-function
-Xcompiler=-Wno-unknown-pragmas>
-Xcompiler=-Wno-unknown-pragmas
-Xcompiler=-mllvm\ -unroll-count=4
>
$<$<CXX_COMPILER_ID:GNU>:
-Xcompiler=-Wno-unknown-pragmas>
$<$<CONFIG:DEVEL>:-Xptxas
Expand Down

0 comments on commit 96f8756

Please sign in to comment.