Mentions légales du service

Skip to content
Snippets Groups Projects
Commit b0346a91 authored by hhakim's avatar hhakim
Browse files

Update matfaust.enable_gpu_mod function to manage multiple versions of gpu_mod...

Update matfaust.enable_gpu_mod function to manage multiple versions of gpu_mod (for cuda9.2 and cuda11.4).
parent 834a8397
No related branches found
No related tags found
No related merge requests found
......@@ -17,22 +17,28 @@ function enable_gpu_mod(varargin)
backend = 'cuda';
silent = true;
osstr = computer;
switch(osstr)
case 'PCWIN64'
libpath = 'C:\Program Files\Faust\lib\gm.dll';
case 'GLNXA64'
libpath = '/opt/local/faust/lib/libgm.so';
case 'MACI64'
libpath = '/opt/local/faust/lib/libgm.dylib';
otherwise
% not reachable
end
if(~ exist(libpath))
% if filepath doesn't exist, try to find lib in cwd
[~, name, ext] = fileparts(libpath);
libfile = [name ext];
libpath = libfile;
end
backend_suffixes = {'-cu11.4', '-cu9.2', ''};
libpaths = {};
for bi = 1:length(backend_suffixes)
bs = backend_suffixes{bi};
switch(osstr)
case 'PCWIN64'
libpath = [ 'C:\Program Files\Faust\lib\gm' bs '.dll'];
case 'GLNXA64'
libpath = [ '/opt/local/faust/lib/libgm' bs '.so' ];
case 'MACI64'
libpath = [ '/opt/local/faust/lib/libgm' bs '.dylib' ];
otherwise
% not reachable
end
if(~ exist(libpath))
% if filepath doesn't exist, try to find lib in cwd
[~, name, ext] = fileparts(libpath);
libfile = [name ext];
libpath = libfile;
end
libpaths = [libpaths libpath];
end
if(nargin > 0)
i = 1;
while (i <= nargin)
......@@ -42,6 +48,8 @@ function enable_gpu_mod(varargin)
if(nargin == i || ~ isstr(libpath))
error('libpath must be a char array or string')
end
% add this path as first path to try
libpaths = [libpath libpaths];
case 'backend'
if(nargin == i || ~ isstr(libpath))
error('libpath must be a char array or string')
......@@ -63,5 +71,11 @@ function enable_gpu_mod(varargin)
i = i + 2;
end
end
mexFaustReal('enable_gpu_mod', libpath, backend, silent); % it should load the library for complex Faust too
handle = 0;
i = 1;
while(handle == 0 && i < length(libpaths))
libpath = libpaths{i};
handle = mexFaustReal('enable_gpu_mod', libpath, backend, silent); % it should load the library for complex Faust too
i = i + 1;
end
end
......@@ -14,7 +14,10 @@ void enable_gpu_mod(const mxArray **prhs, const int nrhs, mxArray **plhs, const
silent = (bool) mxGetScalar(prhs[3]);
// backend is not yet used (only CUDA is available)
#ifdef USE_GPU_MOD
Faust::enable_gpu_mod(libpath, silent);
void* ptr = Faust::enable_gpu_mod(libpath, silent);
plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL);
double* ptr_out = (double*) mxGetData(plhs[0]);
ptr_out[0] = (double)((unsigned long long)ptr);
#endif
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment