Mentions légales du service

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

Add operator*=(const FPP&) overload in MatGeneric<FPP, GPU2> (abstract method)...

Add operator*=(const FPP&) overload in MatGeneric<FPP, GPU2> (abstract method) and implement it in child classes.
parent e80c8a80
Branches
Tags
No related merge requests found
......@@ -79,6 +79,7 @@ namespace Faust
/*********** own member functions **************/
void multiply(MatDense<FPP,GPU2>& M, char opThis='N') const;
void multiply(Vect<FPP,GPU2>& vec, char opThis='N') const;
void operator*=(const FPP& alpha);
static void bsrgemm(const MatBSR<FPP, GPU2>& A, const MatDense<FPP,GPU2>& B, MatDense<FPP,GPU2>& C, const FPP& alpha, const FPP& beta, const char opThis/*='N'*/, const char opB /*= 'N'*/);
void tocpu(int32_t* browptr, int32_t* bcolinds, FPP* bdata, int32_t* nrows=nullptr, int32_t* ncols=nullptr, int32_t *bnrows=nullptr, int32_t *bncol=nullptr, int32_t* bnnz=nullptr) const;
......
......@@ -117,4 +117,13 @@ namespace Faust
this->gpu_mat = gpu_mat;
}
template<typename FPP>
void MatBSR<FPP, GPU2>::operator*=(const FPP& alpha)
{
//TODO: avoid CPU-GPU back and forth
MatBSR<FPP, Cpu> cpu_mat;
tocpu(cpu_mat);
cpu_mat *= alpha;
*this = MatBSR<FPP, GPU2>(cpu_mat);
}
};
......@@ -64,6 +64,7 @@ namespace Faust
MatDense<FPP, GPU2> multiply(const FPP* A, int A_ncols);
MatDense<FPP, GPU2> multiply(MatDense<FPP,GPU2> &A);
void multiply(MatDense<FPP,GPU2> &A, MatDense<FPP, Cpu> & out);
void operator*=(const FPP& alpha);
const Vect<FPP, GPU2>& getD1() {return d1;};
const Vect<FPP, GPU2>& getD2() {return d2;};
const int getLevel() const {return level;}
......
......@@ -219,6 +219,15 @@ namespace Faust
return gpu_X;
}
template<typename FPP>
void MatPerm<FPP, GPU2>::operator*=(const FPP& alpha)
{
d1 *= alpha;
d2 *= alpha;
if(d2t.size() > 0)
d2t *= alpha;
}
template<typename FPP>
MatButterfly<FPP, GPU2>::~MatButterfly()
{
......
......@@ -48,6 +48,7 @@ namespace Faust
virtual Real<FPP> norm() const=0;
virtual void multiply(MatDense<FPP,GPU2> &A, const char opThis) const =0;
virtual void operator*=(const FPP& alpha) =0;
MatGeneric();
virtual ~MatGeneric();
......
......@@ -62,6 +62,8 @@ namespace Faust
MatDense<FPP, GPU2> multiply(const FPP* A, int A_ncols);
MatDense<FPP, GPU2> multiply(MatDense<FPP,GPU2> &A);
void multiply(MatDense<FPP,GPU2> &A, MatDense<FPP, Cpu> & out);
void operator*=(const FPP& alpha);
const Vect<FPP, GPU2>& getD() {return d;};
MatPerm(const MatSparse<FPP, Cpu> &factor);
......
......@@ -217,4 +217,13 @@ namespace Faust
if(perm_ids_T)
delete[] perm_ids_T;
}
template<typename FPP>
void MatPerm<FPP, GPU2>::operator*=(const FPP& alpha)
{
d *= alpha;
if(dt.size() > 0)
dt *= alpha;
}
}
......@@ -19,7 +19,7 @@ namespace Faust
Vect();
Vect(const faust_unsigned_int size,
explicit Vect(const faust_unsigned_int size,
const FPP* cpu_data=nullptr,
const bool no_alloc=false,
const int32_t dev_id=-1,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment