Mentions légales du service

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

Add GPU test for cpp dynprog_multiply.

parent 032d9dec
Branches
No related tags found
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)
endif()
if(USE_GPU_MOD)
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)
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 test_dynprog_mul_gpu)
endif()
foreach(TEST_FPP float double complex<float> complex<double>)
......
#include "faust_TransformHelper.h"
#include "faust_TransformHelper_gpu.h"
#include "faust_prod_opt_gen.h"
#include <cstdlib>
#include <ctime>
typedef @TEST_FPP@ FPP;
using namespace Faust;
int main()
{
unsigned int min_num_factors = 2;
unsigned int max_num_factors = 10;
unsigned int min_dim_size = 10;
unsigned int max_dim_size = 1024;
float density = .5f;
bool per_row = true;
auto F = TransformHelper<FPP, GPU2>::randFaust(MIXED, min_num_factors, max_num_factors, min_dim_size, max_dim_size, density, per_row);
//TODO: fix always two factors
F->display();
// convert the Faust to a vector of matrices
std::vector<MatGeneric<FPP, GPU2>*> data;
for(auto f: *F)
{
f->Display();
data.push_back(f);
}
auto res_mat = dynprog_multiply(data);
auto ref_mat = F->get_product();
auto test_mat = ref_mat;
test_mat -= res_mat;
auto re = test_mat.norm() / ref_mat.norm();
std::cout << "rel. err of test_mat vs ref_mat: " << re << std::endl;
assert(re < 1e-4);
return EXIT_SUCCESS;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment