Mentions légales du service

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

Add GPU2 MatButterfly::multiply(MatSparse<FPP, GPU2>, const char) and its unit test.

parent 3f1dcf52
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,14 @@ bool verifyMatEq(MatDense<FPP, Cpu> refm, MatDense<FPP, Cpu> testm, double tol=1
return err.norm() <= tol;
}
bool verifyMatEq(MatDense<FPP, Cpu> refm, MatDense<FPP, GPU2> testm_gpu, double tol=1e-6)
{
auto testm = testm_gpu.tocpu();
auto err = refm;
err -= testm;
return err.norm() <= tol;
}
void test_mul_matdense(MatButterfly<FPP, GPU2> &gpu_bm, MatButterfly<FPP, Cpu> &cpu_bm)
{
cout << "Test MatButterfly<FPP, GPU2>::multiply(MatDense<FPP, GPU2>, const char* op)" << endl;
......@@ -28,6 +36,24 @@ void test_mul_matdense(MatButterfly<FPP, GPU2> &gpu_bm, MatButterfly<FPP, Cpu> &
gpu_bm.multiply(test_mat, 'N');
auto test_mat_cpu = test_mat.tocpu();
assert(verifyMatEq(test_mat_cpu, ref_mat));
delete rmat;
cout << "OK" << endl;
}
void test_mul_matsparse(MatButterfly<FPP, GPU2> &gpu_bm, MatButterfly<FPP, Cpu> &cpu_bm)
{
cout << "Test MatButterfly<FPP, GPU2>::multiply(MatSparse<FPP, GPU2>, const char* op)" << endl;
auto size = cpu_bm.getNbRow();
auto rmat = MatDense<FPP, Cpu>::randMat(size, size);
MatSparse<FPP, Cpu> rspmat(*rmat);
MatSparse<FPP, GPU2> rspmat_gpu(rspmat);
cpu_bm.multiply(rspmat, 'N');
gpu_bm.multiply(rspmat_gpu, 'N');
MatDense<FPP, Cpu> ref_mat(rspmat);
MatDense<FPP, GPU2> test_mat(rspmat_gpu);
assert(verifyMatEq(ref_mat, test_mat));
delete rmat;
cout << "OK" << endl;
}
......@@ -73,6 +99,7 @@ int main(int argc, char** argv)
test_get_nbytes(gpu_bm, cpu_bm);
test_get_nbrowcol(gpu_bm, cpu_bm);
test_get_type(gpu_bm, cpu_bm);
test_mul_matsparse(gpu_bm, cpu_bm);
return 0;
}
......@@ -17,6 +17,8 @@ namespace Faust
Vect<FPP, GPU2> d2;
int* subdiag_ids;
int level;
Vect<FPP, GPU2> d2t;
bool is_transp;
public:
......@@ -45,6 +47,7 @@ namespace Faust
void Display() const;
Real<FPP> norm() const;*/
void multiply(MatDense<FPP, GPU2> &other, const char op_this);
void multiply(MatSparse<FPP, GPU2> &other, const char op_this);
};
}
......
......@@ -33,4 +33,13 @@ namespace Faust
{
return (d1.size() + d2.size() + (is_transp?d2.size():0)) * sizeof(FPP) + d2.size() * sizeof(int);
}
template<typename FPP>
void MatButterfly<FPP, GPU2>::multiply(MatSparse<FPP, GPU2>& M, const char opThis)
{
MatDense<FPP, GPU2> Y(M);
this->multiply(Y, opThis);
M = Y;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment