From 601cd64a26786cf27a4ea1083bca146094909799 Mon Sep 17 00:00:00 2001 From: Daniil Kazantsev Date: Mon, 21 May 2018 12:51:20 +0100 Subject: mex-installers updated, Windows support --- Wrappers/Matlab/mex_compile/compileCPU_mex.m | 53 ------------ Wrappers/Matlab/mex_compile/compileCPU_mex_Linux.m | 55 ++++++++++++ .../Matlab/mex_compile/compileCPU_mex_WINDOWS.m | 99 ++++++++++++++++++++++ Wrappers/Matlab/mex_compile/compileGPU_mex.m | 15 ++-- 4 files changed, 163 insertions(+), 59 deletions(-) delete mode 100644 Wrappers/Matlab/mex_compile/compileCPU_mex.m create mode 100644 Wrappers/Matlab/mex_compile/compileCPU_mex_Linux.m create mode 100644 Wrappers/Matlab/mex_compile/compileCPU_mex_WINDOWS.m diff --git a/Wrappers/Matlab/mex_compile/compileCPU_mex.m b/Wrappers/Matlab/mex_compile/compileCPU_mex.m deleted file mode 100644 index 19eb301..0000000 --- a/Wrappers/Matlab/mex_compile/compileCPU_mex.m +++ /dev/null @@ -1,53 +0,0 @@ -% execute this mex file in Matlab once - -pathcopyFrom = sprintf(['..' filesep '..' filesep '..' filesep 'Core' filesep 'regularisers_CPU'], 1i); -pathcopyFrom1 = sprintf(['..' filesep '..' filesep '..' filesep 'Core' filesep 'CCPiDefines.h'], 1i); -pathcopyFrom2 = sprintf(['..' filesep '..' filesep '..' filesep 'Core' filesep 'inpainters_CPU'], 1i); - -copyfile(pathcopyFrom, 'regularisers_CPU'); -copyfile(pathcopyFrom1, 'regularisers_CPU'); -copyfile(pathcopyFrom2, 'regularisers_CPU'); - -cd regularisers_CPU - -Pathmove = sprintf(['..' filesep 'installed' filesep], 1i); - -fprintf('%s \n', 'Compiling CPU regularisers...'); -mex ROF_TV.c ROF_TV_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" -movefile('ROF_TV.mex*',Pathmove); - -mex FGP_TV.c FGP_TV_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" -movefile('FGP_TV.mex*',Pathmove); - -mex SB_TV.c SB_TV_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" -movefile('SB_TV.mex*',Pathmove); - -mex FGP_dTV.c FGP_dTV_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" -movefile('FGP_dTV.mex*',Pathmove); - -mex TNV.c TNV_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" -movefile('TNV.mex*',Pathmove); - -mex NonlDiff.c Diffusion_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" -movefile('NonlDiff.mex*',Pathmove); - -mex Diffusion_4thO.c Diffus4th_order_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" -movefile('Diffusion_4thO.mex*',Pathmove); - -mex TV_energy.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" -movefile('TV_energy.mex*',Pathmove); - -%############Inpainters##############% -mex NonlDiff_Inp.c Diffusion_Inpaint_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" -movefile('NonlDiff_Inp.mex*',Pathmove); - -mex NonlocalMarching_Inpaint.c NonlocalMarching_Inpaint_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" -movefile('NonlocalMarching_Inpaint.mex*',Pathmove); - -delete SB_TV_core* ROF_TV_core* FGP_TV_core* FGP_dTV_core* TNV_core* utils* Diffusion_core* Diffus4th_order_core* CCPiDefines.h -delete Diffusion_Inpaint_core* NonlocalMarching_Inpaint_core* -fprintf('%s \n', 'Regularisers successfully compiled!'); - -pathA2 = sprintf(['..' filesep '..' filesep], 1i); -cd(pathA2); -cd demos diff --git a/Wrappers/Matlab/mex_compile/compileCPU_mex_Linux.m b/Wrappers/Matlab/mex_compile/compileCPU_mex_Linux.m new file mode 100644 index 0000000..82b681a --- /dev/null +++ b/Wrappers/Matlab/mex_compile/compileCPU_mex_Linux.m @@ -0,0 +1,55 @@ +% execute this mex file on Linux in Matlab once + +fsep = '/'; + +pathcopyFrom = sprintf(['..' fsep '..' fsep '..' fsep 'Core' fsep 'regularisers_CPU'], 1i); +pathcopyFrom1 = sprintf(['..' fsep '..' fsep '..' fsep 'Core' fsep 'CCPiDefines.h'], 1i); +pathcopyFrom2 = sprintf(['..' fsep '..' fsep '..' fsep 'Core' fsep 'inpainters_CPU'], 1i); + +copyfile(pathcopyFrom, 'regularisers_CPU'); +copyfile(pathcopyFrom1, 'regularisers_CPU'); +copyfile(pathcopyFrom2, 'regularisers_CPU'); + +cd regularisers_CPU + +Pathmove = sprintf(['..' fsep 'installed' fsep], 1i); + +fprintf('%s \n', 'Compiling CPU regularisers...'); +mex ROF_TV.c ROF_TV_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" +movefile('ROF_TV.mex*',Pathmove); + +mex FGP_TV.c FGP_TV_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" +movefile('FGP_TV.mex*',Pathmove); + +mex SB_TV.c SB_TV_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" +movefile('SB_TV.mex*',Pathmove); + +mex FGP_dTV.c FGP_dTV_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" +movefile('FGP_dTV.mex*',Pathmove); + +mex TNV.c TNV_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" +movefile('TNV.mex*',Pathmove); + +mex NonlDiff.c Diffusion_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" +movefile('NonlDiff.mex*',Pathmove); + +mex Diffusion_4thO.c Diffus4th_order_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" +movefile('Diffusion_4thO.mex*',Pathmove); + +mex TV_energy.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" +movefile('TV_energy.mex*',Pathmove); + +%############Inpainters##############% +mex NonlDiff_Inp.c Diffusion_Inpaint_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" +movefile('NonlDiff_Inp.mex*',Pathmove); + +mex NonlocalMarching_Inpaint.c NonlocalMarching_Inpaint_core.c utils.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp" +movefile('NonlocalMarching_Inpaint.mex*',Pathmove); + +delete SB_TV_core* ROF_TV_core* FGP_TV_core* FGP_dTV_core* TNV_core* utils* Diffusion_core* Diffus4th_order_core* CCPiDefines.h +delete Diffusion_Inpaint_core* NonlocalMarching_Inpaint_core* +fprintf('%s \n', 'Regularisers successfully compiled!'); + +pathA2 = sprintf(['..' fsep '..' fsep], 1i); +cd(pathA2); +cd demos diff --git a/Wrappers/Matlab/mex_compile/compileCPU_mex_WINDOWS.m b/Wrappers/Matlab/mex_compile/compileCPU_mex_WINDOWS.m new file mode 100644 index 0000000..629a346 --- /dev/null +++ b/Wrappers/Matlab/mex_compile/compileCPU_mex_WINDOWS.m @@ -0,0 +1,99 @@ +% execute this mex file on Windows in Matlab once + +% >>>>>>>>>>>>>>>>>>>>>>>>>>>>> +% I've been able to compile on Windows 7 with MinGW and Matlab 2016b, however, +% not sure if openmp is enabled after the compilation. + +% Here I present two ways how software can be compiled, if you have some +% other suggestions please contact me at dkazanc@hotmail.com +% >>>>>>>>>>>>>>>>>>>>>>>>>>>>> + +fsep = '/'; + +pathcopyFrom = sprintf(['..' fsep '..' fsep '..' fsep 'Core' fsep 'regularisers_CPU'], 1i); +pathcopyFrom1 = sprintf(['..' fsep '..' fsep '..' fsep 'Core' fsep 'CCPiDefines.h'], 1i); +pathcopyFrom2 = sprintf(['..' fsep '..' fsep '..' fsep 'Core' fsep 'inpainters_CPU'], 1i); + +copyfile(pathcopyFrom, 'regularisers_CPU'); +copyfile(pathcopyFrom1, 'regularisers_CPU'); +copyfile(pathcopyFrom2, 'regularisers_CPU'); + +cd regularisers_CPU + +Pathmove = sprintf(['..' fsep 'installed' fsep], 1i); + +fprintf('%s \n', 'Compiling CPU regularisers...'); +mex ROF_TV.c ROF_TV_core.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99" +movefile('ROF_TV.mex*',Pathmove); + +mex FGP_TV.c FGP_TV_core.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99" +movefile('FGP_TV.mex*',Pathmove); + +mex SB_TV.c SB_TV_core.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99" +movefile('SB_TV.mex*',Pathmove); + +mex FGP_dTV.c FGP_dTV_core.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99" +movefile('FGP_dTV.mex*',Pathmove); + +mex TNV.c TNV_core.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99" +movefile('TNV.mex*',Pathmove); + +mex NonlDiff.c Diffusion_core.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99" +movefile('NonlDiff.mex*',Pathmove); + +mex Diffusion_4thO.c Diffus4th_order_core.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99" +movefile('Diffusion_4thO.mex*',Pathmove); + +mex TV_energy.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99" +movefile('TV_energy.mex*',Pathmove); + +%############Inpainters##############% +mex NonlDiff_Inp.c Diffusion_Inpaint_core.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99" +movefile('NonlDiff_Inp.mex*',Pathmove); + +mex NonlocalMarching_Inpaint.c NonlocalMarching_Inpaint_core.c utils.c COMPFLAGS="\$COMPFLAGS -fopenmp -Wall -std=c99" +movefile('NonlocalMarching_Inpaint.mex*',Pathmove); + +delete SB_TV_core* ROF_TV_core* FGP_TV_core* FGP_dTV_core* TNV_core* utils* Diffusion_core* Diffus4th_order_core* CCPiDefines.h +delete Diffusion_Inpaint_core* NonlocalMarching_Inpaint_core* +fprintf('%s \n', 'Regularisers successfully compiled!'); +%% +%%% The second approach to compile using TDM-GCC which follows this +%%% discussion: +%%% https://uk.mathworks.com/matlabcentral/answers/279171-using-mingw-compiler-and-open-mp#comment_359122 +%%% 1. Install TDM-GCC independently from http://tdm-gcc.tdragon.net/ (I installed 5.1.0) +%%% Install openmp version: http://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%205%20series/5.1.0-tdm64-1/gcc-5.1.0-tdm64-1-openmp.zip/download +%%% 2. Link til libgomp.a in that installation when compilling your mex file. + +%%% assuming you unzipped TDM GCC (OpenMp) in folder TDMGCC on C drive, uncomment +%%% bellow +% fprintf('%s \n', 'Compiling CPU regularisers...'); +% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" ROF_TV.c ROF_TV_core.c utils.c +% movefile('ROF_TV.mex*',Pathmove); +% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" FGP_TV.c FGP_TV_core.c utils.c +% movefile('FGP_TV.mex*',Pathmove); +% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" SB_TV.c SB_TV_core.c utils.c +% movefile('SB_TV.mex*',Pathmove); +% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" FGP_dTV.c FGP_dTV_core.c utils.c +% movefile('FGP_dTV.mex*',Pathmove); +% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" TNV.c TNV_core.c utils.c +% movefile('TNV.mex*',Pathmove); +% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" NonlDiff.c Diffusion_core.c utils.c +% movefile('NonlDiff.mex*',Pathmove); +% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" Diffusion_4thO.c Diffus4th_order_core.c utils.c +% movefile('Diffusion_4thO.mex*',Pathmove); +% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" TV_energy.c utils.c +% movefile('TV_energy.mex*',Pathmove); +% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" NonlDiff_Inp.c Diffusion_Inpaint_core.c utils.c +% movefile('NonlDiff_Inp.mex*',Pathmove); +% mex C:\TDMGCC\lib\gcc\x86_64-w64-mingw32\5.1.0\libgomp.a CXXFLAGS="$CXXFLAGS -std=c++11 -fopenmp" NonlocalMarching_Inpaint.c NonlocalMarching_Inpaint_core.c utils.c +% movefile('NonlocalMarching_Inpaint.mex*',Pathmove); +% delete SB_TV_core* ROF_TV_core* FGP_TV_core* FGP_dTV_core* TNV_core* utils* Diffusion_core* Diffus4th_order_core* CCPiDefines.h +% delete Diffusion_Inpaint_core* NonlocalMarching_Inpaint_core* +% fprintf('%s \n', 'Regularisers successfully compiled!'); +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%pathA2 = sprintf(['..' fsep '..' fsep], 1i); +%cd(pathA2); +%cd demos diff --git a/Wrappers/Matlab/mex_compile/compileGPU_mex.m b/Wrappers/Matlab/mex_compile/compileGPU_mex.m index 6b69c34..a4a636e 100644 --- a/Wrappers/Matlab/mex_compile/compileGPU_mex.m +++ b/Wrappers/Matlab/mex_compile/compileGPU_mex.m @@ -8,18 +8,21 @@ % ! paths to matlab and CUDA sdk can be different, modify accordingly ! % Tested on Ubuntu 16.04/MATLAB 2016b/cuda7.5/gcc4.9 -% It hasn't been tested on Windows, please contact me if you'll be able to -% install it on Windows and I include it into the release. -pathcopyFrom = sprintf(['..' filesep '..' filesep '..' filesep 'Core' filesep 'regularisers_GPU'], 1i); -pathcopyFrom1 = sprintf(['..' filesep '..' filesep '..' filesep 'Core' filesep 'CCPiDefines.h'], 1i); +% It HAS NOT been tested on Windows, please contact me if you'll be able to +% install software on Windows and I greatefully include it into the release. + +fsep = '/'; + +pathcopyFrom = sprintf(['..' fsep '..' fsep '..' fsep 'Core' fsep 'regularisers_GPU'], 1i); +pathcopyFrom1 = sprintf(['..' fsep '..' fsep '..' fsep 'Core' fsep 'CCPiDefines.h'], 1i); copyfile(pathcopyFrom, 'regularisers_GPU'); copyfile(pathcopyFrom1, 'regularisers_GPU'); cd regularisers_GPU -Pathmove = sprintf(['..' filesep 'installed' filesep], 1i); +Pathmove = sprintf(['..' fsep 'installed' fsep], 1i); fprintf('%s \n', 'Compiling GPU regularisers (CUDA)...'); !/usr/local/cuda/bin/nvcc -O0 -c TV_ROF_GPU_core.cu -Xcompiler -fPIC -I~/SOFT/MATLAB9/extern/include/ @@ -49,6 +52,6 @@ movefile('Diffusion_4thO_GPU.mex*',Pathmove); delete TV_ROF_GPU_core* TV_FGP_GPU_core* TV_SB_GPU_core* dTV_FGP_GPU_core* NonlDiff_GPU_core* Diffus_4thO_GPU_core* CCPiDefines.h fprintf('%s \n', 'All successfully compiled!'); -pathA2 = sprintf(['..' filesep '..' filesep], 1i); +pathA2 = sprintf(['..' fsep '..' fsep], 1i); cd(pathA2); cd demos \ No newline at end of file -- cgit v1.2.3