From e6cb12cc6603cff6e8837f7a922a740fb2ee3b02 Mon Sep 17 00:00:00 2001 From: Edoardo Pasca Date: Sun, 5 Aug 2018 13:25:46 +0100 Subject: add all CPU Matlab wrappers --- Wrappers/Matlab/CMakeLists.txt | 112 ++++++++++++++++++++++++++++++++++++----- recipes/regularisers/bld.bat | 2 +- 2 files changed, 100 insertions(+), 14 deletions(-) diff --git a/Wrappers/Matlab/CMakeLists.txt b/Wrappers/Matlab/CMakeLists.txt index 349baf6..012bf96 100755 --- a/Wrappers/Matlab/CMakeLists.txt +++ b/Wrappers/Matlab/CMakeLists.txt @@ -1,29 +1,115 @@ project(regulariserMatlab) -message('<<<<<<<<<<>>>>>>>>>>>>') -message('Compiling ROF-TV...') -#mex ROF_TV.c ROF_TV_core.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99" -#movefile('ROF_TV.mex*',Pathmove); +find_package(Matlab REQUIRED COMPONENTS MAIN_PROGRAM MX_LIBRARY ENG_LIBRARY ) -find_package(Matlab COMPONENTS MAIN_PROGRAM MX_LIBRARY ENG_LIBRARY ) -message ("Matlab mex library " ${Matlab_LIBRARIES}) +#C:\Users\ofn77899\Documents\Projects\CCPi\GitHub\CCPi-FISTA_Reconstruction\Core\regularisers_CPU +# matlab_add_mex( + # NAME CPU_ROF + # SRC + # ${CMAKE_SOURCE_DIR}/Wrappers/Matlab/mex_compile/regularisers_CPU/ROF_TV.c + # LINK_TO cilreg ${Matlab_LIBRARIES} + # ) + +# target_include_directories(CPU_ROF + # PUBLIC ${CMAKE_SOURCE_DIR}/Core/regularisers_CPU + # ${CMAKE_SOURCE_DIR}/Core/regularisers_GPU + # ${CMAKE_SOURCE_DIR}/Core/inpainters_CPU + # ${CMAKE_SOURCE_DIR}/Core/ + # ${MATLAB_INCLUDE_DIR}) + + # matlab_add_mex( + # NAME CPU_TNV + # SRC + # ${CMAKE_SOURCE_DIR}/Wrappers/Matlab/mex_compile/regularisers_CPU/TNV.c + # LINK_TO cilreg ${Matlab_LIBRARIES} + # ) + +# target_include_directories(CPU_TNV + # PUBLIC ${CMAKE_SOURCE_DIR}/Core/regularisers_CPU + # ${CMAKE_SOURCE_DIR}/Core/regularisers_GPU + # ${CMAKE_SOURCE_DIR}/Core/inpainters_CPU + # ${CMAKE_SOURCE_DIR}/Core/ + # ${MATLAB_INCLUDE_DIR}) + +#set (CPU_MEX_FILES "regularisers_CPU/TNV.c;regularisers_CPU/ROF_TV.c") +#set (MEX_TARGETS "CPU_TNV;CPU_ROF") +#list(APPEND MEX_TARGETS "CPU_TNV") +#list(APPEND MEX_TARGETS "CPU_ROF") +set (CPU_TARGETS "CPU_TNV;CPU_ROF") +file(GLOB CPU_MEX_FILES + "${CMAKE_SOURCE_DIR}/Wrappers/Matlab/mex_compile/regularisers_CPU/*.c" + "${CMAKE_SOURCE_DIR}/Wrappers/Matlab/mex_compile/inpainters_CPU/*.c" +) +list(LENGTH CPU_MEX_FILES num) -#C:\Users\ofn77899\Documents\Projects\CCPi\GitHub\CCPi-FISTA_Reconstruction\Core\regularisers_CPU -matlab_add_mex( - NAME MatlabWrapper + +MATH(EXPR num "${num}-1") +#set(num "-1") + +foreach(tgt RANGE ${num}) + message("number " ${tgt}) + #list(GET CPU_TARGETS ${tgt} current_target) + list(GET CPU_MEX_FILES ${tgt} current_file) + get_filename_component(current_target ${current_file} NAME) + message("matlab_add_mex " ${current_target}) + matlab_add_mex( + NAME ${current_target} SRC - #${CMAKE_SOURCE_DIR}/Wrappers/Matlab/mex_compile/regularisers_CPU/ROF_TV.c - ${CMAKE_SOURCE_DIR}/Wrappers/Matlab/mex_compile/regularisers_CPU/TNV.c + ${current_file} LINK_TO cilreg ${Matlab_LIBRARIES} ) -target_include_directories(MatlabWrapper +target_include_directories(${current_target} PUBLIC ${CMAKE_SOURCE_DIR}/Core/regularisers_CPU ${CMAKE_SOURCE_DIR}/Core/regularisers_GPU ${CMAKE_SOURCE_DIR}/Core/inpainters_CPU ${CMAKE_SOURCE_DIR}/Core/ - ${MATLAB_INCLUDE_DIR}) \ No newline at end of file + ${MATLAB_INCLUDE_DIR}) + + list(APPEND CPU_MEX_TARGETS ${current_target}) +endforeach() + +add_custom_target(MatlabWrapper DEPENDS ${CPU_MEX_TARGETS}) + +find_package(CUDA) +if (CUDA_FOUND) + file(GLOB GPU_MEX_FILES + "${CMAKE_SOURCE_DIR}/Wrappers/Matlab/mex_compile/regularisers_GPU/*.c" + ) + + list(LENGTH GPU_MEX_FILES num) + + + MATH(EXPR num "${num}-1") +#set(num "-1") + + foreach(tgt RANGE ${num}) + message("number " ${tgt}) + #list(GET CPU_TARGETS ${tgt} current_target) + list(GET GPU_MEX_FILES ${tgt} current_file) + get_filename_component(current_target ${current_file} NAME) + message("matlab_add_mex " ${current_target}) + matlab_add_mex( + NAME ${current_target} + SRC + ${current_file} + LINK_TO cilreg ${Matlab_LIBRARIES} + ) + + target_include_directories(${current_target} + PUBLIC ${CMAKE_SOURCE_DIR}/Core/regularisers_CPU + ${CMAKE_SOURCE_DIR}/Core/regularisers_GPU + ${CMAKE_SOURCE_DIR}/Core/inpainters_CPU + ${CMAKE_SOURCE_DIR}/Core/ + ${MATLAB_INCLUDE_DIR}) + + list(APPEND CPU_MEX_TARGETS ${current_target}) + endforeach() + + add_custom_target(MatlabWrapperGPU DEPENDS ${GPU_MEX_TARGETS}) + +endif() diff --git a/recipes/regularisers/bld.bat b/recipes/regularisers/bld.bat index 6f2f7e7..43a5286 100644 --- a/recipes/regularisers/bld.bat +++ b/recipes/regularisers/bld.bat @@ -10,7 +10,7 @@ cd "%SRC_DIR%\build" echo "we should be in %SRC_DIR%\build" -cmake -G "NMake Makefiles" -DLIBRARY_LIB="%CONDA_PREFIX%\lib" -DLIBRARY_INC="%CONDA_PREFIX%" -DCMAKE_INSTALL_PREFIX="%PREFIX%\Library" "%SRC_DIR%\build" +cmake -G "NMake Makefiles" "%RECIPE_DIR%\..\..\" -DLIBRARY_LIB="%CONDA_PREFIX%\lib" -DLIBRARY_INC="%CONDA_PREFIX%" -DCMAKE_INSTALL_PREFIX="%PREFIX%\Library" -DCONDA_BUILD=ON -DBUILD_WRAPPERS=OFF ::-DBOOST_LIBRARYDIR="%CONDA_PREFIX%\Library\lib" -DBOOST_INCLUDEDIR="%CONDA_PREFIX%\Library\include" -DBOOST_ROOT="%CONDA_PREFIX%\Library\lib" -- cgit v1.2.3