SuperLU Distributed 9.0.0
gpu3d
xgstrf2.hpp
Go to the documentation of this file.
1#pragma once
2#include "superlu_defs.h"
3#include "superlu_ddefs.h"
4#include "superlu_sdefs.h"
5#include "superlu_blas.hpp"
6#pragma GCC push_options
7#pragma GCC optimize ("O0")
8
9template<typename Ftype>
10void xgstrf2(int_t k, Ftype* diagBlk, int_t LDA, Ftype* BlockUfactor, int_t LDU,
11 threshPivValType<Ftype> thresh, int_t* xsup,
13 SuperLUStat_t *stat, int *info
14 )
15{
16
17 int_t jfst = FstBlockC(k);
18 // int_t jlst = FstBlockC(k + 1);
19 int_t nsupc = SuperSize(k);
20
21 Ftype *ublk_ptr = BlockUfactor;
22 Ftype *ujrow = BlockUfactor;
23 int_t luptr = 0; /* Point_t to the diagonal entries. */
24 int cols_left = nsupc; /* supernode size */
25
26 for (int_t j = 0; j < nsupc; ++j) /* for each column in panel */
27 {
28 /* Diagonal pivot */
29 int_t i = luptr;
30 /* Not to replace zero pivot. */
31 if (options->ReplaceTinyPivot == YES)
32 {
33 // if (fabs(diagBlk[i]) < thresh)
34 if (std::sqrt(sqnorm(diagBlk[i])) < thresh)
35 { /* Diagonal */
36
37#if (PRNTlevel >= 2)
38 printf("(%d) .. col %d, tiny pivot %e ",
39 iam, jfst + j, diagBlk[i]);
40#endif
41 /* Keep the new diagonal entry with the same sign. */
42 setDiagToThreshold(&diagBlk[i], thresh);
43 // if (diagBlk[i] < 0)
44 // // diagBlk[i] = -thresh;
45 // setDiagToThreshold(&diagBlk[i], -thresh);
46 // else
47 // // diagBlk[i] = thresh;
48 // setDiagToThreshold(&diagBlk[i], thresh);
49#if (PRNTlevel >= 2)
50 printf("replaced by %e\n", diagBlk[i]);
51#endif
52 ++(stat->TinyPivots);
53 }
54 }
55
56 for (int_t l = 0; l < cols_left; ++l, i += LDA)
57 {
58 int_t st = j * LDU + j;
59 ublk_ptr[st + l * LDU] = diagBlk[i]; /* copy one row of U */
60 }
61 Ftype zero = zeroT<Ftype>();
62 if (ujrow[0] == zero) /* Test for singularity. */
63 {
64 *info = j + jfst + 1;
65 }
66 else /* Scale the j-th column. */
67 {
68 Ftype temp;
69 temp = one<Ftype>() / ujrow[0];
70 for (int_t i = luptr + 1; i < luptr - j + nsupc; ++i)
71 diagBlk[i] *= temp;
72 stat->ops[FACT] += nsupc - j - 1;
73 }
74
75 /* Rank-1 update of the trailing submatrix. */
76 if (--cols_left)
77 {
78 /*following must be int*/
79 int l = nsupc - j - 1;
80 int incx = 1;
81 int incy = LDU;
82 /* Rank-1 update */
83 Ftype alpha = -one<Ftype>();
84 superlu_ger<Ftype>(l, cols_left, alpha, &diagBlk[luptr + 1], incx,
85 &ujrow[LDU], incy, &diagBlk[luptr + LDA + 1],
86 LDA);
87 stat->ops[FACT] += 2 * l * cols_left;
88 }
89
90 ujrow = ujrow + LDU + 1; /* move to next row of U */
91 luptr += LDA + 1; /* move to next column */
92
93 } /* for column j ... first loop */
94
95 // printf("Coming to local dgstrf2\n");
96}
97
98
99#pragma GCC pop_options
typename std::conditional< std::is_same< Ftype, float >::value, float, typename std::conditional< std::is_same< Ftype, double >::value||std::is_same< Ftype, doublecomplex >::value, double, float >::type >::type threshPivValType
Definition: luAuxStructTemplated.hpp:70
double sqnorm(float value)
Definition: luAuxStructTemplated.hpp:275
void setDiagToThreshold(double *diagptr, double thresh)
Definition: luAuxStructTemplated.hpp:297
Definition: util_dist.h:101
int TinyPivots
Definition: util_dist.h:105
flops_t * ops
Definition: util_dist.h:104
Definition: superlu_defs.h:728
yes_no_t ReplaceTinyPivot
Definition: superlu_defs.h:750
Distributed SuperLU data types and function prototypes.
Definitions which are precision-neutral.
#define SuperSize(bnum)
Definition: superlu_defs.h:271
#define FstBlockC(bnum)
Definition: superlu_defs.h:270
int64_t int_t
Definition: superlu_defs.h:119
@ YES
Definition: superlu_enum_consts.h:29
@ FACT
Definition: superlu_enum_consts.h:74
Distributed SuperLU data types and function prototypes.
int j
Definition: sutil_dist.c:287
int i
Definition: sutil_dist.c:287
void xgstrf2(int_t k, Ftype *diagBlk, int_t LDA, Ftype *BlockUfactor, int_t LDU, threshPivValType< Ftype > thresh, int_t *xsup, superlu_dist_options_t *options, SuperLUStat_t *stat, int *info)
Definition: xgstrf2.hpp:10