1 /*! \file DissectionQueue.hpp 2 \brief management of threads for factorization and Fw/Bw substitution 3 \author Atsushi Suzuki, Laboratoire Jacques-Louis Lions 4 \date Mar. 30th 2012 5 \date Jul. 12th 2015 6 \date Nov. 30th 2016 7 */ 8 9 // This file is part of Dissection 10 // 11 // Dissection is free software: you can redistribute it and/or modify 12 // it under the terms of the GNU General Public License as published by 13 // the Free Software Foundation, either version 3 of the License, or 14 // (at your option) any later version. 15 // 16 // Linking Dissection statically or dynamically with other modules is making 17 // a combined work based on Disssection. Thus, the terms and conditions of 18 // the GNU General Public License cover the whole combination. 19 // 20 // As a special exception, the copyright holders of Dissection give you 21 // permission to combine Dissection program with free software programs or 22 // libraries that are released under the GNU LGPL and with independent modules 23 // that communicate with Dissection solely through the Dissection-fortran 24 // interface. You may copy and distribute such a system following the terms of 25 // the GNU GPL for Dissection and the licenses of the other code concerned, 26 // provided that you include the source code of that other code when and as 27 // the GNU GPL requires distribution of source code and provided that you do 28 // not modify the Dissection-fortran interface. 29 // 30 // Note that people who make modified versions of Dissection are not obligated 31 // to grant this special exception for their modified versions; it is their 32 // choice whether to do so. The GNU General Public License gives permission to 33 // release a modified version without this exception; this exception also makes 34 // it possible to release a modified version which carries forward this 35 // exception. If you modify the Dissection-fortran interface, this exception 36 // does not apply to your modified version of Dissection, and you must remove 37 // this exception when you distribute your modified version. 38 // 39 // This exception is an additional permission under section 7 of the GNU 40 // General Public License, version 3 ("GPLv3") 41 // 42 // Dissection is distributed in the hope that it will be useful, 43 // but WITHOUT ANY WARRANTY; without even the implied warranty of 44 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 45 // GNU General Public License for more details. 46 // 47 // You should have received a copy of the GNU General Public License 48 // along with Dissection. If not, see <http://www.gnu.org/licenses/>. 49 // 50 51 #ifndef _DISSECTION_QUEUE_ 52 #define _DISSECTION_QUEUE_ 53 #include "Compiler/OptionLibrary.hpp" 54 #include <cassert> 55 #include "Splitters/BisectionTree.hpp" 56 #include "Driver/DissectionMatrix.hpp" 57 #include "Driver/QueueRuntime.hpp" 58 #include "Compiler/elapsed_time.hpp" 59 #include <time.h> 60 #include <string> 61 62 template<typename T, typename U = T> 63 class DissectionQueue 64 { 65 public: 66 DissectionQueue(Dissection::Tree *btree, 67 vector<DissectionMatrix<T, U>*>& dissectionMatrix, 68 const int num_threads, 69 const bool isSym, 70 const bool verbose, 71 FILE *fp); 72 73 ~DissectionQueue(); 74 75 void generate_queue(vector<DissectionMatrix<T, U>*>& dM, 76 int nnz, T *coefs); 77 78 void generate_queue_fwbw(vector<DissectionMatrix<T, U>*>& dissectionMatrix, 79 int dim, int nnz, T *coefs); 80 81 void exec_symb_fact(); 82 83 void exec_num_fact(const int called, 84 const double eps_piv, 85 const bool kernel_detection, 86 const int aug_dim, 87 const U eps_machine, 88 const bool higher_precision); 89 90 void exec_fwbw(T *x, const int nrhs, bool isTrans); 91 void exec_fwbw_seq(T *x, const int nrhs, bool isTrans); 92 93 void erase_queue(void); 94 void erase_queue_fwbw(void); 95 DissectionQueue(const DissectionQueue & s)96 DissectionQueue(const DissectionQueue &s) 97 { 98 _queue_symb = s._queue_symb; 99 _queue_static = s._queue_static; 100 _queue_dynamic = s._queue_dynamic; 101 _pivots = s._pivots; 102 } 103 ChildContribs(int nb)104 list<child_contribution<T> >& ChildContribs(int nb) { 105 return _child_contribs[nb]; 106 } 107 dimension() const108 int dimension() const { return _dim; } nnz() const109 int nnz() const { return _nnz; } 110 111 private: 112 Dissection::Tree* _btree; 113 114 C_task_seq* _queue_symb; // single set of tasks among sparse subdomains 115 C_task_seq* _queue_fwbw; 116 list<C_task_seq*> *_queue_static; 117 vector<C_task_seq *> *_queue_dynamic; 118 list<C_task *> _queue_dummy; 119 vector<int>* _children; 120 vector<C_task *>* _tasks_SparseSymb; 121 vector<C_task *>* _tasks_SparseNum; 122 vector<C_task *>* _tasks_SparseLocalSchur; 123 vector<C_task *>* _tasks_DFillSym; 124 vector<C_task *>* _tasks_DFullLDLt; 125 vector<C_task *>* _tasks_DTRSMScale; 126 vector<C_task *>* _tasks_DSymmGEMM; 127 vector<C_task *>* _tasks_deallocLocalSchur; 128 vector<C_task *>** _tasks_Dsub; 129 vector<C_task *>* _tasks_deallocLower; 130 list<child_contribution<T> > *_child_contribs; 131 132 int _num_threads; 133 int _num_threads_symb; 134 int _dim; 135 int _nnz; 136 int _nb_doms; 137 int _nb_level; 138 139 double _eps_piv; // used in selecting pivot 140 bool _kernel_detection; 141 bool _higher_precision; 142 int _aug_dim; 143 U _eps_machine; // magnitude of numerical perturbation 144 double *_pivots; 145 int _max_size_work_y; 146 list<diag_contribution>* _diag_contribs; 147 T ***_xi; 148 T ***_yi; 149 T ***_zi; 150 T ***_wi; 151 T **_x; // a pointer to keep rhs and solution vectors 152 153 int **_nrhs; // these values contain only address information during 154 bool **_isTrans; 155 // queue generation of fw/bw subtitutions 156 bool _verbose; 157 FILE *_fp; 158 FILE **_fps; 159 bool _isSym; 160 161 QueueRuntime* _dissectionRuntime; 162 bool _queue_symb_allocated; 163 bool _queue_numrc_allocated; 164 bool _queue_fwbw_allocated; 165 166 static const T _one; // (1.0); 167 static const T _zero; // (0.0); 168 static const T _none; // (-1.0); 169 }; // End class DissictionQueue 170 171 #endif 172