diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 2f5a18405..336fe748d 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -37,6 +37,7 @@ jobs: - os: ubuntu-latest compiler: gcc compiler_version: 9 + cuda_version: "0" BUILD_FLAGS: "-DSTIR_OPENMP=ON" BUILD_TYPE: "Release" parallelproj: "ON" @@ -45,6 +46,7 @@ jobs: - os: ubuntu-latest compiler: clang #compiler_version: + cuda_version: "0" BUILD_FLAGS: "-DSTIR_OPENMP=ON" BUILD_TYPE: "Release" parallelproj: "ON" @@ -54,6 +56,7 @@ jobs: - os: ubuntu-latest compiler: gcc compiler_version: 10 + cuda_version: "0" BUILD_FLAGS: "-DSTIR_OPENMP=ON -DCMAKE_CXX_STANDARD=17" BUILD_TYPE: "Debug" parallelproj: "OFF" @@ -62,14 +65,25 @@ jobs: - os: ubuntu-latest compiler: gcc compiler_version: 12 + cuda_version: "0" BUILD_FLAGS: "-DSTIR_OPENMP=ON -DCMAKE_CXX_STANDARD=14" BUILD_TYPE: "RelWithDebInfo" parallelproj: "ON" ROOT: "OFF" ITK: "ON" + - os: ubuntu-latest + compiler: gcc + compiler_version: 12 + cuda_version: "12.1.0" + BUILD_FLAGS: "-DSTIR_OPENMP=ON -DCMAKE_CXX_STANDARD=14" + BUILD_TYPE: "Release" + parallelproj: "ON" + ROOT: "OFF" + ITK: "ON" - os: macOS-latest compiler: gcc compiler_version: 11 + cuda_version: "0" BUILD_FLAGS: "-DSTIR_OPENMP=OFF" parallelproj: "OFF" BUILD_TYPE: "Debug" @@ -88,7 +102,7 @@ jobs: # let's run all of them, as opposed to aborting when one fails fail-fast: false - name: ${{ matrix.os }}-${{ matrix.compiler }}${{ matrix.compiler_version }}-${{ matrix.BUILD_TYPE }}-pp=${{ matrix.parallelproj }}-ROOT=${{ matrix.ROOT }} + name: ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.compiler_version }}-cuda${{ matrix.cuda_version }}-${{ matrix.BUILD_TYPE }}-pp=${{ matrix.parallelproj }}-ROOT=${{ matrix.ROOT }} steps: - name: disk space @@ -152,6 +166,13 @@ jobs: echo CC="$CC" >> $GITHUB_ENV echo CXX="$CXX" >> $GITHUB_ENV + - if: matrix.cuda_version != '0' + uses: Jimver/cuda-toolkit@v0.2.11 + id: cuda-toolkit + with: + cuda: ${{ matrix.cuda_version }} + linux-local-args: '["--toolkit"]' + - name: install_dependencies shell: bash run: | @@ -212,10 +233,22 @@ jobs: git clone --depth 1 --branch v1.3.7 https://github.com/gschramm/parallelproj mkdir parallelproj/build cd parallelproj/build - cmake .. -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DSKIP_CUDA_LIB:BOOL=ON + if test "${{matrix.cuda_version}}" == "0"; then + extra_args="-DSKIP_CUDA_LIB:BOOL=ON" + fi + cmake .. -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} ${extra_args} cmake --build . --target install --config Release cd ../.. fi + # Install NiftyPET + if test ! "${{matrix.cuda_version}}" == "0"; then + export PATHTOOLS=${GITHUB_WORKSPACE}/NiftyPET_tools + export HMUDIR=${GITHUB_WORKSPACE}/mmr_hardwareumaps + python -m pip install "nipet>=2" + niftypet_cmake_prefix=$(python -c "from niftypet.nipet import cmake_prefix; print(cmake_prefix)") + find /home/runner/work/STIR/STIR/my-env/ -name prjb.h + echo NiftyPET_DIR="$niftypet_cmake_prefix" >> $GITHUB_ENV + fi # Install ROOT (warning: currently only valid on Ubuntu) if test "${{matrix.ROOT}}XX" == "ONXX"; then @@ -243,7 +276,7 @@ jobs: - name: ccache uses: hendrikmuhs/ccache-action@v1 with: - key: ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.compiler_version }}-${{ matrix.BUILD_TYPE }} + key: ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.compiler_version }}-cuda${{ matrix.cuda_version }}-${{ matrix.BUILD_TYPE }} max-size: "2G" - name: configure @@ -265,6 +298,7 @@ jobs: echo CMAKE_INSTALL_PREFIX="$CMAKE_INSTALL_PREFIX" >> $GITHUB_ENV EXTRA_BUILD_FLAGS="-DBUILD_SWIG_PYTHON=ON -DPYTHON_EXECUTABLE=`which python`" EXTRA_BUILD_FLAGS="${EXTRA_BUILD_FLAGS} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DCMAKE_BUILD_TYPE=${BUILD_TYPE}" + EXTRA_BUILD_FLAGS="${EXTRA_BUILD_FLAGS} -DNiftyPETnipet_DIR=${NiftyPET_DIR}" EXTRA_BUILD_FLAGS="${EXTRA_BUILD_FLAGS} -DDOWNLOAD_ZENODO_TEST_DATA=ON" EXTRA_BUILD_FLAGS="${EXTRA_BUILD_FLAGS} -DDISABLE_STIR_LOCAL=OFF -DSTIR_LOCAL=${GITHUB_WORKSPACE}/examples/C++/src" echo "cmake flags $BUILD_FLAGS $EXTRA_BUILD_FLAGS" @@ -288,8 +322,9 @@ jobs: run: | cd ${GITHUB_WORKSPACE}/build; source ${GITHUB_WORKSPACE}/my-env/bin/activate - cmake --build . -j 2 --config ${BUILD_TYPE}} --target install - + cmake --build . -j 2 --config ${BUILD_TYPE}} --target install || true + #debug + make VERBOSE=ON - name: ctest shell: bash env: @@ -300,6 +335,10 @@ jobs: if test ${BUILD_TYPE} = Debug; then EXCLUDE="-E test_data_processor_projectors|test_export_array|test_ArcCorrection|test_blocks_on_cylindrical_projectors" fi + if test ${{matrix.cuda_version}} != "0"; then + # No CUDA drivers on GitHub Actions + EXCLUDE="${EXCLUDE}|parallelproj|NiftyPET|test_blocks_on_cylindrical_projectors" + fi ctest --output-on-failure -C ${BUILD_TYPE} ${EXCLUDE} - name: recon_test_pack diff --git a/CMakeLists.txt b/CMakeLists.txt index 2873ad6dc..195fe1da8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,11 +5,7 @@ # See STIR/LICENSE.txt for details # cmake file for building STIR. See the STIR User's Guide and http://www.cmake.org. -if (CMAKE_HOST_WIN32) - cmake_minimum_required(VERSION 3.12.0) -else() - cmake_minimum_required(VERSION 3.1.0) -endif() +cmake_minimum_required(VERSION 3.14.0) # enable ccache https://ccache.samba.org/ find_program(CCACHE_PROGRAM ccache) @@ -183,8 +179,8 @@ endif() if(NOT DISABLE_NiftyPET_PROJECTOR) if (CUDAToolkit_FOUND) - find_package(NiftyPET) - if (NiftyPET_FOUND) + find_package(NiftyPETnipet COMPONENTS mmr_auxe mmr_lmproc petprj CONFIG) + if (NiftyPETnipet_FOUND) set(STIR_WITH_NiftyPET_PROJECTOR ON) endif() endif() diff --git a/examples/C++/src/CMakeLists.txt b/examples/C++/src/CMakeLists.txt index 3e3308501..9ef4f3fae 100644 --- a/examples/C++/src/CMakeLists.txt +++ b/examples/C++/src/CMakeLists.txt @@ -5,7 +5,7 @@ set(dir examples) set(dir_EXE_SOURCES ${dir}_EXE_SOURCES) set(${dir_EXE_SOURCES} - demo1 demo2 demo3 demo4_obj_fun demo5_line_search + demo1.cxx demo2.cxx demo3.cxx demo4_obj_fun.cxx demo5_line_search.cxx ) diff --git a/src/cmake/FindNiftyPET.cmake b/src/cmake/FindNiftyPET.cmake deleted file mode 100644 index 59c0f8c54..000000000 --- a/src/cmake/FindNiftyPET.cmake +++ /dev/null @@ -1,82 +0,0 @@ -# Copyright 2019-2020 University College London -# @Author Richard Brown -# -# This file is part of STIR. -# -# SPDX-License-Identifier: Apache-2.0 -# -# See STIR/LICENSE.txt for details - -include(FindPackageHandleStandardArgs) - -set(package NiftyPET) - -if (NOT ${package}_PATH) - set(${package}_PATH "" CACHE PATH "Path to ${package} installation") -endif() - -############################################################### -# Headers -############################################################### - -# Find the base folder containing def.h -find_path(${package}_INCLUDE_DIR "niftypet/nipet/def.h" - PATHS ${${package}_PATH} - PATH_SUFFIXES include - ) -mark_as_advanced(${package}_INCLUDE_DIR) - -############################################################### -# Libraries -############################################################### - -set(${package}_required_libraries - petprj - mmr_auxe - mmr_lmproc - ) -set(${package}_libraries "") - -foreach(l ${${package}_required_libraries}) - find_library(${package}_${l} - NAMES ${l}${CMAKE_SHARED_LIBRARY_SUFFIX} ${l}${CMAKE_STATIC_LIBRARY_SUFFIX} - PATHS ${${package}_PATH} - ) - mark_as_advanced(${package}_${l}) - list(APPEND ${package}_libraries ${package}_${l}) -endforeach() - -############################################################### -# Check everything has been found -############################################################### - -find_package_handle_standard_args(${package} - FOUND_VAR ${package}_FOUND - REQUIRED_VARS - ${${package}_libraries} ${package}_INCLUDE_DIR -) - -############################################################### -# Get header subdirectories -############################################################### - -SET(${package}_INCLUDE_DIRS - "${${package}_INCLUDE_DIR}/niftypet/nipet" - "${${package}_INCLUDE_DIR}/niftypet/nipet/dinf" - "${${package}_INCLUDE_DIR}/niftypet/nipet/lm/src" - "${${package}_INCLUDE_DIR}/niftypet/nipet/prj/src" - "${${package}_INCLUDE_DIR}/niftypet/nipet/sct/src" - "${${package}_INCLUDE_DIR}/niftypet/nipet/src" -) - -############################################################### -# Create imported targets -############################################################### - -foreach(l ${${package}_required_libraries}) - add_library(${package}::${l} UNKNOWN IMPORTED) - set_target_properties(${package}::${l} PROPERTIES - IMPORTED_LOCATION "${${package}_${l}}" - INTERFACE_INCLUDE_DIRECTORIES "${${package}_INCLUDE_DIRS}" - ) -endforeach() diff --git a/src/listmode_buildblock/CMakeLists.txt b/src/listmode_buildblock/CMakeLists.txt index baed95da4..45df9b8b2 100644 --- a/src/listmode_buildblock/CMakeLists.txt +++ b/src/listmode_buildblock/CMakeLists.txt @@ -58,3 +58,7 @@ endif() include(stir_lib_target) target_link_libraries(listmode_buildblock PUBLIC data_buildblock ) + +if (STIR_WITH_NiftyPET_PROJECTOR) + target_link_libraries(listmode_buildblock PRIVATE NiftyPET::mmr_auxe NiftyPET::mmr_lmproc NiftyPET::petprj) +endif() diff --git a/src/listmode_utilities/CMakeLists.txt b/src/listmode_utilities/CMakeLists.txt index af031bc95..d6a72b4e4 100644 --- a/src/listmode_utilities/CMakeLists.txt +++ b/src/listmode_utilities/CMakeLists.txt @@ -35,8 +35,8 @@ if (HAVE_ECAT) endif() if (STIR_WITH_NiftyPET_PROJECTOR) - list(APPEND ${dir_EXE_SOURCES} conv_NiftyPET_stir) - list(APPEND ${dir_EXE_SOURCES} lm_to_projdata_NiftyPET) + list(APPEND ${dir_EXE_SOURCES} conv_NiftyPET_stir.cxx) + list(APPEND ${dir_EXE_SOURCES} lm_to_projdata_NiftyPET.cxx) endif() diff --git a/src/recon_buildblock/CMakeLists.txt b/src/recon_buildblock/CMakeLists.txt index 89d3c5e27..a7b9968f6 100644 --- a/src/recon_buildblock/CMakeLists.txt +++ b/src/recon_buildblock/CMakeLists.txt @@ -143,10 +143,7 @@ endif() target_link_libraries(recon_buildblock PUBLIC modelling_buildblock display numerics_buildblock listmode_buildblock data_buildblock buildblock spatial_transformation_buildblock ) if (STIR_WITH_NiftyPET_PROJECTOR) - target_link_libraries(recon_buildblock PUBLIC NiftyPET::petprj) - target_link_libraries(recon_buildblock PUBLIC NiftyPET::mmr_auxe) - target_link_libraries(recon_buildblock PUBLIC NiftyPET::mmr_lmproc) - target_link_libraries(recon_buildblock PUBLIC CUDA::cudart) + target_link_libraries(recon_buildblock PRIVATE NiftyPET::mmr_auxe NiftyPET::mmr_lmproc NiftyPET::petprj) endif() if (STIR_WITH_Parallelproj_PROJECTOR) diff --git a/src/recon_buildblock/NiftyPET_projector/NiftyPETHelper.cxx b/src/recon_buildblock/NiftyPET_projector/NiftyPETHelper.cxx index 53b92c308..3e215c869 100644 --- a/src/recon_buildblock/NiftyPET_projector/NiftyPETHelper.cxx +++ b/src/recon_buildblock/NiftyPET_projector/NiftyPETHelper.cxx @@ -83,7 +83,7 @@ shared_ptr get_cnst(const Scanner &scanner, const bool cuda_verbose, const shared_ptr cnt_sptr = MAKE_SHARED(); cnt_sptr->DEVID = cuda_device; // device (GPU) ID. allows choosing the device on which to perform calculations - cnt_sptr->VERBOSE = cuda_verbose; + cnt_sptr->LOG = cuda_verbose; if (scanner.get_type() == Scanner::Siemens_mMR) { if (!(span==0 || span==1 || span==11)) @@ -123,8 +123,10 @@ shared_ptr get_cnst(const Scanner &scanner, const bool cuda_verbose, const cnt_sptr->MRD = mxRD; // maximum ring difference cnt_sptr->ALPHA = aLPHA; //angle subtended by a crystal +#if 0 // NiftyPET v1 or so. Now this is hardwored as R_RING in sct.h float R = 32.8f; // ring radius cnt_sptr->RE = R + 0.67f; // effective ring radius accounting for the depth of interaction +#endif cnt_sptr->AXR = SZ_RING; //axial crystal dim cnt_sptr->COSUPSMX = 0.725f; //cosine of max allowed scatter angle diff --git a/src/test/NiftyPET_projector/CMakeLists.txt b/src/test/NiftyPET_projector/CMakeLists.txt index d5ed2caf5..e2eddbb37 100644 --- a/src/test/NiftyPET_projector/CMakeLists.txt +++ b/src/test/NiftyPET_projector/CMakeLists.txt @@ -14,10 +14,10 @@ set(dir_INVOLVED_TEST_EXE_SOURCES ${dir}_INVOLVED_TEST_EXE_SOURCES) set(dir_SIMPLE_TEST_EXE_SOURCES_NO_REGISTRIES ${dir}_SIMPLE_TEST_EXE_SOURCES_NO_REGISTRIES) set(${dir_INVOLVED_TEST_EXE_SOURCES} - test_ProjectorNiftyPET_adjoint + test_ProjectorNiftyPET_adjoint.cxx ) ADD_TEST(test_ProjectorNiftyPET_adjoint ${CMAKE_CURRENT_BINARY_DIR}/test_ProjectorNiftyPET_adjoint 3) -include(stir_test_exe_targets) \ No newline at end of file +include(stir_test_exe_targets)