Mentions légales du service

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

Fix FaustGPU::pop_front, FaustGPU::power_iteration2.

This fix makes the following script https://gitlab.inria.fr/faustgrp/faust/snippets/652 to work on GPU (it wasn't working before).
Update to gpu_mod@8dde3d98.
parent 950987b6
No related branches found
No related tags found
No related merge requests found
Subproject commit 6e39c0eb659e3af17b8e4b34b33b43c80c19b3d1 Subproject commit 8dde3d98af29c4f4d6399db4c31bfb99ad2ffa81
...@@ -1256,6 +1256,7 @@ namespace Faust { ...@@ -1256,6 +1256,7 @@ namespace Faust {
template<typename FPP> template<typename FPP>
double TransformHelper<FPP,Cpu>::spectralNorm(const int nbr_iter_max, double threshold, int &flag) const double TransformHelper<FPP,Cpu>::spectralNorm(const int nbr_iter_max, double threshold, int &flag) const
{ {
// std::cout << "TransformHelper<FPP,Cpu>::spectralNorm" << std::endl;
#ifdef USE_GPU_MOD #ifdef USE_GPU_MOD
if(gpu_faust != nullptr) if(gpu_faust != nullptr)
{ {
...@@ -1285,6 +1286,7 @@ namespace Faust { ...@@ -1285,6 +1286,7 @@ namespace Faust {
AtA->enable_gpu_meth_for_mul(); //TODO: it should not be needed if A is already GPU enabled AtA->enable_gpu_meth_for_mul(); //TODO: it should not be needed if A is already GPU enabled
FPP maxAbsValue = std::sqrt(AtA->gpu_faust->power_iteration(nbr_iter_max, threshold, flag)); FPP maxAbsValue = std::sqrt(AtA->gpu_faust->power_iteration(nbr_iter_max, threshold, flag));
delete AtA; delete AtA;
return absValue(maxAbsValue);
} }
else else
{ {
......
...@@ -99,6 +99,8 @@ namespace Faust ...@@ -99,6 +99,8 @@ namespace Faust
{ {
if(use_ref_man) if(use_ref_man)
ref_man.release(*(cpu_mat_ptrs.begin())); ref_man.release(*(cpu_mat_ptrs.begin()));
auto marr_funcs = (gm_MatArrayFunc_@GM_SCALAR@*) this->marr_funcs;
marr_funcs->erase_at(gpu_mat_arr, 0, !use_ref_man);
cpu_mat_ptrs.erase(cpu_mat_ptrs.begin()); cpu_mat_ptrs.erase(cpu_mat_ptrs.begin());
} }
} }
...@@ -247,6 +249,7 @@ namespace Faust ...@@ -247,6 +249,7 @@ namespace Faust
{ {
push_back(m); push_back(m);
} }
// std::cout << "FaustGPU() factors size, matarray size: " << factors.size() << " " << marr_funcs->size(gpu_mat_arr) << std::endl;
} }
template <> template <>
...@@ -399,6 +402,10 @@ namespace Faust ...@@ -399,6 +402,10 @@ namespace Faust
if(xk2_bufsz < mat->getNbRow()) // xk2 buf receives the result of F*xk if(xk2_bufsz < mat->getNbRow()) // xk2 buf receives the result of F*xk
xk2_bufsz = mat->getNbRow(); xk2_bufsz = mat->getNbRow();
} }
// make sure buffer will be larger enough by setting the lower size buffer to the larger size
//TODO: this seems to correct a bug but it should be further investigated
if(xk_bufsz > xk2_bufsz) xk2_bufsz = xk_bufsz;
else if(xk2_bufsz > xk_bufsz) xk_bufsz = xk2_bufsz;
auto xk = dsm_funcs->togpu_bufsz(this->ncols, 1, (@GM_SCALAR@*) reinterpret_cast<@GM_REINTERPRET_CAST_SCALAR@*>(xk_cpu.getData()), xk_bufsz, 1); auto xk = dsm_funcs->togpu_bufsz(this->ncols, 1, (@GM_SCALAR@*) reinterpret_cast<@GM_REINTERPRET_CAST_SCALAR@*>(xk_cpu.getData()), xk_bufsz, 1);
auto xk_norm = dsm_funcs->togpu_bufsz(this->ncols, 1, (@GM_SCALAR@*) reinterpret_cast<@GM_REINTERPRET_CAST_SCALAR@*>(xk_cpu.getData()), xk_bufsz, 1); // the CPU data is irrelevant for xk_norm but it doesn't matter auto xk_norm = dsm_funcs->togpu_bufsz(this->ncols, 1, (@GM_SCALAR@*) reinterpret_cast<@GM_REINTERPRET_CAST_SCALAR@*>(xk_cpu.getData()), xk_bufsz, 1); // the CPU data is irrelevant for xk_norm but it doesn't matter
auto xk2 = dsm_funcs->togpu_bufsz(this->nrows, 1, (@GM_SCALAR@*) reinterpret_cast<@GM_REINTERPRET_CAST_SCALAR@*>(xk2_cpu.getData()), xk2_bufsz, 1); auto xk2 = dsm_funcs->togpu_bufsz(this->nrows, 1, (@GM_SCALAR@*) reinterpret_cast<@GM_REINTERPRET_CAST_SCALAR@*>(xk2_cpu.getData()), xk2_bufsz, 1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment