コード例 #1
0
            plib.dynproc m_proc;                          //plib::dynproc<void, FT *, nl_fptype *, nl_fptype *, nl_fptype *, nl_fptype ** > m_proc;


            public matrix_solver_GCR_t(devices.nld_solver main_solver, string name, matrix_solver_t_net_list_t nets, solver.solver_parameters_t params_, size_t size)
                : base(main_solver, name, nets, params_, size)
            {
                mat    = new plib.pGEmatrix_cr <FT, FT_OPS, int_SIZE>((uint16_t)size); //mat(static_cast<typename mat_type::index_type>(size))
                m_proc = new plib.dynproc();


                size_t iN = this.size();

                // build the final matrix

                std.vector <std.vector <unsigned> > fill = new std.vector <std.vector <unsigned> >(iN);
                fill.Fill(() => { return(new std.vector <unsigned>()); });

                size_t raw_elements = 0;

                for (size_t k = 0; k < iN; k++)
                {
                    fill[k].resize(iN, (unsigned)plib.pGEmatrix_cr <FT, FT_OPS, int_SIZE> .constants_e.FILL_INFINITY);
                    foreach (var j in this.m_terms[k].m_nz)
                    {
                        fill[k][j] = 0;
                        raw_elements++;
                    }
                }

                var gr = mat.gaussian_extend_fill_mat(fill);

                this.log_fill(fill, mat);

                mat.build_from_fill_mat(fill);

                for (mat_index_type k = 0; k < iN; k++)
                {
                    size_t cnt = 0;
                    // build pointers into the compressed row format matrix for each terminal
                    for (size_t j = 0; j < this.m_terms[k].railstart(); j++)
                    {
                        int other = this.m_terms[k].m_connected_net_idx[j];
                        for (var i = mat.row_idx[k]; i < mat.row_idx[k + 1]; i++)
                        {
                            if (other == (int)mat.col_idx[i])
                            {
                                this.m_mat_ptr.op(k)[j] = new Pointer <FT>(mat.A, i);  //this->m_mat_ptr[k][j] = &mat.A[i];
                                cnt++;
                                break;
                            }
                        }
                    }

                    nl_assert(cnt == this.m_terms[k].railstart());
                    this.m_mat_ptr.op(k)[this.m_terms[k].railstart()] = new Pointer <FT>(mat.A, mat.diag[k]);  //this->m_mat_ptr[k][this->m_terms[k].railstart()] = &mat.A[mat.diag[k]];
                }

                this.state().log().verbose.op("maximum fill: {0}", gr.first);
                this.state().log().verbose.op("Post elimination occupancy ratio: {1} Ops: {0}", gr.second,
                                              (matrix_solver_t_fptype)mat.nz_num / (matrix_solver_t_fptype)(iN * iN));
                this.state().log().verbose.op(" Pre elimination occupancy ratio: {0}",
                                              (matrix_solver_t_fptype)raw_elements / (matrix_solver_t_fptype)(iN * iN));

                // FIXME: Move me
                //

                if (this.state().static_solver_lib().isLoaded())
                {
                    string symname = static_compile_name();
                    m_proc.load(this.state().static_solver_lib(), symname);
                    if (m_proc.resolved())
                    {
                        this.state().log().info.op("External static solver {0} found ...", symname);
                    }
                    else
                    {
                        this.state().log().warning.op("External static solver {0} not found ...", symname);
                    }
                }
            }
コード例 #2
0
        }                                                                                                                  //void gaussian_back_substitution(V1 &V, const V2 &RHS)

        //template <typename V1>
        //void gaussian_back_substitution(V1 &V)


        //template <typename M>
        void build_parallel_gaussian_execution_scheme(std.vector <std.vector <unsigned> > fill)  //void build_parallel_gaussian_execution_scheme(const M &fill)
        {
            // calculate parallel scheme for gaussian elimination
            std.vector <std.vector <size_t> > rt = new std.vector <std.vector <size_t> >(base.size());
            for (size_t k = 0; k < base.size(); k++)
            {
                rt[k] = new std.vector <size_t>();
                for (size_t j = k + 1; j < base.size(); j++)
                {
                    if (fill[j][k] < (size_t)pmatrix_cr <B, B_OPS, int_N> .constants_e.FILL_INFINITY)
                    {
                        rt[k].push_back(j);
                    }
                }
            }

            std.vector <size_t> levGE = new std.vector <size_t>(base.size(), 0);
            size_t cl = 0;

            for (size_t k = 0; k < base.size(); k++)
            {
                if (levGE[k] >= cl)
                {
                    std.vector <size_t> t = rt[k];
                    for (size_t j = k + 1; j < base.size(); j++)
                    {
                        bool overlap = false;
                        // is there overlap
                        if (plib.container.contains(t, j))
                        {
                            overlap = true;
                        }

                        foreach (var x in rt[j])
                        {
                            if (plib.container.contains(t, x))
                            {
                                overlap = true;
                                break;
                            }
                        }

                        if (overlap)
                        {
                            levGE[j] = cl + 1;
                        }
                        else
                        {
                            t.push_back(j);
                            foreach (var x in rt[j])
                            {
                                t.push_back(x);
                            }
                        }
                    }
                    cl++;
                }
            }

            m_ge_par.clear();
            m_ge_par.resize(cl + 1);
            m_ge_par.Fill(() => { return(new std.vector <size_t>()); });
            for (size_t k = 0; k < base.size(); k++)
            {
                m_ge_par[levGE[k]].push_back(k);
            }

            //for (std::size_t k = 0; k < m_ge_par.size(); k++)
            //  printf("%d %d\n", (int) k, (int) m_ge_par[k].size());
        }