hi,
my code is:
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 = 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\' ;
end
nvccPath = fullfile(cudaRoot, 'bin', 'nvcc.exe')
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 );build_cropRectanglesMex
% linking
mopts = {'-outdir', root, ...
'-output', 'cropRectanglesMex', ...
['-L', fullfile(cudaRoot, 'lib','x64')], ...
'cudart.lib', '-nppi', '-nppc', 'mwgpu', ...
'-largeArrayDims', ...
fullfile(root,'cropRectanglesMex.o') };
mex(mopts{:}) ;
delete( fullfile(root,'cropRectanglesMex.o') );
I get this error:
Error using mex
Unknown file extension ''.
Error in build_cropRectanglesMex (line 37)
mex(mopts{:}) ;
I believe the code is for linking in Linux. How can I do an equivalent linking for Windows?

댓글 수: 5

Walter Roberson
Walter Roberson 2017년 6월 20일
Is it possible that 'mwgpu' should be '-mwgpu' ?
Joss Knight
Joss Knight 2017년 6월 20일
편집: Joss Knight 2017년 6월 20일
Try adding -v to the list of mopts and run again. I don't really see how -nppi and -nppc can be valid options to mex, those are libraries and will need a -l in front to be linked.
Also, all this is very old school. You should be using mexcuda, which would save you most of this include file and linking bother.
Kate
Kate 2017년 6월 20일
I tried adding -v as follows:
mopts = {'-outdir', root, ...
'-output', 'cropRectanglesMex', ...
['-L', fullfile(cudaRoot, 'lib','x64')], ...
'cudart.lib', '-nppi', '-nppc', '-mwgpu', ...
'-largeArrayDims', ...
'-v', ...
fullfile(root,'cropRectanglesMex.o') };
mex(mopts{:}) ;
delete( fullfile(root,'cropRectanglesMex.o') );
But then I get this error:
Error using mex
Unknown MEX argument '-mwgpu'.
Error in build_cropRectanglesMex2 (line 33)
mex(mopts{:}) ;
I tried mexcuda directly on the .cu file, but got an error as well:
>> mexcuda cropRectanglesMex.cu
Building with 'NVIDIA CUDA Compiler'.
Error using mex
Creating library cropRectanglesMex.lib and object cropRectanglesMex.exp
cropRectanglesMex.obj : error LNK2019: unresolved external symbol nppiResizeSqrPixel_32f_P3R referenced in
function mexFunction
cropRectanglesMex.mexw64 : fatal error LNK1120: 1 unresolved externals
Error in mexcuda (line 157)
[varargout{1:nargout}] = mex(mexArguments{:});
The code package is here, any help appreciated: github_code
Joss Knight
Joss Knight 2017년 6월 22일
Using mexcuda you don't need to try to link mwgpu because that is done for you. And libraries are linked using the -l option; so you need -lnppi not -nppi.
Hannah
Hannah 2017년 8월 29일
Kate, did you ever figure out the LNK2019 error when compiling with mexcuda? I am having the same issue.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Get Started with GPU Coder에 대해 자세히 알아보기

질문:

2017년 6월 20일

댓글:

2017년 8월 29일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by