Mentions légales du service

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

Add to_string() and Display() methods to MatSparse<FPP,GPU2> and MatDense<FPP,GPU2> methods.

parent 1a3996eb
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,8 @@ namespace Faust
MatDense(const MatDense<FPP,Cpu>& mat, const int32_t dev_id/*=-1*/, const void* stream/*=nullptr*/);
~MatDense();
void operator=(const MatDense<FPP,GPU2> & A);
void operator=(const MatDense<FPP,Cpu> & A);
void operator=(const MatSparse<FPP,Cpu> & A);
......@@ -78,11 +80,12 @@ namespace Faust
Real<FPP> norm();
Real<FPP> normL1();
void normalize();
int32_t getDevice();
int32_t getDevice() const;
MatDense<FPP, GPU2>* clone(const int32_t dev_id=-1, const void* stream=nullptr);
void move(const int32_t dev_id=-1, const void* stream=nullptr);
MatDense<FPP, Cpu> tocpu(const void* stream=nullptr);
~MatDense<FPP, GPU2>();
MatDense<FPP, Cpu> tocpu(const void* stream=nullptr) const;
void Display() const;
std::string to_string(const bool transpose=false, const bool displaying_small_mat_elts=false) const;
private:
gm_DenseMat_t gpu_mat;
};
......
......@@ -111,7 +111,7 @@ namespace Faust
}
template<>
Faust::MatDense<@FAUST_SCALAR_FOR_GM@, Cpu> Faust::MatDense<@FAUST_SCALAR_FOR_GM@,GPU2>::tocpu(const void* stream/*=nullptr*/)
Faust::MatDense<@FAUST_SCALAR_FOR_GM@, Cpu> Faust::MatDense<@FAUST_SCALAR_FOR_GM@,GPU2>::tocpu(const void* stream/*=nullptr*/) const
{
MatDense<@FAUST_SCALAR_FOR_GM@, Cpu> cpu_mat(dim1, dim2);
auto dsm_funcs = GPUModHandler::get_singleton()->dsm_funcs(@FAUST_SCALAR_FOR_GM@(0));
......@@ -435,7 +435,7 @@ namespace Faust
}
template<>
int32_t Faust::MatDense<@FAUST_SCALAR_FOR_GM@, GPU2>::getDevice()
int32_t Faust::MatDense<@FAUST_SCALAR_FOR_GM@, GPU2>::getDevice() const
{
auto dsm_funcs = GPUModHandler::get_singleton()->dsm_funcs(@FAUST_SCALAR_FOR_GM@(0));
int32_t dev_id = dsm_funcs->get_dev(gpu_mat);
......@@ -443,4 +443,17 @@ namespace Faust
}
template<>
std::string Faust::MatDense<@FAUST_SCALAR_FOR_GM@, GPU2>::to_string(const bool transpose/*=false*/, const bool displaying_small_mat_elts/*=false*/) const
{
//TODO: rely on gpu_mod display function (yet to write)
return "(on GPU device: " + std::to_string(getDevice())+ ") "+tocpu().to_string();
}
template<>
void Faust::MatDense<@FAUST_SCALAR_FOR_GM@, GPU2>::Display() const
{
std::cout << this->to_string();
}
};
......@@ -54,7 +54,7 @@ namespace Faust
bool operator==(const MatSparse<FPP, GPU2>& mat) const;
bool operator!=(const MatSparse<FPP, GPU2>& mat) const;
void tocpu(MatSparse<FPP,Cpu> &sp_mat);
void tocpu(MatSparse<FPP,Cpu> &sp_mat) const;
Real<FPP> norm();
void transpose();
void adjoint();
......@@ -69,7 +69,9 @@ namespace Faust
int32_t getNbRow();
int32_t getNbCol();
int32_t getNonZeros();
int32_t getDevice();
int32_t getDevice() const;
void Display() const;
std::string to_string(const bool transpose=false, const bool displaying_small_mat_elts=false) const;
~MatSparse();
private:
......
......@@ -120,7 +120,7 @@ namespace Faust
}
template<>
void MatSparse<@FAUST_SCALAR_FOR_GM@,GPU2>::tocpu(MatSparse<@FAUST_SCALAR_FOR_GM@, Cpu> & sp_mat)
void MatSparse<@FAUST_SCALAR_FOR_GM@,GPU2>::tocpu(MatSparse<@FAUST_SCALAR_FOR_GM@, Cpu> & sp_mat) const
{
int32_t nrows, ncols, nnz;
auto spm_funcs = GPUModHandler::get_singleton()->spm_funcs((@FAUST_SCALAR_FOR_GM@)(0));
......@@ -244,10 +244,25 @@ namespace Faust
}
template<>
int32_t Faust::MatSparse<@FAUST_SCALAR_FOR_GM@, GPU2>::getDevice()
int32_t Faust::MatSparse<@FAUST_SCALAR_FOR_GM@, GPU2>::getDevice() const
{
auto spm_funcs = GPUModHandler::get_singleton()->spm_funcs((@FAUST_SCALAR_FOR_GM@)(0));
int32_t dev_id = spm_funcs->get_dev(gpu_mat);
return dev_id;
}
template<>
std::string Faust::MatSparse<@FAUST_SCALAR_FOR_GM@, GPU2>::to_string(const bool transpose/*=false*/, const bool displaying_small_mat_elts/*=false*/) const
{
MatSparse<@FAUST_SCALAR_FOR_GM@, Cpu> sp_mat;
tocpu(sp_mat);
//TODO: rely on gpu_mod display function (yet to write)
return "(on GPU device: " + std::to_string(getDevice())+ ") "+ sp_mat.to_string();
}
template<>
void Faust::MatSparse<@FAUST_SCALAR_FOR_GM@, GPU2>::Display() const
{
std::cout << this->to_string();
}
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment