Skip to content

Commit

Permalink
Merge branch 'develop' into dev/prune-pyramid-code
Browse files Browse the repository at this point in the history
  • Loading branch information
Carsten Griwodz committed Aug 12, 2024
2 parents 55810f9 + bdd37e5 commit 181e585
Show file tree
Hide file tree
Showing 24 changed files with 187 additions and 386 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
container: ["alicevision/popsift-deps:cuda10.2-ubuntu18.04", "alicevision/popsift-deps:cuda11.8.0-ubuntu20.04", "alicevision/popsift-deps:cuda12.1.0-ubuntu22.04"]
container: ["alicevision/popsift-deps:cuda11.8.0-ubuntu20.04", "alicevision/popsift-deps:cuda12.1.0-ubuntu22.04"]
build_tpe: ["Release", "Debug"]
exclude:
# excludes debug on this one as it has a segmentation fault during the compilation (!)
- container: "alicevision/popsift-deps:cuda12.1.0-ubuntu22.04"
- container: "alicevision/popsift-deps:cuda11.8.0-ubuntu20.04"
build_tpe: "Debug"

container:
Expand Down
41 changes: 11 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dist: xenial
dist: jammy

language: cpp
compiler: gcc
Expand All @@ -13,10 +13,8 @@ addons:

env:
matrix:
- CUDA_VERSION_MAJOR="8" CUDA_VERSION_MINOR="0" CUDA_PKG_LONGVERSION="${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}.61-1" CUDA_PKG_VERSION="${CUDA_VERSION_MAJOR}-${CUDA_VERSION_MINOR}"
- CUDA_VERSION_MAJOR="9" CUDA_VERSION_MINOR="2" CUDA_PKG_LONGVERSION="${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}.148-1" CUDA_PKG_VERSION="${CUDA_VERSION_MAJOR}-${CUDA_VERSION_MINOR}"
- CUDA_VERSION_MAJOR="10" CUDA_VERSION_MINOR="2" CUDA_PKG_LONGVERSION="${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}.89-1" CUDA_PKG_VERSION="${CUDA_VERSION_MAJOR}-${CUDA_VERSION_MINOR}"
- CUDA_VERSION_MAJOR="11" CUDA_VERSION_MINOR="0" CUDA_PKG_LONGVERSION="${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}.2-1" CUDA_PKG_VERSION="${CUDA_VERSION_MAJOR}-${CUDA_VERSION_MINOR}"
- CUDA_VERSION_MAJOR="11" CUDA_VERSION_MINOR="8" CUDA_PKG_LONGVERSION="${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}.0-1" CUDA_PKG_VERSION="${CUDA_VERSION_MAJOR}-${CUDA_VERSION_MINOR}"
- CUDA_VERSION_MAJOR="12" CUDA_VERSION_MINOR="5" CUDA_PKG_LONGVERSION="${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}.1-1" CUDA_PKG_VERSION="${CUDA_VERSION_MAJOR}-${CUDA_VERSION_MINOR}"


global:
Expand All @@ -34,7 +32,7 @@ env:
- POPSIFT_APP_INSTALL_RELEASE=${POPSIFT_APP_BUILD_RELEASE}/install
- POPSIFT_APP_INSTALL_DEBUG=${POPSIFT_APP_BUILD_DEBUG}/install
# CMAKE
- CMAKE_URL="https://cmake.org/files/v3.13/cmake-3.13.5-Linux-x86_64.tar.gz"
- CMAKE_URL="https://github.com/Kitware/CMake/releases/download/v3.30.1/cmake-3.30.1-linux-x86_64.tar.gz"
- CMAKE_ROOT=${TRAVIS_BUILD_DIR}/cmake
- CMAKE_SOURCE=${CMAKE_ROOT}/source
- CMAKE_INSTALL=${CMAKE_ROOT}/install
Expand All @@ -57,30 +55,12 @@ before_install:
fi
install:
- UBUNTU_VERSION=ubuntu1604
- >
if [ ${CUDA_VERSION_MAJOR} -lt 11 ]; then
CUDA_REPO_PKG=cuda-repo-${UBUNTU_VERSION}_${CUDA_PKG_LONGVERSION}_amd64.deb
wget http://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/$CUDA_REPO_PKG
travis_retry sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/7fa2af80.pub
sudo dpkg -i $CUDA_REPO_PKG
rm ${CUDA_REPO_PKG}
travis_retry sudo apt-get -y update
# cuda > 10.0 changed cublas naming
if [ ${CUDA_VERSION_MAJOR} -lt 10 ]; then
CUBLAS_PKG=cuda-cublas-dev-$CUDA_PKG_VERSION
else
CUBLAS_PKG=libcublas-dev
fi
travis_retry sudo apt-get install -y --no-install-recommends --allow-unauthenticated cuda-core-$CUDA_PKG_VERSION cuda-cudart-dev-$CUDA_PKG_VERSION ${CUBLAS_PKG} cuda-curand-dev-$CUDA_PKG_VERSION
sudo ln -s /usr/local/cuda-${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR} /usr/local/cuda
else
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-ubuntu1604.pin
travis_retry sudo mv cuda-ubuntu1604.pin /etc/apt/preferences.d/cuda-repository-pin-600
travis_retry sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
travis_retry sudo add-apt-repository "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/ /"
sudo apt-get update && sudo apt-get -y install cuda
fi
- UBUNTU_VERSION=ubuntu2204
- wget https://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/cuda-${UBUNTU_VERSION}.pin
- travis_retry sudo mv cuda-${UBUNTU_VERSION}.pin /etc/apt/preferences.d/cuda-repository-pin-600
- travis_retry sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/3bf863cc.pub
- travis_retry sudo add-apt-repository "deb http://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/ /"
- sudo apt-get update && sudo apt-get -y install cuda
# - CUDA_REPO_PKG=cuda-repo-${UBUNTU_VERSION}_${CUDA_PKG_LONGVERSION}_amd64.deb
# - wget http://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/$CUDA_REPO_PKG

Expand Down Expand Up @@ -131,3 +111,4 @@ cache:
apt: true
directories:
- ${CMAKE_INSTALL}

4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [1.0.0] - YYYY-MM-DD

## 2024

- CMake: CUDA as first-order language, different CC selection

### Added
- Improved checks for CUDA textures [PR](https://github.com/alicevision/popsift/pull/89)
- CMake: Improved support for all Cuda CC [PR](https://github.com/alicevision/popsift/pull/75)
Expand Down
112 changes: 35 additions & 77 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
# CMake below 3.4 does not work with CUDA separable compilation at all
cmake_minimum_required(VERSION 3.12)
# First-order language CUDA requires at least CMake 3.18
cmake_minimum_required(VERSION 3.24)

project(PopSift VERSION 1.0.0 LANGUAGES CXX)
project(PopSift VERSION 1.0.0 LANGUAGES CXX CUDA)

# Policy to support CUDA as a first-order language for CMake.
# Since CMake 3.18. See https://cmake.org/cmake/help/latest/policy/CMP0104.html
cmake_policy(SET CMP0104 NEW)

set(CMAKE_CUDA_ARCHITECTURES "all-major"
CACHE
STRING "Which CUDA CCs to support: native, all, all-major or an explicit list delimited by semicolons"
FORCE)

# Set build path as a folder named as the platform (linux, windows, darwin...) plus the processor type
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
Expand All @@ -16,7 +25,6 @@ option(PopSift_USE_GRID_FILTER "Switch off grid filtering to massively reduce co
option(PopSift_USE_NORMF "The __normf function computes Euclidean distance on large arrays. Fast but stability is uncertain." OFF)
option(PopSift_NVCC_WARNINGS "Switch on several additional warning for CUDA nvcc" OFF)
option(PopSift_USE_TEST_CMD "Add testing step for functional verification" OFF)
option(PopSift_NO_DEPRECATED_CUDA_SM_WARNINGS "Suppress warnings about soon to be deprecated cuda SM" ON)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)

if(PopSift_USE_POSITION_INDEPENDENT_CODE AND NOT MSVC)
Expand Down Expand Up @@ -55,17 +63,15 @@ include(GNUInstallDirs)

if(BUILD_SHARED_LIBS)
message(STATUS "BUILD_SHARED_LIBS ON")
# Need to declare CUDA_USE_STATIC_CUDA_RUNTIME as an option to ensure that it is not overwritten in FindCUDA.
option(CUDA_USE_STATIC_CUDA_RUNTIME "Use the static version of the CUDA runtime library if available" OFF)
set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
# Workaround to force deactivation of cuda static runtime for cmake < 3.10
set(CUDA_cudart_static_LIBRARY 0)

# Auto-build dll exports on Windows
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

set(CMAKE_CUDA_RUNTIME_LIBRARY Shared)
else()
message(STATUS "BUILD_SHARED_LIBS OFF")
option(CUDA_USE_STATIC_CUDA_RUNTIME "Use the static version of the CUDA runtime library if available" ON)
set(CUDA_USE_STATIC_CUDA_RUNTIME ON)

set(CMAKE_CUDA_RUNTIME_LIBRARY Static)
endif()

# Require threads because of std::thread.
Expand All @@ -74,26 +80,15 @@ find_package(Threads REQUIRED)
###################
# CUDA
###################
find_package(CUDA 7.0 REQUIRED)
include(CheckLanguage)
check_language(CUDA)

if(NOT CUDA_FOUND)
message(FATAL_ERROR "Could not find CUDA >= 7.0")
endif()
# Use this if necessary: "cmake -DCUDAToolkit_ROOT=/some/path"
# target_link_libraries(binary_linking_to_cudart PRIVATE CUDA::cudart)
find_package(CUDAToolkit)

message(STATUS "CUDA Version is ${CUDA_VERSION}")

include(ChooseCudaCC)
if(NOT DEFINED PopSift_CUDA_CC_LIST)
chooseCudaCC(PopSift_CUDA_CC_LIST_BASIC
PopSift_CUDA_GENCODE_FLAGS
MIN_CC 30
MIN_CUDA_VERSION 7.0)
set(PopSift_CUDA_CC_LIST ${PopSift_CUDA_CC_LIST_BASIC} CACHE STRING "CUDA CC versions to compile")
else()
getFlagsForCudaCCList(PopSift_CUDA_CC_LIST
PopSift_CUDA_GENCODE_FLAGS)
endif()
list(APPEND CUDA_NVCC_FLAGS "${PopSift_CUDA_GENCODE_FLAGS}")
message(STATUS "CUDA Version is ${CUDAToolkit_VERSION}")
set(CUDA_VERSION ${CUDAToolkit_VERSION})

if(PopSift_USE_NVTX_PROFILING)
message(STATUS "PROFILING CPU CODE: NVTX is in use")
Expand All @@ -104,46 +99,8 @@ if(PopSift_ERRCHK_AFTER_KERNEL)
list(APPEND CUDA_NVCC_FLAGS "-DERRCHK_AFTER_KERNEL")
endif()

set(CUDA_SEPARABLE_COMPILATION ON)

if(PopSift_NO_DEPRECATED_CUDA_SM_WARNINGS)
list(APPEND CUDA_NVCC_FLAGS "-Wno-deprecated-gpu-targets")
endif()

if(UNIX AND NOT APPLE)
list(APPEND CUDA_NVCC_FLAGS "-Xcompiler;-rdynamic")
# set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};-Xptxas;-v")
# set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};-Xptxas;-warn-double-usage")
list(APPEND CUDA_NVCC_FLAGS_DEBUG "--keep")
list(APPEND CUDA_NVCC_FLAGS_DEBUG "--source-in-ptx")
endif()

# The following if should not be necessary, but apparently there is a bug in FindCUDA.cmake that
# generate an empty string in the nvcc command line causing the compilation to fail.
# see https://gitlab.kitware.com/cmake/cmake/issues/16411
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Building in debug mode")
list(APPEND CUDA_NVCC_FLAGS_DEBUG "-G")
endif()
list(APPEND CUDA_NVCC_FLAGS_RELEASE "-O3")

if(PopSift_USE_POSITION_INDEPENDENT_CODE AND NOT MSVC)
list(APPEND CUDA_NVCC_FLAGS "-Xcompiler;-fPIC")
endif()

# this is to ensure that on MSVC the flags for the linker are properly propagate even to the intermediate
# linking step. This seems not the case e.g. on vcpkg using ninja build.
if(MSVC)
if(BUILD_SHARED_LIBS)
set(PopSift_MVSC_LINKER "/MD")
else()
set(PopSift_MVSC_LINKER "/MT")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(PopSift_MVSC_LINKER "${PopSift_MVSC_LINKER}d")
endif()
list(APPEND CUDA_NVCC_FLAGS -Xcompiler ${PopSift_MVSC_LINKER})
endif()
# This may not be required any more.
set(CMAKE_CUDA_SEPARABLE_COMPILATION ON)

# default stream per-thread implies that each host thread has one non-synchronizing 0-stream
# currently, the code requires legacy mode
Expand All @@ -159,7 +116,7 @@ if(CUDA_VERSION VERSION_GREATER_EQUAL "7.5")
endif()
endif()

set(PopSift_CXX_STANDARD 14) # Thrust/CUB requires C++14 starting with CUDA SDK 11
set(PopSift_CXX_STANDARD 17) # Thrust/CUB requires C++14 starting with CUDA SDK 11
if(CUDA_VERSION_MAJOR LESS_EQUAL 8)
set(PopSift_CXX_STANDARD 11)
endif()
Expand All @@ -181,9 +138,9 @@ else()
endif()

if(CUDA_VERSION VERSION_GREATER_EQUAL "9.0")
set(HAVE_SHFL_DOWN_SYNC 1)
set(PopSift_HAVE_SHFL_DOWN_SYNC 1)
else()
set(HAVE_SHFL_DOWN_SYNC 0)
set(PopSift_HAVE_SHFL_DOWN_SYNC 0)
endif()

if(NOT PopSift_USE_GRID_FILTER)
Expand All @@ -193,12 +150,8 @@ else()
set(DISABLE_GRID_FILTER 0)
endif()

# library required for CUDA dynamic parallelism, forgotten by CMake 3.4
cuda_find_library_local_first(CUDA_CUDADEVRT_LIBRARY cudadevrt "\"cudadevrt\" library")

if(PopSift_USE_NVTX_PROFILING)
# library required for NVTX profiling of the CPU
cuda_find_library_local_first(CUDA_NVTX_LIBRARY nvToolsExt "NVTX library")
set(PopSift_USE_NVTX 1)
else()
set(PopSift_USE_NVTX 0)
Expand Down Expand Up @@ -245,9 +198,14 @@ message(STATUS "Use CUDA NVTX for profiling: " ${PopSift_USE_NVTX_PROFILING})
message(STATUS "Synchronize and check CUDA error after every kernel: " ${PopSift_ERRCHK_AFTER_KERNEL})
message(STATUS "Grid filtering: " ${PopSift_USE_GRID_FILTER})
message(STATUS "Additional warning for CUDA nvcc: " ${PopSift_NVCC_WARNINGS})
message(STATUS "Compiling for CUDA CCs: ${PopSift_CUDA_CC_LIST}")
message(STATUS "Install path: " ${CMAKE_INSTALL_PREFIX})
message(STATUS "Testing step: " ${PopSift_USE_TEST_CMD})

message(STATUS "CMAKE_CUDA_COMPILER = ${CMAKE_CUDA_COMPILER}")
message(STATUS "CMAKE_CUDA_COMPILER_ID = ${CMAKE_CUDA_COMPILER_ID}")
message(STATUS "CMAKE_CUDA_COMPILER_VERSION = ${CMAKE_CUDA_COMPILER_VERSION}")
message(STATUS "CMAKE_CUDA_ARCHITECTURES = ${CMAKE_CUDA_ARCHITECTURES}")

if(PopSift_USE_TEST_CMD)
message(STATUS "Path for test input: " ${PopSift_TESTFILE_PATH})
endif()
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ PopSift depends on:

Optionally, for the provided applications:

* Boost >= 1.55 (required components {atomic, chrono, date-time, system, thread}-dev)
* Boost >= 1.71 (required components {atomic, chrono, date-time, system, thread}-dev)

* DevIL (libdevil-dev) can be used to load a broader range of image formats, otherwise only pgm is supported.

Expand Down
22 changes: 20 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#
# Build system for the PopSift library, including its demo programs.
#
version: '1.0.{build}'

image: Visual Studio 2015
image: Visual Studio 2022

platform:
- x64
Expand All @@ -14,6 +17,9 @@ configuration:
# - DBUILD_SHARED_LIBS: 0
# - DBUILD_SHARED_LIBS: 1

#
# Check the separate file cudaInstallAppveyor for the installation of CUDA
#
install:
- cmd: >-
call cudaInstallAppveyor.cmd
Expand All @@ -23,10 +29,22 @@ install:
--triplet %PLATFORM%-windows
# devil

#
# When updating to a new version of visual studio, change the generation string after
# -G and find the suitable toolkit version that is listed after -T (v143 in this case).
# The CUDA Toolkit and the VS version must match. The matches are found in the CUDA
# documentation.
# The platform in this case is x64. Apparently, you need in after -T for VS and after -A
# for CUDA.
# You can only have one -T parameter, but you can separate several options with a comma.
#
# PopSift_USE_GRID_FILTER is off in this build because the installation of CUDA Thrust
# in cudaInstallAppveyor is not happening yet.
#
before_build:
- md build
- cd build
- cmake -G "Visual Studio 14 2015" -A x64 -T v140,host=x64 -DBUILD_SHARED_LIBS=%DBUILD_SHARED_LIBS% -DPopSift_BUILD_DOCS:BOOL=OFF -DPopSift_USE_POSITION_INDEPENDENT_CODE:BOOL=%DBUILD_SHARED_LIBS% -DPopSift_BUILD_EXAMPLES:BOOL=ON -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake ..
- cmake -G "Visual Studio 17 2022" -A x64 -T v143,host=x64,cuda="%ProgramFiles%\NVIDIA GPU Computing Toolkit\CUDA\v12.5" -DBUILD_SHARED_LIBS:BOOL=ON -DPopSift_USE_NVTX_PROFILING:BOOL=OFF -DPopSift_USE_GRID_FILTER:BOOL=OFF -DPopSift_BUILD_DOCS:BOOL=OFF -DPopSift_USE_POSITION_INDEPENDENT_CODE:BOOL=ON -DPopSift_BUILD_EXAMPLES:BOOL=ON -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake ..
- ls -l

build:
Expand Down
Loading

0 comments on commit 181e585

Please sign in to comment.