Mentions légales du service

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

Add matfaust.Faust.save GPU2 wrapper.

parent 09fec4fb
Branches
Tags
No related merge requests found
...@@ -75,14 +75,13 @@ ...@@ -75,14 +75,13 @@
#include "faust_numfactors.h" #include "faust_numfactors.h"
#include "faust_factors.h" #include "faust_factors.h"
#include "faust_rand.h" #include "faust_rand.h"
#include "faust_save.h"
typedef @FAUST_SCALAR@ SCALAR; typedef @FAUST_SCALAR@ SCALAR;
typedef @FAUST_FPP@ FPP; typedef @FAUST_FPP@ FPP;
using namespace Faust; using namespace Faust;
void save(Faust::TransformHelper<SCALAR,Cpu>* core_ptr, int nargs, const mxArray **args);
template<typename T> template<typename T>
void fourierFaust(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]); void fourierFaust(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
...@@ -131,7 +130,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) ...@@ -131,7 +130,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
if(!strcmp("rand", cmd)) if(!strcmp("rand", cmd))
{ {
faust_rand<FPP,Cpu>(prhs, nrhs, plhs, nlhs); faust_rand<SCALAR,Cpu>(prhs, nrhs, plhs, nlhs);
return; return;
} }
//TODO: hadamard, fourier, and proxs must be in there own mex function (one for hadamard and fourier, another for the prox) //TODO: hadamard, fourier, and proxs must be in there own mex function (one for hadamard and fourier, another for the prox)
...@@ -501,7 +500,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) ...@@ -501,7 +500,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
} }
if(!strcmp("save", cmd)) if(!strcmp("save", cmd))
return save(convertMat2Ptr<Faust::TransformHelper<SCALAR,Cpu> >(prhs[1]), nrhs-2, &prhs[2]); return faust_save<FPP,Cpu>(prhs, nrhs, plhs, nlhs);
if(!strcmp("transpose", cmd)) { //TODO: verify no arguments passed or if(!strcmp("transpose", cmd)) { //TODO: verify no arguments passed or
Faust::TransformHelper<SCALAR,Cpu>* th = core_ptr->transpose(); Faust::TransformHelper<SCALAR,Cpu>* th = core_ptr->transpose();
...@@ -696,32 +695,6 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) ...@@ -696,32 +695,6 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
} }
} }
void save(Faust::TransformHelper<SCALAR,Cpu>* core_ptr, int nargs, const mxArray **args)
{
const size_t MAX_PATH_SIZE=512;
char filepath[MAX_PATH_SIZE];
// args[0] must be the filepath
// args[1] must be the boolean for tranposing or not at write time
// nargs the number of arguments in args (must be 2)
if(nargs != 1){
mexErrMsgTxt("The number of arguments for the save function is not valid.");
return;
}
if(mxGetString(args[0], filepath, sizeof(filepath)) || strlen(filepath) == 0){
mexErrMsgTxt("The filepath is not valid.");
return;
}
// printf("save: filepath = %s, nargs = %d\n", filepath, nargs);
try
{
core_ptr->save_mat_file(filepath/*, mxGetScalar(args[1])*/);
}
catch(exception& e)
{
mexErrMsgTxt("Failed to save the file.");
}
}
template<typename T> template<typename T>
void fourierFaust(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) void fourierFaust(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{ {
......
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
#include "faust_gpu_mod_utils.h" #include "faust_gpu_mod_utils.h"
#include "faust_TransformHelper_gpu.h" #include "faust_TransformHelper_gpu.h"
#include "faust_rand.h" #include "faust_rand.h"
#include "faust_save.h"
typedef @FAUST_SCALAR@ SCALAR; typedef @FAUST_SCALAR@ SCALAR;
typedef @FAUST_FPP@ FPP; typedef @FAUST_FPP@ FPP;
...@@ -110,7 +111,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) ...@@ -110,7 +111,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
if (!strcmp("new", cmd)) if (!strcmp("new", cmd))
new_faust<SCALAR,GPU2>(prhs, nrhs, plhs, nlhs); new_faust<SCALAR,GPU2>(prhs, nrhs, plhs, nlhs);
else if(!strcmp("rand", cmd)) else if(!strcmp("rand", cmd))
faust_rand<FPP,GPU2>(prhs, nrhs, plhs, nlhs); faust_rand<SCALAR,GPU2>(prhs, nrhs, plhs, nlhs);
else if (! strcmp("disp",cmd)) else if (! strcmp("disp",cmd))
faust_disp<SCALAR,GPU2>(prhs, nrhs, plhs, nlhs); faust_disp<SCALAR,GPU2>(prhs, nrhs, plhs, nlhs);
else if (!strcmp("delete", cmd)) else if (!strcmp("delete", cmd))
...@@ -133,6 +134,8 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) ...@@ -133,6 +134,8 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
faust_numfactors<SCALAR, GPU2>(prhs, nrhs, plhs, nlhs); faust_numfactors<SCALAR, GPU2>(prhs, nrhs, plhs, nlhs);
else if (!strcmp("factors", cmd)) else if (!strcmp("factors", cmd))
faust_factors<SCALAR, GPU2>(prhs, nrhs, plhs, nlhs); faust_factors<SCALAR, GPU2>(prhs, nrhs, plhs, nlhs);
else if (!strcmp("save", cmd))
faust_save<SCALAR, GPU2>(prhs, nrhs, plhs, nlhs);
} }
catch (const std::exception& e) catch (const std::exception& e)
......
...@@ -400,9 +400,9 @@ mxArray* transformFact2FullMxArray(faust_unsigned_int id, Faust::TransformHelper ...@@ -400,9 +400,9 @@ mxArray* transformFact2FullMxArray(faust_unsigned_int id, Faust::TransformHelper
} }
else else
{ {
const complex<FPP>* src_data_ptr; complex<FPP>* src_data_ptr;
//not calling the same prototype of get_fact() called in transpose case (and real version of this function) //not calling the same prototype of get_fact() called in transpose case (and real version of this function)
core_ptr->get_fact(id, &src_data_ptr, &num_rows, &num_cols); core_ptr->get_fact(id, src_data_ptr, &num_rows, &num_cols);
splitComplexPtr(src_data_ptr, num_rows*num_cols, data_ptr, img_data_ptr, core_ptr->isConjugate());//let conjugate to false because it's handled internally by get_fact() splitComplexPtr(src_data_ptr, num_rows*num_cols, data_ptr, img_data_ptr, core_ptr->isConjugate());//let conjugate to false because it's handled internally by get_fact()
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment