Mentions légales du service

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

Add MatBSR<FPP,GPU2>::to_dense and its unit test.

Update to gpu_mod@19563928.
parent 0636f298
No related branches found
No related tags found
No related merge requests found
...@@ -91,6 +91,26 @@ void test_gpu_mul_vec() ...@@ -91,6 +91,26 @@ void test_gpu_mul_vec()
std::cout << "OK" << std::endl; std::cout << "OK" << std::endl;
} }
void test_bsr_to_dense()
{
std::cout << "test_bsr_to_dense" << std::endl;
auto cpu_bmat = MatBSR<FPP, Cpu>::randMat(10, 15, 5, 5, 2);
MatBSR<FPP, GPU2> gpu_bmat(*cpu_bmat);
auto gpu_dsmat = gpu_bmat.to_dense();
MatDense<FPP, Cpu> cpu_dsmat_test;
gpu_dsmat.tocpu(cpu_dsmat_test);
auto cpu_dsmat_ref = cpu_bmat->to_dense();
MatDense<FPP, Cpu> cpu_dmat_test = cpu_dsmat_test;
MatDense<FPP, Cpu> cpu_dmat_ref = cpu_dsmat_ref;
MatDense<FPP, Cpu> diff = cpu_dmat_ref;
diff -= cpu_dmat_test;
assert(diff.norm() / cpu_dmat_ref.norm() < 1e-3);
std::cout << "OK" << std::endl;
}
void test_bsr_to_sparse() void test_bsr_to_sparse()
{ {
std::cout << "test_bsr_to_sparse" << std::endl; std::cout << "test_bsr_to_sparse" << std::endl;
...@@ -346,6 +366,7 @@ int main() ...@@ -346,6 +366,7 @@ int main()
test_gpu_mul_dense(); test_gpu_mul_dense();
test_gpu_mul_vec(); test_gpu_mul_vec();
test_bsr_to_sparse(); test_bsr_to_sparse();
test_bsr_to_dense();
test_sparse_to_bsr(); test_sparse_to_bsr();
test_transpose(); test_transpose();
test_adjoint(); test_adjoint();
......
...@@ -135,6 +135,15 @@ namespace Faust ...@@ -135,6 +135,15 @@ namespace Faust
return spm; return spm;
} }
template<>
MatDense<@FAUST_SCALAR_FOR_GM@, GPU2> MatBSR<@FAUST_SCALAR_FOR_GM@,GPU2>::to_dense() const
{
MatDense<@FAUST_SCALAR_FOR_GM@, GPU2> dsm;
auto bsr_funcs = GPUModHandler::get_singleton()->bsr_funcs((@FAUST_SCALAR_FOR_GM@)(0));
dsm.set_gpu_mat_ptr(bsr_funcs->bsr2dense(gpu_mat, OP_NOTRANSP));
return dsm;
}
template<> template<>
void MatBSR<@FAUST_SCALAR_FOR_GM@, GPU2>::transpose() void MatBSR<@FAUST_SCALAR_FOR_GM@, GPU2>::transpose()
{ {
......
...@@ -77,6 +77,7 @@ namespace Faust ...@@ -77,6 +77,7 @@ namespace Faust
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; 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;
void tocpu(MatBSR<FPP, Cpu> &cpu_mat) const; void tocpu(MatBSR<FPP, Cpu> &cpu_mat) const;
MatSparse<FPP, GPU2> to_sparse() const; MatSparse<FPP, GPU2> to_sparse() const;
MatDense<FPP, GPU2> to_dense() const;
}; };
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment