-
Notifications
You must be signed in to change notification settings - Fork 0
/
nvcc.m
38 lines (26 loc) · 1.03 KB
/
nvcc.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
% all rights reserved
% author: Zhihua Ban
% contact: [email protected]
function nvcc(varargin)
nvcc_customer = strjoin(varargin);
% host compiler
compilerForMex = mex.getCompilerConfigurations('C++','selected');
compiler_arch = strtrim(compilerForMex(1).Details.CommandLineShellArg);
if ispc && isempty(strfind(compiler_arch, '64'))
error('we only suport 64-bit');
end
if ispc
compiler_parent = fullfile(compilerForMex.Location, 'VC', 'bin', compiler_arch);
host_compiler_opt = sprintf(' -ccbin "%s"', compiler_parent);
host_compiler_flg = regexprep(compilerForMex.Details.CompilerFlags, '/[Ww][0-9]\s*', '');
else
host_compiler_opt = ' ';
host_compiler_flg = regexprep(compilerForMex.Details.CompilerFlags, '-std\S*\s*', '');
end
host_compiler_opt = sprintf('%s -Xcompiler "%s"', host_compiler_opt, host_compiler_flg);
nvcc_command_line = ['nvcc', ' ', host_compiler_opt];
nvcc_command = sprintf('%s %s\n', nvcc_command_line, nvcc_customer);
status = system(nvcc_command);
if status < 0
error('Error invoking nvcc');
end