https://github.com/aosokin/cropRectanglesMex
Raw File
Tip revision: 1d117efde6e40394c7aacccba7a22c8572bb20d4 authored by Anton Osokin on 19 October 2016, 23:48:49 UTC
removing dependencies on samples coming with CUDA
Tip revision: 1d117ef
build_cropRectanglesMex.m
function build_cropRectanglesMex( cudaRoot )
%build_cropRectanglesMex builds package cropRectanglesMex
%
% INPUT:
%   cudaRoot - path to the CUDA installation

% Anton Osokin, firstname.lastname@gmail.com, May 2015

if ~exist('cudaRoot', 'var')
    cudaRoot = '/usr/cuda-7.0' ;
end
nvccPath = fullfile(cudaRoot, 'bin', 'nvcc');
if ~exist(nvccPath, 'file')
    error('NVCC compiler was not found!');
end

root = fileparts( mfilename('fullpath') );

% compiling
compileCmd = [ '"', nvccPath, '"', ...
        ' -c ', fullfile(root,'cropRectanglesMex.cu'), ... 
        ' -I"', fullfile( matlabroot, 'extern', 'include'), '"', ...
        ' -I"', fullfile( matlabroot, 'toolbox', 'distcomp', 'gpu', 'extern', 'include'), '"', ...
        ' -I"', fullfile( cudaRoot, 'include'), '"', ...        
        ' -DNDEBUG -DENABLE_GPU', ...
        ' -Xcompiler', ' -fPIC', ...
        ' -o "', fullfile(root,'cropRectanglesMex.o'), '"'];
system( compileCmd );

% linking
mopts = {'-outdir', root, ...
         '-output', 'cropRectanglesMex', ...
         ['-L', fullfile(cudaRoot, 'lib64')], ...
         '-lcudart', '-lnppi', '-lnppc', '-lmwgpu', ...
         '-largeArrayDims', ...
         fullfile(root,'cropRectanglesMex.o') };
mex(mopts{:}) ;

delete( fullfile(root,'cropRectanglesMex.o') );
        
back to top