31 static LoggerPtr logger(Logger::getLogger(
"pz.matrix.tpzskylparmatrix"));
35 pthread_mutex_t
skymutex = PTHREAD_MUTEX_INITIALIZER;
37 pthread_cond_t
condition = PTHREAD_COND_INITIALIZER;
47 TPZSkylMatrix<TVar>(dim, skyline),fDec(dim), fCorrectSingular(false)
91 int64_t i,neq=this->
Dim();
92 for(i=0;i<neq;i++)
fDec[i]=skyline[i]-1;
101 cout <<
"Decomposed equations " <<
fEqDec <<
' ' <<
" Thread 'i' working on equation" <<
' ';
104 cout <<
"Columns to work " <<
' ';
105 int64_t neq = this->
Dim();
106 for(i=0; i<neq; i++) cout <<
fDec[i] <<
' ';
108 cout <<
"Singular equations ";
109 std::list<int64_t>::iterator it;
118 int64_t neq = this->
Dim();
119 for(lcol=
fEqDec+1;lcol<neq;lcol++)
129 if(i < fNthreads &&
fThreadUsed[i] == lcol)
continue;
134 lprevcol =
fDec[lcol] + 1;
145 int64_t neq = this->
Dim();
146 int64_t lcolentry = lcol;
148 if(lcolentry < 0 || lcolentry >= neq)
150 LOGPZ_ERROR(logger,
"ColumnToWork called with wrong lcol argument")
156 while(lcol != lcolentry)
164 int decomposeduntil =
fDec[lcol]+1;
165 if(
fDec[decomposeduntil] == decomposeduntil)
168 if (logger->isDebugEnabled()) {
169 std::stringstream sout;
170 sout <<
"Will work column " << lcol;
177 if(lcol == neq) lcol = 0;
179 if(lcol == lcolentry){
189 int64_t aux_col = -1;
190 int64_t col, prevcol;
193 int64_t neq = loc->
Dim();
194 while (loc->
fEqDec < neq-1) {
229 loc->
fDec[col]=prevcol;
232 if(loc->
fEqDec == col-1) {
234 if(!(loc->
fEqDec%100) && loc->
Dim() > 100) {
235 cout << loc->
fEqDec <<
' ';
238 if(!(loc->
fEqDec%1000)) cout << endl;
241 else cout <<
"BIG MISTAKE\n";
258 int64_t aux_col = -1;
259 int64_t col, prevcol;
262 int64_t neq = loc->
Dim();
263 while (loc->
fEqDec < neq-1) {
291 loc->
fDec[col]=prevcol;
294 if(loc->
fEqDec == col-1) {
296 if(!(loc->
fEqDec%100) && loc->
Dim() > 100) {
297 cout << loc->
fEqDec <<
' ';
300 if(!(loc->
fEqDec%1000)) cout << endl;
303 else cout <<
"BIG MISTAKE\n";
320 int64_t col = 0, prevcol;
323 int64_t neq = loc->
Dim();
346 if(loc->
fDec[col] == col)
356 cout <<
"Terminating thread " << pthread_self().x <<
" numthreads = " << loc->
fNthreads <<
" numdecomposed " << loc->
fNumDecomposed << endl;
358 cout <<
"Terminating thread " << pthread_self() <<
" numthreads = " << loc->
fNthreads <<
" numdecomposed " << loc->
fNumDecomposed << endl;
384 int64_t neq = this->
Dim();
386 cout << endl <<
"TPZSkylParMatrix::Decompose_Cholesky() -> Number of Equations = " << neq << endl;
388 cout <<
"Using BLAS " << endl;
392 pthread_t *allthreads =
new pthread_t[
fNthreads-1];
406 for(i=0;i<fNthreads-1;i++) {
412 for(i=0;i<fNthreads-1;i++) {
420 std::stringstream sout;
421 sout <<
"Singular equations ";
422 std::list<int64_t>::iterator it;
429 for(i=0;i<this->
Dim();i++) {
458 int64_t neq = this->
Dim();
460 cout << endl <<
"TPZSkylParMatrix::Decompose_LDLt() -> Number of Equations = " << neq << endl;
462 cout <<
"Using BLAS " << endl;
468 pthread_t *allthreads =
new pthread_t[
fNthreads-1];
481 for(i=0;i<this->
Dim();i++) {
491 for(i=0;i<nthreads-1;i++) {
496 for(i=0;i<nthreads-1;i++) {
505 for(i=0;i<this->
Dim();i++) {
529 int64_t skprev, skcol;
535 ptrprev = this->
Diag(prevcol);
536 ptrcol = this->
Diag(col);
538 if((prevcol-skprev) > (col-skcol)){
539 minline = prevcol - skprev;
542 minline = col - skcol;
544 if(minline > prevcol) {
545 cout <<
"error condition col " << col <<
" prevcol " << prevcol <<
"\n";
549 TVar *run1 = ptrprev + (prevcol-minline);
550 TVar *run2 = ptrcol + (col-minline);
557 while(run1-ptrprev > templatedepth) {
560 sum += TemplateSum<templatedepth>(run1--,run2--);
565 while(run1 != ptrprev) sum += (*run1--)*(*run2--);
569 int64_t n = run1 - ptrprev;
573 sum =
ddot_(&n, run1, &n1, run2, &n2);
592 }
else if (
IsZero(*run2)) {
593 std::cout << __PRETTY_FUNCTION__ <<
" Singular pivot at column " << col;
608 int64_t skprev, skcol;
614 ptrprev = this->
Diag(prevcol);
615 ptrcol = this->
Diag(col);
617 if((prevcol-skprev) > (col-skcol)){
618 minline = prevcol - skprev;
621 minline = col - skcol;
623 if(minline > prevcol) {
624 cout <<
"error condition col " << col <<
" prevcol " << prevcol <<
"\n";
629 TVar *run1 = ptrprev + (prevcol-minline);
630 TVar *run2 = ptrcol + (col-minline);
637 while(run1 != ptrprev) sum += (*run1--)*(*run2--)* *this->
fElem[k++];
643 if (logger->isDebugEnabled())
645 std::stringstream sout;
646 sout <<
"col = " << col <<
" diagonal " << *run2;
662 int64_t skprev, skcol;
667 prevcol =
fDec[col]+1;
671 ptrprev = this->
Diag(prevcol);
672 ptrcol = this->
Diag(col);
674 if((prevcol-skprev) > (col-skcol)){
675 minline = prevcol - skprev;
678 minline = col - skcol;
680 if(minline > prevcol) {
681 cout <<
"error condition col " << col <<
" prevcol " << prevcol <<
"\n";
686 TVar *run1 = ptrprev + (prevcol-minline);
687 TVar *run2 = ptrcol + (col-minline);
694 while(run1 != ptrprev) sum += (*run1--)*(*run2--)* *this->
fElem[k++];
705 if (logger->isDebugEnabled())
707 std::stringstream sout;
708 sout <<
"col = " << col <<
" diagonal " << *run2;
723 cout <<
"Calling constructor"<< endl;
724 int64_t tempo1, tempo2,
tempo;
725 int64_t dim, nequation, limite, kk, steps;
727 cout <<
"Entre o numero de equacoes\n";
729 cout <<
"Entre com o limite\n";
731 cout <<
"Entre com o passo\n";
734 int tempo_par[50], tempo_sin[50], passos[50];
735 cout <<
"Entre o nome do Arquivo\n";
737 ofstream output(filename,ios::app);
765 for(dim=nequation;dim<=limite;dim=dim+steps)
769 for(i=0;i<dim;i++) skyline[i] = 0;
775 if(i%100==0) {cout << i <<
' '; cout.flush();}
776 for(j=skyline[i];j<=i;j++) {
778 double rnd = (random*10.)/RAND_MAX;
780 if(i==j) MySky(i,i)=6000.;
799 cout <<
"VOCE E BURRO MESMO!!!\n";
804 tempo1=time(&t)-
tempo;
805 MySky.
Print(
"Gustavo",output);
809 tempo2=time(&t)-
tempo;
812 misael.
Print(
"misael",output);
814 tempo_par[kk]=tempo1;
815 tempo_sin[kk]=tempo2;
818 output <<
"Multi-threaded ";
820 for(i=0;i<kk;i++) output <<
"{"<< passos[i] <<
"," << tempo_par[i] <<
"},";
822 output <<
"Single-Threaded ";
823 for(i=0;i<kk;i++) output <<
"{"<< passos[i] <<
"," << tempo_sin[i] <<
"},";
#define PZ_PTHREAD_MUTEX_UNLOCK(mutex, fn)
std::set< int64_t > fColUsed
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ fabs
int ClassId() const override
Define the class id associated with the class.
#define PZ_PTHREAD_COND_SIGNAL(cond, fn)
bool IsZero(long double a)
Returns if the value a is close Zero as the allowable tolerance.
Contains definitions to LOGPZ_DEBUG, LOGPZ_INFO, LOGPZ_WARN, LOGPZ_ERROR and LOGPZ_FATAL, and the implementation of the inline InitializePZLOG(string) function using log4cxx library or not. It must to be called out of "#ifdef LOG4CXX" scope.
TPZVec< int64_t > fSkyline
TPZTimeTemp tempo
External variable to TPZTimeTemp (to take time)
Contains TPZSkylParMatrix class which implements a skyline storage format to parallelized process...
int Decompose_LDLt() override
Decomposes the current matrix using LDLt.
void DecomposeColumnLDLt(int64_t lcol, int64_t lprevcol)
void SetSkyline(const TPZVec< int64_t > &skyline)
void DecomposeColumnCholesky(int64_t lcol, int64_t lprevcol)
TPZSkylParMatrix()
Default constructor.
char fDecomposed
Decomposition type used to decompose the current matrix.
pthread_mutex_t skymutex
Semaphore.
int64_t SkyHeight(int64_t col)
return the height of the skyline for a given column
#define LOGPZ_WARN(A, B)
Define log for warnings.
#define PZ_PTHREAD_COND_WAIT(cond, mutex, fn)
Implements a skyline storage format. A Skyline matrix is symmetric so square. Matrix.
TVar * Diag(int64_t col)
This method returns a pointer to the diagonal element of the matrix of the col column.
int Decompose_Cholesky() override
Decomposes the current matrix using Cholesky method. The current matrix has to be symmetric...
#define PZ_PTHREAD_JOIN(thread, val, fn)
void SetSkyline(const TPZVec< int64_t > &skyline)
modify the skyline of the matrix, throwing away its values skyline indicates the minimum row number w...
#define PZ_PTHREAD_MUTEX_LOCK(mutex, fn)
Contains TPZMatrixclass which implements full matrix (using column major representation).
#define DebugStop()
Returns a message to user put a breakpoint in.
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
static void * ParallelLDLt2(void *t)
int Decompose_LDLt() override
Decomposes the current matrix using LDLt.
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ sqrt
Contains several BLAS rotines for linear algebra.
doublereal ddot_(integer *N, doublereal *X, integer *incX, doublereal *Y, integer *incY)
Contains TPZSkyline class which implements a skyline storage format.
TPZVec< TVar * > fElem
Storage to keep the first elements to each equation.
#define LOGPZ_ERROR(A, B)
Define log for errors (cout)
virtual int64_t Dim() const
Returns the dimension of the matrix if the matrix is square.
pthread_cond_t condition
Condition to waiting.
int32_t Hash(std::string str)
virtual ~TPZSkylParMatrix()
Default destructor.
int Decompose_LDLt(std::list< int64_t > &singular) override
Decomposes the current matrix using LDLt. The current matrix has to be symmetric. "L" is lower triangular with 1.0 in its diagonal and "D" is a Diagonal matrix.
Implements a skyline storage format to parallelized process. Matrix.
std::list< int64_t > fSingular
void DecomposeColumnLDLt2(int64_t lcol)
#define PZ_PTHREAD_CREATE(thread, attr, routine, args, fn)
static void * ParallelLDLt(void *t)
void DecomposeColumn(int64_t col, int64_t prevcol)
virtual void Print(std::ostream &out) const
int ClassId() const override
Define the class id associated with the class.
static void * ParallelCholesky(void *t)
void ColumnToWork(int64_t &lcol, int64_t &lprevcol)
Determine which column can be decomposed with respect to which column.
#define PZ_PTHREAD_COND_BROADCAST(cond, fn)