diff --git a/CMakeLists.txt b/CMakeLists.txt index 32f10174..2b6b5186 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.17) project(milk LANGUAGES C) @@ -17,25 +17,29 @@ include(CheckLanguage) # ======================================= # options +option(DEBUG "Enable Debug library" OFF) +if(DEBUG) + set(CMAKE_BUILD_TYPE "Debug") +endif() + option(USE_CUDA "Use CUDA library" OFF) option(USE_MAGMA "Use MAGMA library" OFF) if(USE_CUDA) -#find_package(CUDA 9.0 REQUIRED) -check_language(CUDA) -if(CMAKE_CUDA_COMPILER) - enable_language(CUDA) -else() - #message(FATAL_ERROR "No CUDA support") - message(WARNING "No CUDA support found") - set(CMAKE_CUDA_COMPILER "/usr/bin/nvcc") - message(" setting CMAKE_CUDA_COMPILER to ${CMAKE_CUDA_COMPILER}") -endif() + check_language(CUDA) + if(CMAKE_CUDA_COMPILER) + enable_language(CUDA) + else() + #message(FATAL_ERROR "No CUDA support") + message(WARNING "No CUDA support found") + set(CMAKE_CUDA_COMPILER "/usr/bin/nvcc") + message(" setting CMAKE_CUDA_COMPILER to ${CMAKE_CUDA_COMPILER}") + endif() endif(USE_CUDA) - +find_package(Threads REQUIRED) find_package(PkgConfig REQUIRED) #find_package(MKL CONFIG) @@ -213,11 +217,11 @@ execute_process(COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/plugins -mindepth 2 string(REGEX REPLACE "\n" "; " libextradir "${libextradir}") foreach(lsrcdir IN LISTS libsrcdir libextradir) -string(REGEX REPLACE " " "" lsrcdir "${lsrcdir}") -if (NOT ${lsrcdir} EQUAL "") -message("ADDING SUBDIR = ${lsrcdir}") -add_subdirectory ( ${lsrcdir} ) -endif() + string(REGEX REPLACE " " "" lsrcdir "${lsrcdir}") + if (NOT ${lsrcdir} EQUAL "") + message("ADDING SUBDIR = ${lsrcdir}") + add_subdirectory ( ${lsrcdir} ) + endif() endforeach() # add example module @@ -235,14 +239,16 @@ add_executable(milk src/CLImain.c) set(BUILD_FLAGS "-DPACKAGE_NAME=\\\"milk\\\" -DCONFIGDIR=\\\"${PROJECT_SOURCE_DIR}/config\\\" -DINSTALLDIR=\\\"${CMAKE_INSTALL_PREFIX}\\\" -DSOURCEDIR=\\\"${PROJECT_SOURCE_DIR}\\\" -DABSSRCTOPDIR=\\\"${PROJECT_SOURCE_DIR}\\\" -DPACKAGE_BUGREPORT=\\\"https://github.com/milk-org/milk/issues\\\"" ) -target_link_libraries (milk PUBLIC -${libname} -) - +target_link_libraries(milk PUBLIC ${libname}) if(USE_CUDA) -target_link_libraries (milk PUBLIC ${CUDA_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES}) -set(BUILD_FLAGS "${BUILD_FLAGS} -DHAVE_CUDA" ) + # Link CUDA globally to the executable rather than per module. + find_package(CUDAToolkit 9.0 REQUIRED) + target_link_libraries(milk PUBLIC CUDA::toolkit + PUBLIC CUDA::cusolver + PUBLIC CUDA::cudart + PUBLIC CUDA::cublas) + set(BUILD_FLAGS "${BUILD_FLAGS} -DHAVE_CUDA" ) endif(USE_CUDA) @@ -290,7 +296,7 @@ install(TARGETS milk set(CMAKE_INSTALL_PREFIX_LINK "/usr/local/${PROJECT_NAME}") if(INSTALLMAKEDEFAULT) - install(CODE " + install(CODE " EXECUTE_PROCESS(COMMAND ln -snf ${CMAKE_INSTALL_PREFIX} ${CMAKE_INSTALL_PREFIX_LINK}) ") endif(INSTALLMAKEDEFAULT) @@ -371,7 +377,7 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/milk_config.h if(build_python_module) -add_subdirectory (python_module) + add_subdirectory (python_module) endif() install(TARGETS CLIcore DESTINATION bin) diff --git a/plugins/milk-extra-src/linARfilterPred/CMakeLists.txt b/plugins/milk-extra-src/linARfilterPred/CMakeLists.txt index dca674fd..0ad5719b 100644 --- a/plugins/milk-extra-src/linARfilterPred/CMakeLists.txt +++ b/plugins/milk-extra-src/linARfilterPred/CMakeLists.txt @@ -36,13 +36,9 @@ add_library(${LIBNAME} SHARED ${SOURCEFILES}) if(USE_CUDA) -find_package(CUDA 9.0 REQUIRED) -message(STATUS "Found CUDA ${CUDA_VERSION_STRING} at ${CUDA_TOOLKIT_ROOT_DIR}") -message("---- CUDA_INCLUDE_DIRS = ${CUDA_INCLUDE_DIRS}") -message("---- CUDA_LIBRARIES = ${CUDA_LIBRARIES}" ) -target_include_directories(${LIBNAME} PUBLIC ${CUDA_INCLUDE_DIRS}) -target_link_libraries(${LIBNAME} PRIVATE ${CUDA_LIBRARIES}) -target_compile_options(${LIBNAME} PUBLIC -DHAVE_CUDA) + find_package(CUDAToolkit 9.0 REQUIRED) + target_include_directories(${LIBNAME} PUBLIC ${CUDAToolkit_INCLUDE_DIRS}) + target_compile_options(${LIBNAME} PUBLIC -DHAVE_CUDA) endif(USE_CUDA) diff --git a/plugins/milk-extra-src/linARfilterPred/build_linPF.c b/plugins/milk-extra-src/linARfilterPred/build_linPF.c index 46868b53..f95eb739 100644 --- a/plugins/milk-extra-src/linARfilterPred/build_linPF.c +++ b/plugins/milk-extra-src/linARfilterPred/build_linPF.c @@ -31,16 +31,17 @@ #include "linalgebra/SingularValueDecomp.h" +/* #ifdef HAVE_CUDA -#include -#include -#include -#include -#include -#include -#include "linalgebra/linalgebra.h" + #include + #include + #include + #include + #include + #include + #include "linalgebra/linalgebra.h" #endif - +*/ static char *inname; @@ -703,7 +704,8 @@ static errno_t compute_function() // set flag to compute SVD-based pseudoinverse // stored as psinv // - uint64_t SVDflag = COMPSVD_COMP_PSINV; // | COMPSVD_COMP_CHECKPSINV; // COMPSVD_SKIP_BIGMAT; + uint64_t SVDflag = + COMPSVD_COMP_PSINV; // | COMPSVD_COMP_CHECKPSINV; // COMPSVD_SKIP_BIGMAT; compute_SVD( imgin, @@ -719,17 +721,17 @@ static errno_t compute_function() list_image_ID(); -/* - save_fits("PFmatD", "SVD_PFmatD.fits"); - save_fits("matU", "SVD_matU.fits"); - save_fits("eigenvec", "SVD_eigenvec.fits"); + /* + save_fits("PFmatD", "SVD_PFmatD.fits"); + save_fits("matU", "SVD_matU.fits"); + save_fits("eigenvec", "SVD_eigenvec.fits"); - save_fits("PF_VTmat", "SVD_PF_VTmat.fits"); - save_fits("PFmatC", "SVD_PFmatC.fits"); + save_fits("PF_VTmat", "SVD_PF_VTmat.fits"); + save_fits("PFmatC", "SVD_PFmatC.fits"); - save_fits("psinv", "SVD_psinv.fits"); - save_fits("psinvcheck", "SVD_psinvcheck.fits"); -*/ + save_fits("psinv", "SVD_psinv.fits"); + save_fits("psinvcheck", "SVD_psinvcheck.fits"); + */ } @@ -771,14 +773,15 @@ static errno_t compute_function() uint32_t PForderval = *PForder; // transpost of matC for speed - float *matCtrans = (float*) malloc(sizeof(float)*data.image[IDmatC].md->nelement); + float *matCtrans = (float *) malloc(sizeof(float) * + data.image[IDmatC].md->nelement); for(long ii = 0; ii < data.image[IDmatC].md->size[0]; ii++) { for(long jj = 0; jj < data.image[IDmatC].md->size[1]; jj++) { - matCtrans[ii*data.image[IDmatC].md->size[1] + jj] = - data.image[IDmatC].array.F[jj*data.image[IDmatC].md->size[0] + ii]; + matCtrans[ii * data.image[IDmatC].md->size[1] + jj] = + data.image[IDmatC].array.F[jj * data.image[IDmatC].md->size[0] + ii]; } } diff --git a/plugins/milk-extra-src/linalgebra/CMakeLists.txt b/plugins/milk-extra-src/linalgebra/CMakeLists.txt index 94746c7b..0269580b 100644 --- a/plugins/milk-extra-src/linalgebra/CMakeLists.txt +++ b/plugins/milk-extra-src/linalgebra/CMakeLists.txt @@ -92,34 +92,30 @@ message("---- module linalgebra ------------------") find_package(PkgConfig REQUIRED) if(USE_CUDA) -find_package(CUDA 9.0 REQUIRED) -message(STATUS "Found CUDA ${CUDA_VERSION_STRING} at ${CUDA_TOOLKIT_ROOT_DIR}") -message("---- CUDA_INCLUDE_DIRS = ${CUDA_INCLUDE_DIRS}") -message("---- CUDA_LIBRARIES = ${CUDA_LIBRARIES} ${CUDA_cusolver_LIBRARY}" ) -message("---- CUDA_CUBLAS_LIBRARIES = ${CUDA_CUBLAS_LIBRARIES}" ) -target_include_directories(${LIBNAME} PUBLIC ${CUDA_INCLUDE_DIRS}) -target_link_libraries(${LIBNAME} PRIVATE ${CUDA_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES} ${CUDA_cusolver_LIBRARY}) -target_compile_options(${LIBNAME} PUBLIC -DHAVE_CUDA) + find_package(CUDAToolkit 9.0 REQUIRED) + message(STATUS "Found CUDA ${CUDAToolkit_VERSION} at ${CUDAToolkit_LIBRARY_DIR}") + message("---- CUDA_INCLUDE_DIRS = ${CUDAToolkit_INCLUDE_DIRS}") + target_include_directories(${LIBNAME} PUBLIC ${CUDAToolkit_INCLUDE_DIRS}) + target_link_libraries(${LIBNAME} PRIVATE CUDA::cublas CUDA::cusolver) + target_compile_options(${LIBNAME} PUBLIC -DHAVE_CUDA) + + if(USE_MAGMA) + find_package(PkgConfig REQUIRED) + pkg_check_modules(MAGMA REQUIRED magma) + message("---- MAGMA_LIBRARY_DIRS = ${MAGMA_LIBRARY_DIRS}") + message("---- MAGMA_LIBRARIES = ${MAGMA_LIBRARIES}" ) + message("---- MAGMA_CFLAGS_OTHER = ${MAGMA_CFLAGS_OTHER}" ) + target_include_directories(${LIBNAME} PUBLIC ${MAGMA_INCLUDE_DIRS}) + target_link_directories(${LIBNAME} PUBLIC ${MAGMA_LIBRARY_DIRS}) + target_link_libraries(${LIBNAME} PRIVATE ${MAGMA_LIBRARIES}) + target_compile_options(${LIBNAME} PRIVATE ${MAGMA_CFLAGS_OTHER}) + target_compile_options(${LIBNAME} PUBLIC -DHAVE_CUDA -DHAVE_MAGMA -DUSE_MAGMA) + #target_compile_options(${LIBNAME} PUBLIC -DHAVE_CUDA -DHAVE_MAGMA -DUSE_MAGMA) + endif(USE_MAGMA) endif(USE_CUDA) -if(USE_MAGMA) -find_package(PkgConfig REQUIRED) -pkg_check_modules(MAGMA REQUIRED magma) -message("---- MAGMA_LIBRARY_DIRS = ${MAGMA_LIBRARY_DIRS}") -message("---- MAGMA_LIBRARIES = ${MAGMA_LIBRARIES}" ) -message("---- MAGMA_CFLAGS_OTHER = ${MAGMA_CFLAGS_OTHER}" ) -target_include_directories(${LIBNAME} PUBLIC ${MAGMA_INCLUDE_DIRS}) -target_link_directories(${LIBNAME} PUBLIC ${MAGMA_LIBRARY_DIRS}) -target_link_libraries(${LIBNAME} PRIVATE ${MAGMA_LIBRARIES}) -target_compile_options(${LIBNAME} PRIVATE ${MAGMA_CFLAGS_OTHER}) -target_compile_options(${LIBNAME} PUBLIC -DHAVE_CUDA -DHAVE_MAGMA -DUSE_MAGMA) -#target_compile_options(${LIBNAME} PUBLIC -DHAVE_CUDA -DHAVE_MAGMA -DUSE_MAGMA) -endif(USE_MAGMA) - - - #find_package(PkgConfig REQUIRED) #pkg_check_modules(OPENBLAS openblas) diff --git a/plugins/milk-extra-src/linopt_imtools/CMakeLists.txt b/plugins/milk-extra-src/linopt_imtools/CMakeLists.txt index ae6329ae..ed6f899c 100644 --- a/plugins/milk-extra-src/linopt_imtools/CMakeLists.txt +++ b/plugins/milk-extra-src/linopt_imtools/CMakeLists.txt @@ -60,33 +60,6 @@ target_include_directories(${LIBNAME} PUBLIC $) target_link_libraries(${LIBNAME} PRIVATE ${LINKLIBS}) -if(USE_CUDA) -find_package(CUDA 9.0 REQUIRED) -message(STATUS "Found CUDA ${CUDA_VERSION_STRING} at ${CUDA_TOOLKIT_ROOT_DIR}") -message("---- CUDA_INCLUDE_DIRS = ${CUDA_INCLUDE_DIRS}") -message("---- CUDA_LIBRARIES = ${CUDA_LIBRARIES} ${CUDA_cusolver_LIBRARY}" ) -message("---- CUDA_CUBLAS_LIBRARIES = ${CUDA_CUBLAS_LIBRARIES}" ) -target_include_directories(${LIBNAME} PUBLIC ${CUDA_INCLUDE_DIRS}) -target_link_libraries(${LIBNAME} PRIVATE ${CUDA_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES} ${CUDA_cusolver_LIBRARY}) -target_compile_options(${LIBNAME} PUBLIC -DHAVE_CUDA) -endif(USE_CUDA) - - - -if(USE_MAGMA) -find_package(PkgConfig REQUIRED) -pkg_check_modules(MAGMA REQUIRED magma) -message("---- MAGMA_LIBRARY_DIRS = ${MAGMA_LIBRARY_DIRS}") -message("---- MAGMA_LIBRARIES = ${MAGMA_LIBRARIES}" ) -message("---- MAGMA_CFLAGS_OTHER = ${MAGMA_CFLAGS_OTHER}" ) -target_include_directories(${LIBNAME} PUBLIC ${MAGMA_INCLUDE_DIRS}) -target_link_directories(${LIBNAME} PUBLIC ${MAGMA_LIBRARY_DIRS}) -target_link_libraries(${LIBNAME} PRIVATE ${MAGMA_LIBRARIES}) -target_compile_options(${LIBNAME} PRIVATE ${MAGMA_CFLAGS_OTHER}) -target_compile_options(${LIBNAME} PUBLIC -DHAVE_CUDA -DHAVE_MAGMA -DUSE_MAGMA) -#target_compile_options(${LIBNAME} PUBLIC -DHAVE_CUDA -DHAVE_MAGMA -DUSE_MAGMA) -endif(USE_MAGMA) - install(TARGETS ${LIBNAME} EXPORT milkTargets DESTINATION lib) install(FILES ${SRCNAME}.h ${INCLUDEFILES} DESTINATION include/${SRCNAME}) diff --git a/src/ImageStreamIO b/src/ImageStreamIO index a70528c4..a5e46461 160000 --- a/src/ImageStreamIO +++ b/src/ImageStreamIO @@ -1 +1 @@ -Subproject commit a70528c45e1be9dc90b3d2a2118530f097cc2484 +Subproject commit a5e46461425600216eeb0c4bd19efb90e4857af3