Mentions légales du service

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

Implement GPU2 TransformHelper::randBSRFaust + its unit test and modify...

Implement GPU2 TransformHelper::randBSRFaust + its unit test and modify push_back to handle BSR factors appending.

Update to gpu_mod@58c653f4.
parent 3e654bb3
Branches
Tags
No related merge requests found
Subproject commit 15531393a8ed3c5dbf38c5817d181bcbf7b827a8
Subproject commit 58c653f4adbebc386ae2ff3b5b21e582b6fb647c
......@@ -5,6 +5,9 @@
#include "faust_cuda_device.h"
#include <cstdlib>
#include <cmath>
#include "faust_TransformHelper.h"
#include "faust_TransformHelper_gpu.h"
using namespace std;
using namespace Faust;
......@@ -321,6 +324,21 @@ void test_clone()
delete cpu_bsr_mat;
}
void test_transform_rand_bsr()
{
std::cout << "test_transform_rand_bsr" << std::endl;
unsigned int faust_nrows = 10;
unsigned int faust_ncols = 10;
unsigned int min_num_factors = 2;
unsigned int max_num_factors = 5;
unsigned int bnrows = 2;
unsigned int bncols = 2;
float density = .1f;
auto F = TransformHelper<FPP, GPU2>::randBSRFaust(faust_nrows, faust_ncols, min_num_factors, max_num_factors, bnrows, bncols);
F->display();
delete F;
}
int main()
{
Faust::enable_gpu_mod();
......@@ -337,6 +355,7 @@ int main()
test_set_zeros();
test_get_nrows_ncols();
test_clone();
test_transform_rand_bsr();
}
......@@ -139,7 +139,7 @@ namespace Faust
static TransformHelper<FPP,GPU2>* randFaust(int faust_nrows, int faust_ncols, RandFaustType t, unsigned int min_num_factors, unsigned int max_num_factors, unsigned int min_dim_size, unsigned int max_dim_size, float density=.1f, bool per_row=true);
static TransformHelper<FPP,GPU2>* randFaust(RandFaustType t, unsigned int min_num_factors, unsigned int max_num_factors, unsigned int min_dim_size, unsigned int max_dim_size, float density=.1f, bool per_row=true);
static TransformHelper<FPP, GPU2>* randBSRFaust(unsigned int faust_nrows, unsigned int faust_ncols, unsigned int min_num_factors, unsigned int max_num_factors, unsigned int bnrows, unsigned int bncols, float density=.1f) { throw std::runtime_error("randBSRFaust not yet implemented on GPU.");}
static TransformHelper<FPP, GPU2>* randBSRFaust(unsigned int faust_nrows, unsigned int faust_ncols, unsigned int min_num_factors, unsigned int max_num_factors, unsigned int bnrows, unsigned int bncols, float density=.1f);
};
......
......@@ -84,6 +84,7 @@ namespace Faust
MatGeneric<FPP,GPU2>* gpu_M = nullptr;
const MatDense<FPP,Cpu>* cpu_dM = nullptr;
const MatSparse<FPP,Cpu>* cpu_sM = nullptr;
const MatBSR<FPP,Cpu>* cpu_bM = nullptr;
if(nullptr != (cpu_dM = dynamic_cast<const MatDense<FPP,Cpu>*>(M)))
{
auto gpu_dM = new MatDense<FPP,GPU2>(M->getNbRow(), M->getNbCol(), cpu_dM->getData());
......@@ -94,6 +95,11 @@ namespace Faust
auto gpu_sM = new MatSparse<FPP,GPU2>(M->getNbRow(), M->getNbCol(), cpu_sM->getNonZeros(), cpu_sM->getValuePtr(), cpu_sM->getRowPtr(), cpu_sM->getColInd(), dev_id);
gpu_M = gpu_sM;
}
else if(nullptr != (cpu_bM = dynamic_cast<const MatBSR<FPP,Cpu>*>(M)))
{
auto gpu_bM = new MatBSR<FPP,GPU2>(*cpu_bM);
gpu_M = gpu_bM;
}
this->transform->push_back(gpu_M, false);
}
......@@ -726,6 +732,16 @@ namespace Faust
return gpu_faust;
}
template<typename FPP>
TransformHelper<FPP, GPU2>* TransformHelper<FPP,GPU2>::randBSRFaust(unsigned int faust_nrows, unsigned int faust_ncols, unsigned int min_num_factors, unsigned int max_num_factors, unsigned int bnrows, unsigned int bncols, float density/*=.1f*/)
{
auto cpu_faust = TransformHelper<FPP,Cpu>::randBSRFaust(faust_nrows, faust_ncols, min_num_factors, max_num_factors, bnrows, bncols, density);
TransformHelper<FPP,GPU2>* gpu_faust = new TransformHelper<FPP,GPU2>(*cpu_faust, -1, nullptr /*TODO: dev_id and stream ?*/);
delete cpu_faust;
return gpu_faust;
}
template<typename FPP>
TransformHelper<FPP,GPU2>* TransformHelper<FPP,GPU2>::swap_rows(const faust_unsigned_int id1,
const faust_unsigned_int id2,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment