Prepare further optimization. (nw)

This commit is contained in:
couriersud 2019-02-23 19:58:49 +01:00
parent df3e331d6f
commit 89e0f698b6
5 changed files with 22 additions and 27 deletions

View File

@ -237,7 +237,7 @@ namespace devices
/* rebuild */
for (auto &term : m_terms)
{
int *other = term->connected_net_idx();
int *other = term->m_connected_net_idx.data();
for (std::size_t i = 0; i < term->count(); i++)
//FIXME: this is weird
if (other[i] != -1)
@ -253,7 +253,7 @@ namespace devices
{
m_terms[k]->m_railstart = m_terms[k]->count();
for (std::size_t i = 0; i < m_rails_temp[k]->count(); i++)
this->m_terms[k]->add(m_rails_temp[k]->terms()[i], m_rails_temp[k]->connected_net_idx()[i], false);
this->m_terms[k]->add(m_rails_temp[k]->terms()[i], m_rails_temp[k]->m_connected_net_idx.data()[i], false);
m_terms[k]->set_pointers();
}
@ -268,7 +268,7 @@ namespace devices
{
terms_for_net_t * t = m_terms[k].get();
/* pretty brutal */
int *other = t->connected_net_idx();
int *other = t->m_connected_net_idx.data();
t->m_nz.clear();
@ -290,7 +290,7 @@ namespace devices
{
terms_for_net_t * t = m_terms[k].get();
/* pretty brutal */
int *other = t->connected_net_idx();
int *other = t->m_connected_net_idx.data();
if (k==0)
t->m_nzrd.clear();
@ -371,9 +371,9 @@ namespace devices
state().save(*this, m_terms[k]->m_h_n_m_1, this->name(), "m_h_n_m_1." + num);
// FIXME: This shouldn't be necessary, recalculate on each entry ...
state().save(*this, m_terms[k]->go(),"GO" + num, this->name(), m_terms[k]->count());
state().save(*this, m_terms[k]->gt(),"GT" + num, this->name(), m_terms[k]->count());
state().save(*this, m_terms[k]->Idr(),"IDR" + num, this->name(), m_terms[k]->count());
state().save(*this, m_terms[k]->m_go.data(),"GO" + num, this->name(), m_terms[k]->count());
state().save(*this, m_terms[k]->m_gt.data(),"GT" + num, this->name(), m_terms[k]->count());
state().save(*this, m_terms[k]->m_Idr.data(),"IDR" + num, this->name(), m_terms[k]->count());
}
}

View File

@ -50,11 +50,6 @@ namespace devices
std::size_t count() const { return m_terms.size(); }
terminal_t **terms() { return m_terms.data(); }
int *connected_net_idx() { return m_connected_net_idx.data(); }
nl_double *gt() { return m_gt.data(); }
nl_double *go() { return m_go.data(); }
nl_double *Idr() { return m_Idr.data(); }
nl_double * const *connected_net_V() const { return m_connected_net_V.data(); }
void set_pointers();
@ -105,12 +100,12 @@ namespace devices
nl_double m_DD_n_m_1;
nl_double m_h_n_m_1;
private:
std::vector<int> m_connected_net_idx;
plib::aligned_vector<nl_double, PALIGN_VECTOROPT> m_go;
plib::aligned_vector<nl_double, PALIGN_VECTOROPT> m_gt;
plib::aligned_vector<nl_double, PALIGN_VECTOROPT> m_Idr;
plib::aligned_vector<nl_double *, PALIGN_VECTOROPT> m_connected_net_V;
private:
std::vector<terminal_t *> m_terms;
};
@ -284,7 +279,7 @@ namespace devices
const std::size_t terms_count = terms->count();
const std::size_t railstart = terms->m_railstart;
const float_type * const gt = terms->gt();
const float_type * const gt = terms->m_gt.data();
{
float_type akk = 0.0;
@ -294,8 +289,8 @@ namespace devices
Ak[k] = akk;
}
const float_type * const go = terms->go();
int * net_other = terms->connected_net_idx();
const float_type * const go = terms->m_go.data();
int * net_other = terms->m_connected_net_idx.data();
for (std::size_t i = 0; i < railstart; i++)
Ak[net_other[i]] -= go[i];
@ -315,9 +310,9 @@ namespace devices
float_type rhsk_b = 0.0;
const std::size_t terms_count = m_terms[k]->count();
const float_type * const go = m_terms[k]->go();
const float_type * const Idr = m_terms[k]->Idr();
const float_type * const * other_cur_analog = m_terms[k]->connected_net_V();
const float_type * const go = m_terms[k]->m_go.data();
const float_type * const Idr = m_terms[k]->m_Idr.data();
const float_type * const * other_cur_analog = m_terms[k]->m_connected_net_V.data();
for (std::size_t i = 0; i < terms_count; i++)
rhsk_a = rhsk_a + Idr[i];

View File

@ -167,7 +167,7 @@ void matrix_solver_GCR_t<FT, SIZE>::vsetup(analog_net_t::list_t &nets)
/* build pointers into the compressed row format matrix for each terminal */
for (std::size_t j=0; j< this->m_terms[k]->m_railstart;j++)
{
int other = this->m_terms[k]->connected_net_idx()[j];
int other = this->m_terms[k]->m_connected_net_idx[j];
for (auto i = mat.row_idx[k]; i < mat.row_idx[k+1]; i++)
if (other == static_cast<int>(mat.col_idx[i]))
{

View File

@ -89,7 +89,7 @@ namespace devices
for (std::size_t j=0; j< this->m_terms[k]->m_railstart;j++)
{
for (std::size_t i = m_ops.m_mat.row_idx[k]; i<m_ops.m_mat.row_idx[k+1]; i++)
if (this->m_terms[k]->connected_net_idx()[j] == static_cast<int>(m_ops.m_mat.col_idx[i]))
if (this->m_terms[k]->m_connected_net_idx[j] == static_cast<int>(m_ops.m_mat.col_idx[i]))
{
m_term_cr[k].push_back(&m_ops.m_mat.A[i]);
break;

View File

@ -85,10 +85,10 @@ unsigned matrix_solver_SOR_t<FT, SIZE>::vsolve_non_dynamic(const bool newton_rap
float_type RHS_t = 0.0;
const std::size_t term_count = this->m_terms[k]->count();
const float_type * const gt = this->m_terms[k]->gt();
const float_type * const go = this->m_terms[k]->go();
const float_type * const Idr = this->m_terms[k]->Idr();
auto other_cur_analog = this->m_terms[k]->connected_net_V();
const float_type * const gt = this->m_terms[k]->m_gt.data();
const float_type * const go = this->m_terms[k]->m_go.data();
const float_type * const Idr = this->m_terms[k]->m_Idr.data();
auto other_cur_analog = this->m_terms[k]->m_connected_net_V.data();
this->m_new_V[k] = this->m_nets[k]->Q_Analog();
@ -134,9 +134,9 @@ unsigned matrix_solver_SOR_t<FT, SIZE>::vsolve_non_dynamic(const bool newton_rap
float_type err = 0;
for (std::size_t k = 0; k < iN; k++)
{
const int * net_other = this->m_terms[k]->connected_net_idx();
const int * net_other = this->m_terms[k]->m_connected_net_idx.data();
const std::size_t railstart = this->m_terms[k]->m_railstart;
const float_type * go = this->m_terms[k]->go();
const float_type * go = this->m_terms[k]->m_go.data();
float_type Idrive = 0.0;
for (std::size_t i = 0; i < railstart; i++)