Previous 199869 Revisions Next

r30709 Thursday 29th May, 2014 at 16:45:20 UTC by Couriersud
Further work on vectorization. Works, but not yet finished.
[src/emu/netlist]nl_base.c nl_base.h plists.h
[src/emu/netlist/analog]nld_solver.c nld_solver.h

trunk/src/emu/netlist/nl_base.h
r30708r30709
460460
461461   netlist_terminal_t *m_otherterm;
462462
463   // used by gauss-seidel-solver
464
465   double * RESTRICT m_new_analog_ptr;
466
467463protected:
468464   ATTR_COLD virtual void save_register();
469465
trunk/src/emu/netlist/analog/nld_solver.c
r30708r30709
7878               }
7979               {
8080                  netlist_terminal_t *pterm = dynamic_cast<netlist_terminal_t *>(p);
81                  // for gauss seidel
82                     pterm->m_new_analog_ptr = &pterm->m_otherterm->net().as_analog().m_new_Analog;
83#if 0
84                  if (pterm->m_otherterm->net().isRailNet())
85                     m_nets[k].m_rails.add(pterm);
86                  else
87                      m_nets[k].m_terms.add(pterm);
88#endif
8981                  add_term(k, pterm);
9082               }
9183               NL_VERBOSE_OUT(("Added terminal\n"));
r30708r30709
336328    if (term->m_otherterm->net().isRailNet())
337329    {
338330        //m_nets[k].m_rails.add(pterm);
339        m_rails[k].add(terms_t(term, -1));
331        m_rails[k].add(term, -1);
340332    }
341333    else
342334    {
343335        int ot = get_net_idx(&term->m_otherterm->net());
344336        if (ot>=0)
345337        {
346            m_terms[k].add(terms_t(term, ot));
338            m_terms[k].add(term, ot);
347339            SOLVER_VERBOSE_OUT(("Net %d Term %s %f %f\n", k, terms[i]->name().cstr(), terms[i]->m_gt, terms[i]->m_go));
348340        }
349341        /* Should this be allowed ? */
350342        else // if (ot<0)
351343        {
352           m_rails[k].add(terms_t(term, ot));
344           m_rails[k].add(term, ot);
353345           netlist().error("found term with missing othernet %s\n", term->name().cstr());
354346        }
355347    }
r30708r30709
424416        double rhsk = 0.0;
425417        double akk  = 0.0;
426418        const int terms_count = m_terms[k].count();
427        const terms_t *terms = m_terms[k];
419        const netlist_terminal_t * const *terms = m_terms[k].terms();
420        const int *net_other = m_terms[k].net_other();
428421
429422        for (int i = 0; i < terms_count; i++)
430423      {
431424            //printf("A %d %d %s %f %f\n",t.net_this, t.net_other, t.term->name().cstr(), t.term->m_gt, t.term->m_go);
432425
433            rhsk = rhsk + terms[i].m_term->m_Idr;
434            akk = akk + terms[i].m_term->m_gt;
435            m_A[k][terms[i].m_net_other] += -terms[i].m_term->m_go;
426            rhsk = rhsk + terms[i]->m_Idr;
427            akk = akk + terms[i]->m_gt;
428            m_A[k][net_other[i]] += -terms[i]->m_go;
436429      }
437430
438431        const int rails_count = m_rails[k].count();
439        const terms_t *rails = m_rails[k];
432        const netlist_terminal_t * const *rails = m_rails[k].terms();
440433
441434        for (int i = 0; i < rails_count; i++)
442435        {
443            const terms_t t = rails[i];
444
445            rhsk = rhsk + t.m_term->m_Idr + t.m_term->m_go * t.m_term->m_otherterm->net().as_analog().Q_Analog();
446            akk = akk + t.m_term->m_gt;
436            rhsk = rhsk + rails[i]->m_Idr + rails[i]->m_go * rails[i]->m_otherterm->net().as_analog().Q_Analog();
437            akk = akk + rails[i]->m_gt;
447438        }
448439        m_RHS[k] = rhsk;
449440        m_A[k][k] += akk;
r30708r30709
738729   double w[_storage_N];
739730   double one_m_w[_storage_N];
740731   double RHS[_storage_N];
732   double new_V[_storage_N];
741733
742734    for (int k = 0; k < iN; k++)
743735    {
744        this->m_nets[k]->m_new_Analog = this->m_nets[k]->m_cur_Analog;
736        new_V[k] = this->m_nets[k]->m_new_Analog = this->m_nets[k]->m_cur_Analog;
745737    }
746738
747739   for (int k = 0; k < iN; k++)
r30708r30709
750742      double gabs_t = 0.0;
751743      double RHS_t = 0.0;
752744
753        const typename netlist_matrix_solver_direct_t<m_N, _storage_N>::xlist_t &terms = this->m_terms[k];
754        const typename netlist_matrix_solver_direct_t<m_N, _storage_N>::xlist_t &rails = this->m_rails[k];
755      const int term_count = terms.count();
756      const int rail_count = rails.count();
745      {
746           const netlist_terminal_t * const * rails = this->m_rails[k].terms();
747           //const int * othernet = this->m_rails[k].m_othernet;
748           const int rail_count = this->m_rails[k].count();
757749
758      for (int i = 0; i < rail_count; i++)
750           for (int i = 0; i < rail_count; i++)
751           {
752               const netlist_terminal_t *rail = rails[i];
753               gtot_t += rail->m_gt;
754               gabs_t += fabs(rail->m_go);
755               RHS_t += rail->m_Idr;
756               // this may point to a rail net ...
757               RHS_t += rail->m_go * rail->m_otherterm->net().as_analog().Q_Analog();
758           }
759      }
759760      {
760          const netlist_terminal_t *rail = rails[i].m_term;
761            gtot_t += rail->m_gt;
762            gabs_t += fabs(rail->m_go);
763            RHS_t += rail->m_Idr;
764            RHS_t += rail->m_go * rail->m_otherterm->net().as_analog().Q_Analog();
765      }
761            const netlist_terminal_t * const * terms = this->m_terms[k].terms();
762            const int term_count = this->m_terms[k].count();
766763
767      for (int i = 0; i < term_count; i++)
768      {
769            const netlist_terminal_t *term = terms[i].m_term;
770         gtot_t += term->m_gt;
771         gabs_t += fabs(term->m_go);
772         RHS_t += term->m_Idr;
764            for (int i = 0; i < term_count; i++)
765            {
766                const netlist_terminal_t *term = terms[i];
767                gtot_t += term->m_gt;
768                gabs_t += fabs(term->m_go);
769                RHS_t += term->m_Idr;
770            }
773771      }
774
775772      gabs_t *= 1.0;
776773      if (gabs_t > gtot_t)
777774      {
r30708r30709
794791
795792      for (int k = 0; k < iN; k++)
796793      {
797         netlist_analog_net_t & RESTRICT net = *this->m_nets[k];
798           const typename netlist_matrix_solver_direct_t<m_N, _storage_N>::xlist_t &terms = this->m_terms[k];
799         const int term_count = terms.count();
794         //netlist_analog_net_t & RESTRICT net = *this->m_nets[k];
795           const netlist_terminal_t * const * terms = this->m_terms[k].terms();
796            const int * net_other = this->m_terms[k].net_other();
797         const int term_count = this->m_terms[k].count();
798
800799         double Idrive = 0;
801800
802801            for (int i = 0; i < term_count; i++)
803                Idrive += terms[i].m_term->m_go * *(terms[i].m_term->m_new_analog_ptr);
802                Idrive += terms[i]->m_go * new_V[net_other[i]];
804803
805804            //double new_val = (net->m_cur_Analog * gabs[k] + iIdr) / (gtot[k]);
806         const double new_val = net.m_new_Analog * one_m_w[k] + (Idrive + RHS[k]) * w[k];
805         const double new_val = new_V[k] * one_m_w[k] + (Idrive + RHS[k]) * w[k];
807806
808         const double e = (new_val - net.m_new_Analog);
809         cerr = (fabs(e) > cerr ? fabs(e) : cerr);
807         const double e = fabs(new_val - new_V[k]);
808         cerr = (e > cerr ? e : cerr);
810809
811         net.m_new_Analog = new_val;
810         new_V[k] = new_val;
812811      }
813812      if (cerr > this->m_params.m_accuracy)
814813      {
r30708r30709
817816      resched_cnt++;
818817   } while (resched && (resched_cnt < this->m_params.m_gs_loops));
819818
819    for (int k = 0; k < iN; k++)
820    {
821        this->m_nets[k]->m_new_Analog = this->m_nets[k]->m_cur_Analog = new_V[k];
822    }
823
824
820825   this->m_gs_total += resched_cnt;
821826   if (resched)
822827   {
r30708r30709
829834   else {
830835       this->m_calculations++;
831836
832       for (int k = 0; k < this->N(); k++)
833           this->m_nets[k]->m_cur_Analog = this->m_nets[k]->m_new_Analog;
837       //for (int k = 0; k < this->N(); k++)
838       //    this->m_nets[k]->m_cur_Analog = this->m_nets[k]->m_new_Analog;
834839
835840       return resched_cnt;
836841   }
trunk/src/emu/netlist/analog/nld_solver.h
r30708r30709
7070
7171protected:
7272
73    class ATTR_ALIGNED(64) terms_t{
74
75    public:
76        terms_t() {}
77
78        void clear()
79        {
80            m_term.clear();
81            m_net_other.clear();
82        }
83
84        void add(netlist_terminal_t *term, int net_other)
85        {
86            m_term.add(term);
87            m_net_other.add(net_other);
88        }
89
90        inline int count() { return m_term.count(); }
91
92        inline netlist_terminal_t **terms() { return m_term; }
93        inline int *net_other() { return m_net_other; }
94
95    private:
96        plinearlist_t<netlist_terminal_t *> m_term;
97        plinearlist_t<int> m_net_other;
98
99    };
100
73101    ATTR_COLD void setup(netlist_analog_net_t::list_t &nets);
74102
75103    // return true if a reschedule is needed ...
r30708r30709
137165    ATTR_ALIGNED(64) double m_RHS[_storage_N];
138166    ATTR_ALIGNED(64) double m_last_RHS[_storage_N]; // right hand side - contains currents
139167
140   struct ATTR_ALIGNED(64) terms_t{
141
142        terms_t(netlist_terminal_t *term, int net_other)
143        : m_term(term), m_net_other(net_other)
144       {}
145        terms_t()
146        : m_term(NULL), m_net_other(-1)
147        {}
148
149        ATTR_ALIGNED(64) netlist_terminal_t ATTR_ALIGNED(64) *  RESTRICT m_term;
150      int m_net_other;
151   };
152
153    typedef plinearlist_t<terms_t> xlist_t;
154    xlist_t m_terms[_storage_N];
155    xlist_t m_rails[_storage_N];
168    terms_t m_terms[_storage_N];
169    terms_t m_rails[_storage_N];
156170    plinearlist_t<double> xx[_storage_N];
157171
158172private:
trunk/src/emu/netlist/plists.h
r30708r30709
6565   }
6666
6767   ATTR_HOT inline operator _ListClass *  () { return m_list; }
68    ATTR_HOT inline operator const _ListClass * const () { return m_list; }
68    ATTR_HOT inline operator const _ListClass * () const { return m_list; }
6969
7070    /* using the [] operator will not allow gcc to vectorize code because
7171     * basically a pointer is returned.
trunk/src/emu/netlist/nl_base.c
r30708r30709
771771, m_go(NETLIST_GMIN_DEFAULT)
772772, m_gt(NETLIST_GMIN_DEFAULT)
773773, m_otherterm(NULL)
774, m_new_analog_ptr(NULL)
775774{
776775}
777776

Previous 199869 Revisions Next


© 1997-2024 The MAME Team