\hypertarget{kdnpgetrf_8c}{}\section{src/kdnpgetrf.c File Reference}
\label{kdnpgetrf_8c}\index{src/kdnpgetrf.\+c@{src/kdnpgetrf.\+c}}


s\+L\+A\+Ss-\/\+D\+D\+Ss kdnpgetrf routine.  


{\ttfamily \#include \char`\"{}../include/lass.\+h\char`\"{}}\\*
Include dependency graph for kdnpgetrf.\+c\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{kdnpgetrf_8c__incl}
\end{center}
\end{figure}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
enum L\+A\+S\+S\+\_\+\+R\+E\+T\+U\+RN \hyperlink{kdnpgetrf_8c_aad8c6b9542e74c481faff1ff5e03850f}{kdnpgetrf} (int M, int N, double $\ast$A, int L\+DA)
\end{DoxyCompactItemize}


\subsection{Detailed Description}
s\+L\+A\+Ss-\/\+D\+D\+Ss kdnpgetrf routine. 

s\+L\+A\+Ss-\/\+D\+D\+Ss is a software package provided by\+: Barcelona Supercomputing Center -\/ Centro Nacional de Supercomputacion

\begin{DoxyAuthor}{Author}
Pedro Valero-\/\+Lara \href{mailto:pedro.valero@bsc.es}{\tt pedro.\+valero@bsc.\+es} 
\end{DoxyAuthor}
\begin{DoxyDate}{Date}
2018-\/07-\/24   
\end{DoxyDate}


\subsection{Function Documentation}
\index{kdnpgetrf.\+c@{kdnpgetrf.\+c}!kdnpgetrf@{kdnpgetrf}}
\index{kdnpgetrf@{kdnpgetrf}!kdnpgetrf.\+c@{kdnpgetrf.\+c}}
\subsubsection[{\texorpdfstring{kdnpgetrf(int M, int N, double $\ast$\+A, int L\+D\+A)}{kdnpgetrf(int M, int N, double *A, int LDA)}}]{\setlength{\rightskip}{0pt plus 5cm}enum L\+A\+S\+S\+\_\+\+R\+E\+T\+U\+RN kdnpgetrf (
\begin{DoxyParamCaption}
\item[{int}]{M, }
\item[{int}]{N, }
\item[{double $\ast$}]{A, }
\item[{int}]{L\+DA}
\end{DoxyParamCaption}
)}\hypertarget{kdnpgetrf_8c_aad8c6b9542e74c481faff1ff5e03850f}{}\label{kdnpgetrf_8c_aad8c6b9542e74c481faff1ff5e03850f}
Performs the LU factorization without pivoting of a general M-\/by-\/N matrix A\+: \begin{DoxyVerb}A = L * U
\end{DoxyVerb}


where L is a lower triangular ( lower trapezoidal if M $>$ N ) matrix with unit diagonal elements and U is an upper triangular ( upper trapezoidal if M $<$ N ) matrix.


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em M} & int. M specifies the number of rows of the matrix A. M $>$= 0.\\
\hline
\mbox{\tt in}  & {\em N} & int. N specifies the number of columns of the matrix A. N $>$= 0.\\
\hline
\mbox{\tt in,out}  & {\em A} & double $\ast$. A is a pointer to a regular matrix of dimension M-\/by-\/N. On exit, if return value is Success, the matrix A is overwriten by the factors L and U. The unit diagonal elements of L are not stored.\\
\hline
\mbox{\tt in}  & {\em L\+DA} & int. L\+DA specifies the number of columns of A ( row-\/major order ). L\+DA must be at least max( 1, N ).\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em Success} & successful exit \\
\hline
{\em No\+Success} & unsuccessful exit\\
\hline
\end{DoxyRetVals}
\begin{DoxySeeAlso}{See also}
\hyperlink{lass_8h_a90f43bdc154edb1979f7ffce22e142ff}{dnpgetrf} 

tune\+\_\+dnpgetrf 

smart\+\_\+dnpgetrf 

ddss\+\_\+tile 

ddss\+\_\+flat2tiled 

ddss\+\_\+tiled2flat 
\end{DoxySeeAlso}


Definition at line 74 of file kdnpgetrf.\+c.



References ddss\+\_\+dflat2tiled(), ddss\+\_\+dtiled2flat(), ddss\+\_\+tile\+\_\+size(), and dnpgetrf().



Referenced by ddss\+\_\+dnpgetrf().


\begin{DoxyCode}
75 \{
76 
77     \textcolor{comment}{// Local variables}
78     \textcolor{keywordtype}{int} mt, nt;
79     \textcolor{keywordtype}{int} mi, mmi, ki, ni, nni, li;
80     \textcolor{keywordtype}{int} tile\_size\_m;
81     \textcolor{keywordtype}{int} tile\_size\_mm;
82     \textcolor{keywordtype}{int} tile\_size\_n;
83     \textcolor{keywordtype}{int} tile\_size\_nn;
84     \textcolor{keywordtype}{int} tile\_size\_k;
85     \textcolor{keywordtype}{int} tile\_size\_km;
86     \textcolor{keywordtype}{int} tile\_size\_kn;
87 
88     \textcolor{comment}{// Number of tiles}
89     \textcolor{keywordflow}{if} ( M % TILE\_SIZE == 0 )
90     \{
91         mt = M / TILE\_SIZE;
92     \}
93     \textcolor{keywordflow}{else}
94     \{
95         mt = ( M / TILE\_SIZE ) + 1;
96     \}
97 
98     \textcolor{keywordflow}{if} ( N % TILE\_SIZE == 0 )
99     \{
100         nt = N / TILE\_SIZE;
101     \}
102     \textcolor{keywordflow}{else}
103     \{
104         nt = ( N / TILE\_SIZE ) + 1;
105     \}
106 
107     \textcolor{comment}{/***************************}
108 \textcolor{comment}{    --Tile A matrix allocation--}
109 \textcolor{comment}{    ***************************/}
110         
111     double (*TILE\_A)[nt][TILE\_SIZE * TILE\_SIZE] = malloc ( mt * nt * 
112         TILE\_SIZE * TILE\_SIZE * \textcolor{keyword}{sizeof}( \textcolor{keywordtype}{double} ) );
113     
114     \textcolor{keywordflow}{if} ( TILE\_A == NULL )
115     \{
116         fprintf( stderr, \textcolor{stringliteral}{"Failure in kdnpgetrf for matrix TILE\_A\(\backslash\)n"} );
117         \textcolor{keywordflow}{return} NoSuccess;
118     \}
119 
120     \textcolor{comment}{/*********************************************}
121 \textcolor{comment}{    --From flat data layout to tiled data layout--  }
122 \textcolor{comment}{    *********************************************/}
123 
124     \hyperlink{ddss__flat2tiled_8c_ab411e9b05a203c7905f0285ef4200a9e}{ddss\_dflat2tiled}( M, N, A, LDA, mt, nt, TILE\_A );
125 
126     \textcolor{comment}{/****************}
127 \textcolor{comment}{    --DNPGETRF tile--}
128 \textcolor{comment}{    ****************/}   
129     
130     \textcolor{keywordflow}{for} ( ki = 0; ki < MIN( mt, nt ); ki++ )
131     \{
132         tile\_size\_km = \hyperlink{ddss__tile_8c_a931442adba78807015ff9a076fb2ae49}{ddss\_tile\_size}( M, ki );
133         tile\_size\_kn = \hyperlink{ddss__tile_8c_a931442adba78807015ff9a076fb2ae49}{ddss\_tile\_size}( N, ki );
134         
135 \textcolor{preprocessor}{        #if defined(LASs\_WITH\_MKL)}
136         
137         tile\_size\_k = MIN( tile\_size\_km, tile\_size\_kn );
138         
139 \textcolor{preprocessor}{        #pragma oss task inout( TILE\_A[ki][ki] ) \(\backslash\)}
140 \textcolor{preprocessor}{                shared( TILE\_A ) \(\backslash\)}
141 \textcolor{preprocessor}{                firstprivate( ki ) \(\backslash\)}
142 \textcolor{preprocessor}{                priority( nt ) \(\backslash\)}
143 \textcolor{preprocessor}{                label( mkl\_dgetrfnpi )}
144         LAPACKE\_mkl\_dgetrfnpi( CblasRowMajor,
145                                tile\_size\_km, tile\_size\_kn,
146                                tile\_size\_k,
147                                TILE\_A[ki][ki], tile\_size\_kn );
148 
149 \textcolor{preprocessor}{        #else}
150 
151 \textcolor{preprocessor}{        #pragma oss task inout( TILE\_A[ki][ki] ) \(\backslash\)}
152 \textcolor{preprocessor}{                shared( TILE\_A ) \(\backslash\)}
153 \textcolor{preprocessor}{                firstprivate( ki ) \(\backslash\)}
154 \textcolor{preprocessor}{                priority( nt ) \(\backslash\)}
155 \textcolor{preprocessor}{                label( dnpgetrf )}
156         \hyperlink{dnpgetrf_8c_a90f43bdc154edb1979f7ffce22e142ff}{dnpgetrf}( tile\_size\_km, tile\_size\_kn,
157                   TILE\_A[ki][ki],
158                   tile\_size\_kn );
159 
160 \textcolor{preprocessor}{        #endif}
161             
162         \textcolor{keywordflow}{for} ( mi = ki + 1; mi < mt; mi++ )
163         \{
164             tile\_size\_m = \hyperlink{ddss__tile_8c_a931442adba78807015ff9a076fb2ae49}{ddss\_tile\_size}( M, mi );
165             
166 \textcolor{preprocessor}{            #pragma oss task in( TILE\_A[ki][ki] ) \(\backslash\)}
167 \textcolor{preprocessor}{                    inout(TILE\_A[mi][ki]) \(\backslash\)}
168 \textcolor{preprocessor}{                    shared( TILE\_A ) \(\backslash\)}
169 \textcolor{preprocessor}{                    firstprivate( mi, ki ) \(\backslash\)}
170 \textcolor{preprocessor}{                    priority( nt ) \(\backslash\)}
171 \textcolor{preprocessor}{                    label( dtrsm\_below )}
172             cblas\_dtrsm( CblasRowMajor, 
173                          ( CBLAS\_SIDE ) Right, ( CBLAS\_UPLO ) Upper, 
174                          ( CBLAS\_TRANSPOSE ) NoTrans, ( CBLAS\_DIAG ) NonUnit, 
175                          tile\_size\_m, tile\_size\_kn, 
176                          1.0, TILE\_A[ki][ki], tile\_size\_kn, 
177                               TILE\_A[mi][ki], tile\_size\_kn );
178         \}
179         \textcolor{keywordflow}{for} ( ni = ki + 1; ni < nt; ni++ )
180         \{
181             tile\_size\_n = \hyperlink{ddss__tile_8c_a931442adba78807015ff9a076fb2ae49}{ddss\_tile\_size}( N, ni );
182             
183 \textcolor{preprocessor}{            #pragma oss task in( TILE\_A[ki][ki] ) \(\backslash\)}
184 \textcolor{preprocessor}{                    inout(TILE\_A[ki][ni]) \(\backslash\)}
185 \textcolor{preprocessor}{                    shared( TILE\_A ) \(\backslash\)}
186 \textcolor{preprocessor}{                    firstprivate( ni, ki ) \(\backslash\)}
187 \textcolor{preprocessor}{                    priority( nt ) \(\backslash\)}
188 \textcolor{preprocessor}{                    label( dtrsm\_right )}
189             cblas\_dtrsm( CblasRowMajor, 
190                          ( CBLAS\_SIDE ) Left, ( CBLAS\_UPLO ) Lower, 
191                          ( CBLAS\_TRANSPOSE ) NoTrans, ( CBLAS\_DIAG ) Unit, 
192                          tile\_size\_km, tile\_size\_n, 
193                          1.0, TILE\_A[ki][ki], tile\_size\_kn, 
194                               TILE\_A[ki][ni], tile\_size\_n );
195         \}
196         
197         \textcolor{keywordflow}{for} ( nni = ki + 1; nni < nt; nni++ )
198         \{
199             tile\_size\_nn = \hyperlink{ddss__tile_8c_a931442adba78807015ff9a076fb2ae49}{ddss\_tile\_size}( N, nni );
200 
201             \textcolor{keywordflow}{for} ( mmi = ki + 1; mmi < mt; mmi++ )
202             \{
203                 tile\_size\_mm = \hyperlink{ddss__tile_8c_a931442adba78807015ff9a076fb2ae49}{ddss\_tile\_size}( M, mmi );
204                                 
205 \textcolor{preprocessor}{                #pragma oss task in( TILE\_A[mmi][ki] ) \(\backslash\)}
206 \textcolor{preprocessor}{                    in( TILE\_A[ki][nni] ) \(\backslash\)}
207 \textcolor{preprocessor}{                    inout( TILE\_A[mmi][nni] ) \(\backslash\)}
208 \textcolor{preprocessor}{                    shared( TILE\_A ) \(\backslash\)}
209 \textcolor{preprocessor}{                    firstprivate( nni, mmi, ki ) \(\backslash\)}
210 \textcolor{preprocessor}{                    priority( nt - nni ) \(\backslash\)}
211 \textcolor{preprocessor}{                    label( dgemm )}
212                 cblas\_dgemm( CblasRowMajor, 
213                              ( CBLAS\_TRANSPOSE ) NoTrans,
214                              ( CBLAS\_TRANSPOSE ) NoTrans,
215                              tile\_size\_mm, 
216                              tile\_size\_nn, 
217                              TILE\_SIZE,
218                              -1.0, TILE\_A[mmi][ki],  tile\_size\_kn,
219                                    TILE\_A[ki][nni],  tile\_size\_nn,
220                               1.0, TILE\_A[mmi][nni], tile\_size\_nn );
221             \}
222         \}
223     \}
224 
225     \textcolor{comment}{// --From tile data layout to flat data layout--    }
226     \hyperlink{ddss__tiled2flat_8c_aeeb6b69c6b4db8333c660ef6824cdf6a}{ddss\_dtiled2flat}( M, N, A, LDA, mt, nt, TILE\_A );
227 
228     \textcolor{comment}{// --Tile A matrix free--}
229     free( TILE\_A );
230 
231     \textcolor{keywordflow}{return} Success;
232 
233 \}
\end{DoxyCode}
