Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/milk-org/milk into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
oguyon committed Dec 16, 2024
2 parents 6da3eb6 + 879cf3b commit ce32f41
Show file tree
Hide file tree
Showing 14 changed files with 184 additions and 181 deletions.
56 changes: 31 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14)
cmake_minimum_required(VERSION 3.17)

project(milk LANGUAGES C)

Expand All @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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)


Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 3 additions & 7 deletions plugins/milk-extra-src/linARfilterPred/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
45 changes: 24 additions & 21 deletions plugins/milk-extra-src/linARfilterPred/build_linPF.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@

#include "linalgebra/SingularValueDecomp.h"

/*
#ifdef HAVE_CUDA
#include <cublas_v2.h>
#include <cuda_runtime.h>
#include <cuda_runtime_api.h>
#include <cusolverDn.h>
#include <device_types.h>
#include <pthread.h>
#include "linalgebra/linalgebra.h"
#include <cublas_v2.h>
#include <cuda_runtime.h>
#include <cuda_runtime_api.h>
#include <cusolverDn.h>
#include <device_types.h>
#include <pthread.h>
#include "linalgebra/linalgebra.h"
#endif

*/

static char *inname;

Expand Down Expand Up @@ -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,
Expand All @@ -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");
*/
}


Expand Down Expand Up @@ -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];
}
}

Expand Down
44 changes: 20 additions & 24 deletions plugins/milk-extra-src/linalgebra/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
27 changes: 0 additions & 27 deletions plugins/milk-extra-src/linopt_imtools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,33 +60,6 @@ target_include_directories(${LIBNAME} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_S
$<INSTALL_INTERFACE:include>)
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})
Expand Down
Loading

0 comments on commit ce32f41

Please sign in to comment.