Skip to content

Commit

Permalink
Fix Mac compatibility
Browse files Browse the repository at this point in the history
Changed unix and mac checking, as unix=linux&mac
Aslo added xml.
  • Loading branch information
AnderBiguri authored and AnderBiguri committed Oct 5, 2016
1 parent c217793 commit 87110b9
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 30 deletions.
28 changes: 15 additions & 13 deletions Compile.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,10 @@
mex ./Source/minTV.cpp ./Source/POCS_TV.cu -outdir ./Mex_files/win32
mex ./Source/tvDenoise.cpp ./Source/tvdenoising.cu -outdir ./Mex_files/win32
end
elseif isunix
if ~isempty(strfind(computer('arch'),'64'))
mex -largeArrayDims ./Source/Ax.cpp ./Source/ray_interpolated_projection.cu ./Source/Siddon_projection.cu ./Source/ray_interpolated_projection_parallel.cu ./Source/Siddon_projection_parallel.cu -outdir ./Mex_files/linux64
mex -largeArrayDims ./Source/Atb.cpp ./Source/voxel_backprojection.cu ./Source/voxel_backprojection2.cu ./Source/voxel_backprojection_parallel.cu -outdir ./Mex_files/linux64
mex -largeArrayDims ./Source/minTV.cpp ./Source/POCS_TV.cu -outdir ./Mex_files/linux64
mex -largeArrayDims ./Source/tvDenoise.cpp ./Source/tvdenoising.cu -outdir ./Mex_files/linux64
else
mex ./Source/Ax.cpp ./Source/ray_interpolated_projection.cu ./Source/Siddon_projection.cu ./Source/ray_interpolated_projection_parallel.cu ./Source/Siddon_projection_parallel.cu -outdir ./Mex_files/linux32
mex ./Source/Atb.cpp ./Source/voxel_backprojection.cu ./Source/voxel_backprojection2.cu ./Source/voxel_backprojection_parallel.cu -outdir ./Mex_files/linux32
mex ./Source/minTV.cpp ./Source/POCS_TV.cu -outdir ./Mex_files/linux32
mex ./Source/tvDenoise.cpp ./Source/tvdenoising.cu -outdir ./Mex_files/linux32
end

elseif ismac
if ~isempty(strfind(computer('arch'),'64'))
disp('compiling for mac 64')
mex -largeArrayDims ./Source/Ax.cpp ./Source/ray_interpolated_projection.cu ./Source/Siddon_projection.cu ./Source/ray_interpolated_projection_parallel.cu ./Source/Siddon_projection_parallel.cu -outdir ./Mex_files/mac64
mex -largeArrayDims ./Source/Atb.cpp ./Source/voxel_backprojection.cu ./Source/voxel_backprojection2.cu ./Source/voxel_backprojection_parallel.cu -outdir ./Mex_files/mac64
mex -largeArrayDims ./Source/minTV.cpp ./Source/POCS_TV.cu -outdir ./Mex_files/mac64
Expand All @@ -69,11 +58,24 @@
mex ./Source/minTV.cpp ./Source/POCS_TV.cu -outdir ./Mex_files/mac32
mex ./Source/tvDenoise.cpp ./Source/tvdenoising.cu -outdir ./Mex_files/mac32
end

elseif isunix
if ~isempty(strfind(computer('arch'),'64'))
mex -largeArrayDims ./Source/Ax.cpp ./Source/ray_interpolated_projection.cu ./Source/Siddon_projection.cu ./Source/ray_interpolated_projection_parallel.cu ./Source/Siddon_projection_parallel.cu -outdir ./Mex_files/linux64
mex -largeArrayDims ./Source/Atb.cpp ./Source/voxel_backprojection.cu ./Source/voxel_backprojection2.cu ./Source/voxel_backprojection_parallel.cu -outdir ./Mex_files/linux64
mex -largeArrayDims ./Source/minTV.cpp ./Source/POCS_TV.cu -outdir ./Mex_files/linux64
mex -largeArrayDims ./Source/tvDenoise.cpp ./Source/tvdenoising.cu -outdir ./Mex_files/linux64
else
mex ./Source/Ax.cpp ./Source/ray_interpolated_projection.cu ./Source/Siddon_projection.cu ./Source/ray_interpolated_projection_parallel.cu ./Source/Siddon_projection_parallel.cu -outdir ./Mex_files/linux32
mex ./Source/Atb.cpp ./Source/voxel_backprojection.cu ./Source/voxel_backprojection2.cu ./Source/voxel_backprojection_parallel.cu -outdir ./Mex_files/linux32
mex ./Source/minTV.cpp ./Source/POCS_TV.cu -outdir ./Mex_files/linux32
mex ./Source/tvDenoise.cpp ./Source/tvdenoising.cu -outdir ./Mex_files/linux32
end
end





disp('')
disp('Compilation complete')
disp('Compilation complete')
37 changes: 25 additions & 12 deletions InitTIGRE.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,26 @@
addpath(genpath('./Test_data'));

% different arch versions
if ~isempty(strfind(computer('arch'),'64'))
addpath('./Mex_files/win64');
if ispc
if ~isempty(strfind(computer('arch'),'64'))
addpath('./Mex_files/win64');
else
addpath('./Mex_files/win32');
end
elseif ismac
if ~isempty(strfind(computer('arch'),'64'))
addpath('./Mex_files/mac64');
else
addpath('./Mex_files/mac32');
end
else
addpath('./Mex_files/win32');
if ~isempty(strfind(computer('arch'),'64'))
addpath('./Mex_files/linux64');
else
addpath('./Mex_files/linux32');
end
end

addpath('./Demos');

% Perceptually uniform colormaps
Expand All @@ -40,25 +54,24 @@
addpath('./Third_party_tools/sec2hours');
addpath('./Third_party_tools/readMHD');


if ispc
if ~isempty(strfind(computer('arch'),'64'))
addpath('./Mex_files/win64');
else
addpath('./Mex_files/win32');
end
elseif isunix
if ~isempty(strfind(computer('arch'),'64'))
addpath('./Mex_files/linux64');
else
addpath('./Mex_files/linux32');
end
elseif ismac
if ~isempty(strfind(computer('arch'),'64'))
addpath('./Mex_files/mac64');
else
addpath('./Mex_files/mac32');
end
else
if ~isempty(strfind(computer('arch'),'64'))
addpath('./Mex_files/linux64');
else
addpath('./Mex_files/linux32');
end
end

if ispc
Expand All @@ -75,4 +88,4 @@
warning('TIGRE needs a big amount of memory, be careful when running big images.')
end

clear all;
clear all;
2 changes: 1 addition & 1 deletion Source/POCS_TV.cu
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ do { \
cudaMemcpy(dst, d_image, mem_size, cudaMemcpyDeviceToHost);
cudaCheckErrors("Copy result back");

cudaFree(b);
cudaFree(d_image);
cudaFree(d_norm2aux);
cudaFree(d_dimgTV);
cudaFree(d_norm2);
Expand Down
8 changes: 4 additions & 4 deletions Source/Siddon_projection_parallel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ __global__ void kernelPixelDetector_parallel( Geometry geo,

// Compute max/min image INDEX for intersection eq(11-19)
// Discussion about ternary operator in CUDA: https://stackoverflow.com/questions/7104384/in-cuda-why-is-a-b010-more-efficient-than-an-if-else-version
float imin,imax,jmin,jmax,kmin,kmax;
float imin,imax,jmin,jmax;
// for X
if( source.x<pixel1D.x){
imin=(am==axm)? 1 : ceil (source.x+am*ray.x);
Expand All @@ -197,7 +197,7 @@ __global__ void kernelPixelDetector_parallel( Geometry geo,
// }

// get intersection point N1. eq(20-21) [(also eq 9-10)]
float ax,ay,az;
float ax,ay;
ax=(source.x<pixel1D.x)? (imin-source.x)/ray.x : (imax-source.x)/ray.x;
ay=(source.y<pixel1D.y)? (jmin-source.y)/ray.y : (jmax-source.y)/ray.y;
// az=(source.z<pixel1D.z)? (kmin-source.z)/ray.z : (kmax-source.z)/ray.z;
Expand All @@ -214,12 +214,12 @@ __global__ void kernelPixelDetector_parallel( Geometry geo,
// Initialize
float ac=am;
//eq (28), unit alphas
float axu,ayu,azu;
float axu,ayu;
axu=1/abs(ray.x);
ayu=1/abs(ray.y);
// azu=1/abs(ray.z);
// eq(29), direction of update
float iu,ju,ku;
float iu,ju;
iu=(source.x< pixel1D.x)? 1 : -1;
ju=(source.y< pixel1D.y)? 1 : -1;
// ku=(source.z< pixel1D.z)? 1 : -1;
Expand Down
91 changes: 91 additions & 0 deletions mex_CUDA_maci64.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2013 The MathWorks, Inc. -->
<config
Name="nvcc"
ShortName="nvcc"
Manufacturer="NVIDIA"
Version=""
Language="CUDA"
Priority="A"
Location="$NVCC" >
<Details
CompilerExecutable="$CXX"
CompilerDefines="$DEFINES"
CompilerFlags="$CXXFLAGS"
OptimizationFlags="$CXXOPTIMFLAGS"
DebugFlags="$CXXDEBUGFLAGS"
IncludeFlags="$INCLUDE"
LinkerLibraries="$LINKLIBS"
LinkerOptimizationFlags="$LDOPTIMFLAGS"
LinkerDebugFlags="$LDDEBUGFLAGS"

CompilerDefineFormatter="-D%s"
LinkerLibrarySwitchFormatter="-l%s"
LinkerPathFormatter="-L%s"
/>
<vars
CMDLINE1="$CXX -c $DEFINES $INCLUDE $NVCCFLAGS $CXXFLAGS $OPTIM $SRC -o $OBJ"
CMDLINE2="$LDXX $LDFLAGS $LINKOPTIM $LINKEXPORT $OBJS $CXXLIBS $LINKLIBS -o $EXE"
CMDLINE3="rm -f $OBJ"

CXX="$NVCC"
DEFINES="$MATLABMEX"
MATLABMEX="-DMATLAB_MEX_FILE"
NVCCFLAGS="-gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_50,code=sm_50 -m 64 $NVCC_FLAGS"
CXXFLAGS="--compiler-bindir=$CLANG_COMPILER --compiler-options=-fno-common,-arch,$ARCHS,-mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET,-fexceptions,-fPIC,-fno-omit-frame-pointer,-pthread,-isysroot,$ISYSROOT"
INCLUDE="-I&quot;$MATLABROOT/extern/include&quot; -I&quot;$MATLABROOT/simulink/include&quot; -I&quot;$MATLABROOT/toolbox/distcomp/gpu/extern/include/&quot;"
CXXOPTIMFLAGS="-O2 -DNDEBUG"
CXXDEBUGFLAGS="-g"
ARCHS="x86_64"

LDXX="$XCRUN_DIR/xcrun clang++"
LDFLAGS="-stdlib=libstdc++ -pthread -Wl,-twolevel_namespace -undefined error -arch $ARCHS -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -Wl,-syslibroot,$ISYSROOT $LDBUNDLE $LINKEXPORT"
LDBUNDLE="-bundle"
LINKEXPORT="-Wl,-exported_symbols_list,&quot;$MATLABROOT/extern/lib/$ARCH/mexFunction.map&quot;"
LINKLIBS="-L&quot;$MATLABROOT/bin/$ARCH&quot; -lmx -lmex -lmat -lm -lmwgpu -lcudart"
LDOPTIMFLAGS="-O"
LDDEBUGFLAGS="-g"

OBJEXT=".o"
LDEXT=".mexmaci64"
MACOSX_DEPLOYMENT_TARGET='10.11'>
</vars>
<client>
</client>
<locationFinder>
<NVCC>
<or>
<and>
<envVarExists name="MW_NVCC_PATH" />
<dirExists name="$$" />
<fileExists name="$$/nvcc" />
</and>
<cmdReturns name="which nvcc" />
<fileExists name="/Developer/NVIDIA/CUDA-7.5/bin/nvcc" /> <!-- Default install location -->
<fileExists name="/usr/local/cuda/bin/nvcc" /> <!-- Recent CUDA versions symlink here -->
</or>
</NVCC>
<CLANG_COMPILER>
<or>
<envVarExists name="MW_XCODE_CLANG_COMPILER" />
<and>
<cmdReturns name="xcrun -f clang++" />
<dirExists name="$$" />
<fileExists name="$$/clang++" />
</and>
</or>
</CLANG_COMPILER>
<XCRUN_DIR>
<and>
<cmdReturns name="which xcrun" />
<dirExists name="$$" />
</and>
</XCRUN_DIR>
<ISYSROOT>
<and>
<cmdReturns name="xcrun --show-sdk-path"/>
<dirExists name="$$" />
</and>
</ISYSROOT>
</locationFinder>
</config>

0 comments on commit 87110b9

Please sign in to comment.