Mentions légales du service

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

Fix a bug in Parallel Truncated Jacobi algorithm (GivensFGFTParallel/Complex).

The bug occured in certain conditions (when the number of Givens rotations per factor -- t -- is at its max or near). An error in the break condition of a while loop provoked an exit before that the factor is full of Givens as expected.
Minor other modifs: change in the debug output/tests.
parent a2fd3aba
No related branches found
No related tags found
No related merge requests found
Pipeline #833892 skipped
...@@ -81,8 +81,10 @@ void GivensFGFTParallel<FPP,DEVICE,FPP2>::update_fact_nz_inds() ...@@ -81,8 +81,10 @@ void GivensFGFTParallel<FPP,DEVICE,FPP2>::update_fact_nz_inds()
i++; i++;
} }
#ifdef DEBUG_GIVENS #ifdef DEBUG_GIVENS
cout << "GivensFGFTParallel::update_fact_nz_inds() after purge: ";
for(auto &p : fact_nz_inds) for(auto &p : fact_nz_inds)
cout << "GivensFGFTParallel::update_fact_nz_inds() after purge (" << p.first+1 << "," << p.second+1 << ") :" << endl; cout << "(" << p.first+1 << "," << p.second+1 << ") :";
cout << endl;
#endif #endif
} }
...@@ -110,7 +112,7 @@ template<typename FPP, Device DEVICE, typename FPP2> ...@@ -110,7 +112,7 @@ template<typename FPP, Device DEVICE, typename FPP2>
void GivensFGFTParallel<FPP,DEVICE,FPP2>::loop_update_fact() void GivensFGFTParallel<FPP,DEVICE,FPP2>::loop_update_fact()
{ {
fact_nrots = 0; fact_nrots = 0;
while(fact_nrots < t && fact_nrots < fact_nz_inds.size()) while(fact_nrots < t && 0 < fact_nz_inds.size())
{ {
choose_pivot(); choose_pivot();
update_fact_nz_inds(); update_fact_nz_inds();
...@@ -131,7 +133,7 @@ void GivensFGFTParallel<FPP,DEVICE,FPP2>::choose_pivot() ...@@ -131,7 +133,7 @@ void GivensFGFTParallel<FPP,DEVICE,FPP2>::choose_pivot()
this->q = max_elt.second; this->q = max_elt.second;
this->coord_choices.push_back(pair<int,int>(this->p,this->q)); this->coord_choices.push_back(pair<int,int>(this->p,this->q));
#ifdef DEBUG_GIVENS #ifdef DEBUG_GIVENS
cout << "choose_pivot() p: " << this->p+1 << " q:" << this->q+1 << " " << "L(p,q): " << this->L(this->p,this->q) << " nrots: " << fact_nrots << endl; cout << "choose_pivot() p: " << this->p+1 << " q:" << this->q+1 << " " << "L(p,q): " << (*(this->L))(this->p,this->q) << " nrots: " << fact_nrots << endl;
#endif #endif
} }
......
...@@ -112,7 +112,7 @@ template<typename FPP, Device DEVICE, typename FPP2> ...@@ -112,7 +112,7 @@ template<typename FPP, Device DEVICE, typename FPP2>
void GivensFGFTParallelComplex<FPP,DEVICE,FPP2>::loop_update_fact() void GivensFGFTParallelComplex<FPP,DEVICE,FPP2>::loop_update_fact()
{ {
fact_nrots = 0; fact_nrots = 0;
while(fact_nrots < t && fact_nrots < fact_nz_inds.size()) while(fact_nrots < t && 0 < fact_nz_inds.size())
{ {
choose_pivot(); choose_pivot();
update_fact_nz_inds(); update_fact_nz_inds();
...@@ -121,6 +121,7 @@ void GivensFGFTParallelComplex<FPP,DEVICE,FPP2>::loop_update_fact() ...@@ -121,6 +121,7 @@ void GivensFGFTParallelComplex<FPP,DEVICE,FPP2>::loop_update_fact()
fact_nrots++; fact_nrots++;
} }
finish_fact(); finish_fact();
#ifdef DEBUG_GIVENS
int n = this->L->getNbRow(); int n = this->L->getNbRow();
// cout << "n=" << n << endl; // cout << "n=" << n << endl;
MatSparse<FPP,DEVICE> test1(this->facts[this->ite]); MatSparse<FPP,DEVICE> test1(this->facts[this->ite]);
...@@ -133,7 +134,7 @@ void GivensFGFTParallelComplex<FPP,DEVICE,FPP2>::loop_update_fact() ...@@ -133,7 +134,7 @@ void GivensFGFTParallelComplex<FPP,DEVICE,FPP2>::loop_update_fact()
// cout << "ite=" << this->ite << "S*S'(" << j << "," << j << ")=" << test2(j,j) << endl; // cout << "ite=" << this->ite << "S*S'(" << j << "," << j << ")=" << test2(j,j) << endl;
assert(Faust::abs(test2(j,j)-FPP(1,0)) < 1); assert(Faust::abs(test2(j,j)-FPP(1,0)) < 1);
} }
#endif
} }
template<typename FPP, Device DEVICE, typename FPP2> template<typename FPP, Device DEVICE, typename FPP2>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment