Mentions légales du service

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

Add GPU MatBSR CPU-GPU round trip test.

parent 41106267
Branches
Tags
No related merge requests found
...@@ -200,7 +200,7 @@ if(MATIO_LIB_FILE AND MATIO_INC_DIR AND BUILD_READ_MAT_FILE AND NOT NOCPPTESTS) ...@@ -200,7 +200,7 @@ if(MATIO_LIB_FILE AND MATIO_INC_DIR AND BUILD_READ_MAT_FILE AND NOT NOCPPTESTS)
endif() endif()
if(USE_GPU_MOD) if(USE_GPU_MOD)
list(APPEND tests faust_gpu_mod hierarchical2020_gpu test_matdense_gpu_mod test_matsparse_gpu_mod test_transform_gpu_mod test_vect_gpu_mod test_transform_helper_gpu_mod hierarchical2020_gpu2 hierarchical2020Hadamard_gpu2 MEG_factorization test_prox_sp_gpu test_prox_splin_spcol_gpu) list(APPEND tests faust_gpu_mod hierarchical2020_gpu test_matdense_gpu_mod test_matsparse_gpu_mod test_matbsr_gpu_mod test_transform_gpu_mod test_vect_gpu_mod test_transform_helper_gpu_mod hierarchical2020_gpu2 hierarchical2020Hadamard_gpu2 MEG_factorization test_prox_sp_gpu test_prox_splin_spcol_gpu)
endif() endif()
foreach(TEST_FPP float double complex<float> complex<double>) foreach(TEST_FPP float double complex<float> complex<double>)
......
#include "faust_constant.h"
#include "faust_MatBSR.h"
#include "faust_MatBSR_gpu.h"
#include "faust_cuda_device.h"
#include <cstdlib>
#include <cmath>
using namespace std;
using namespace Faust;
typedef @TEST_FPP@ FPP;
void test_gpu_ctor_and_tocpu()
{
auto nrows = 10;
auto ncols = 15;
auto bnrows = 5;
auto bncols = 5;
auto bnnz = 2;
auto cpu_bsr_mat = Faust::MatBSR<double, Cpu>::randMat(nrows, ncols, bnrows, bncols, bnnz);
Faust::MatBSR<double, Cpu> cpu_bsr_mat2;
Faust::MatBSR<double, GPU2> gpu_bsr_mat(
cpu_bsr_mat->getNbRow(),
cpu_bsr_mat->getNbCol(),
cpu_bsr_mat->getNbBlockRow(),
cpu_bsr_mat->getNbBlockCol(),
cpu_bsr_mat->getNBlocks(),
cpu_bsr_mat->get_bdata(),
cpu_bsr_mat->get_browptr(),
cpu_bsr_mat->get_bcolinds());
gpu_bsr_mat.tocpu(cpu_bsr_mat2);
assert(cpu_bsr_mat->norm() == cpu_bsr_mat2.norm());
MatDense<double, Cpu> diff_mat = cpu_bsr_mat->to_dense();
diff_mat -= cpu_bsr_mat2.to_dense();
assert(diff_mat.norm() < 1e-3);
cout << "OK" << endl;
delete cpu_bsr_mat;
}
int main()
{
Faust::enable_gpu_mod();
test_gpu_ctor_and_tocpu();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment