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