\hypertarget{kdpotrf_8c}{}\section{src/kdpotrf.c File Reference}
\label{kdpotrf_8c}\index{src/kdpotrf.\+c@{src/kdpotrf.\+c}}


L\+A\+Ss-\/\+D\+D\+Ss kdpotrf routine.  


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


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

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}
2017-\/24-\/10   
\end{DoxyDate}


\subsection{Function Documentation}
\index{kdpotrf.\+c@{kdpotrf.\+c}!kdpotrf@{kdpotrf}}
\index{kdpotrf@{kdpotrf}!kdpotrf.\+c@{kdpotrf.\+c}}
\subsubsection[{\texorpdfstring{kdpotrf(enum D\+D\+S\+S\+\_\+\+U\+P\+L\+O U\+P\+L\+O, int N, double $\ast$\+A, int L\+D\+A)}{kdpotrf(enum DDSS_UPLO UPLO, int N, double *A, int LDA)}}]{\setlength{\rightskip}{0pt plus 5cm}enum L\+A\+S\+S\+\_\+\+R\+E\+T\+U\+RN kdpotrf (
\begin{DoxyParamCaption}
\item[{enum D\+D\+S\+S\+\_\+\+U\+P\+LO}]{U\+P\+LO, }
\item[{int}]{N, }
\item[{double $\ast$}]{A, }
\item[{int}]{L\+DA}
\end{DoxyParamCaption}
)}\hypertarget{kdpotrf_8c_a561483d08d424c9a13076e0ae998cabd}{}\label{kdpotrf_8c_a561483d08d424c9a13076e0ae998cabd}
Performs the Cholesky factorization of a symmetric positive definite matrix A\+: \begin{DoxyVerb}A = L \times L^T
or
A = U^T \times U
\end{DoxyVerb}


where L is a lower triangular matrix and U is an upper triangular matrix.


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em U\+P\+LO} & enum D\+D\+S\+S\+\_\+\+U\+P\+LO. U\+P\+LO specifies the form of A is stored\+:
\begin{DoxyItemize}
\item Lower\+: Lower triangle of A is stored. The upper traingular part is not referenced.
\item Upper\+: Upper triangle of A is stored. The lower triangular part is not referenced.
\end{DoxyItemize}\\
\hline
\mbox{\tt in}  & {\em N} & int. N specifies the order of the square matrix A. N $>$= 0.\\
\hline
\mbox{\tt in,out}  & {\em A} & double $\ast$. A is a pointer to a positive definite matrix of dimension N by L\+DA. On exit, if return value is Success, the matrix A is overwriten by the factor U or L.\\
\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} & sucessful exit \\
\hline
{\em No\+Success} & unsucessful exit\\
\hline
\end{DoxyRetVals}
\begin{DoxySeeAlso}{See also}
\hyperlink{lass_8h_a7b849eccd797212a1ce50ee598bde5e2}{ddss\+\_\+dpotrf} 

ddss\+\_\+tile 

ddss\+\_\+symflat2tiled 

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


Definition at line 78 of file kdpotrf.\+c.



References ddss\+\_\+dsymflat2tiled(), ddss\+\_\+dsymtiled2flat(), and ddss\+\_\+tile\+\_\+size().



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


\begin{DoxyCode}
79 \{
80 
81     \textcolor{comment}{// Local variables}
82     \textcolor{keywordtype}{int} nt;
83     \textcolor{keywordtype}{int} mi, mmi, ki, ni;
84     \textcolor{keywordtype}{int} Am;
85     \textcolor{keywordtype}{int} An;
86     \textcolor{keywordtype}{int} tile\_size\_m;
87     \textcolor{keywordtype}{int} tile\_size\_mm;
88     \textcolor{keywordtype}{int} tile\_size\_n;
89     \textcolor{keywordtype}{int} tile\_size\_k;
90     \textcolor{keywordtype}{int} k\_check;
91     \textcolor{keywordtype}{double} betat;
92 
93     \textcolor{comment}{// Number of tiles}
94     \textcolor{keywordflow}{if} ( N % TILE\_SIZE == 0 )
95     \{
96         nt = N / TILE\_SIZE;
97     \}
98     \textcolor{keywordflow}{else}
99     \{
100         nt = ( N / TILE\_SIZE ) + 1;
101     \}
102     
103     \textcolor{comment}{/****************************}
104 \textcolor{comment}{    --Tile A matrix declaration--}
105 \textcolor{comment}{    ****************************/}
106 
107     Am = nt;
108     An = nt;
109     
110     \textcolor{comment}{/***************************}
111 \textcolor{comment}{    --Tile A matrix allocation--}
112 \textcolor{comment}{    ***************************/}
113         
114     double (*TILE\_A)[An][TILE\_SIZE * TILE\_SIZE] = malloc ( Am * An * 
115         TILE\_SIZE * TILE\_SIZE * \textcolor{keyword}{sizeof}( \textcolor{keywordtype}{double} ) );
116     
117     \textcolor{keywordflow}{if} ( TILE\_A == NULL)
118     \{
119         fprintf( stderr, \textcolor{stringliteral}{"Failure in kdpotrf for matrix TILE\_A\(\backslash\)n"} );
120         \textcolor{keywordflow}{return} NoSuccess;
121     \}
122 
123     \textcolor{comment}{/************************************************}
124 \textcolor{comment}{    // --From flat data layout to tiled data layout--   }
125 \textcolor{comment}{    ************************************************/}
126 
127     \hyperlink{ddss__flat2tiled_8c_afc5c48ad2172946afab6c9e989c4e81a}{ddss\_dsymflat2tiled}( N, N, A, LDA, nt, nt, TILE\_A, UPLO );
128 
129     \textcolor{comment}{/**************}
130 \textcolor{comment}{    --DPOTRF tile--}
131 \textcolor{comment}{    **************/} 
132 
133     \textcolor{keywordflow}{if} ( UPLO == Lower )
134     \{   
135         \textcolor{comment}{// --UPLO = Lower-- }
136         \textcolor{keywordflow}{for} ( ki = 0; ki < nt; ki++ )
137         \{
138             tile\_size\_k = \hyperlink{ddss__tile_8c_a931442adba78807015ff9a076fb2ae49}{ddss\_tile\_size}( N, ki );
139     
140 \textcolor{preprocessor}{            #pragma oss task inout( TILE\_A[ki][ki] ) \(\backslash\)}
141 \textcolor{preprocessor}{                firstprivate( ki ) \(\backslash\)}
142 \textcolor{preprocessor}{                label( dpotrf )}
143             LAPACKE\_dpotrf\_work( LAPACK\_ROW\_MAJOR, 
144                              \textcolor{charliteral}{'L'},
145                              tile\_size\_k, TILE\_A[ki][ki], tile\_size\_k );
146 
147             \textcolor{keywordflow}{for} ( mi = ki + 1; mi < nt; mi++ )
148             \{
149                 tile\_size\_m = \hyperlink{ddss__tile_8c_a931442adba78807015ff9a076fb2ae49}{ddss\_tile\_size}( N, mi );
150             
151 \textcolor{preprocessor}{                #pragma oss task in( TILE\_A[ki][ki] ) \(\backslash\)}
152 \textcolor{preprocessor}{                    inout(TILE\_A[mi][ki]) \(\backslash\)}
153 \textcolor{preprocessor}{                    firstprivate( mi, ki ) \(\backslash\)}
154 \textcolor{preprocessor}{                    label( dtrsm )}
155                 cblas\_dtrsm( CblasRowMajor, 
156                              ( CBLAS\_SIDE ) Right, ( CBLAS\_UPLO ) Lower, 
157                              ( CBLAS\_TRANSPOSE ) Trans, ( CBLAS\_DIAG ) NonUnit, 
158                              tile\_size\_m, TILE\_SIZE, 
159                              1.0, TILE\_A[ki][ki], TILE\_SIZE, 
160                                   TILE\_A[mi][ki], TILE\_SIZE );
161             \}
162             \textcolor{keywordflow}{for} ( mmi = ki + 1; mmi < nt; mmi++ )
163             \{
164                 tile\_size\_mm = \hyperlink{ddss__tile_8c_a931442adba78807015ff9a076fb2ae49}{ddss\_tile\_size}( N, mmi );
165             
166 \textcolor{preprocessor}{                #pragma oss task in( TILE\_A[mmi][ki] ) \(\backslash\)}
167 \textcolor{preprocessor}{                    inout( TILE\_A[mmi][mmi] ) \(\backslash\)}
168 \textcolor{preprocessor}{                    firstprivate( mmi, ki ) \(\backslash\)}
169 \textcolor{preprocessor}{                    label( dsyrk )}
170                 cblas\_dsyrk( CblasRowMajor, 
171                              ( CBLAS\_UPLO ) Lower, ( CBLAS\_TRANSPOSE ) NoTrans, 
172                              tile\_size\_mm, TILE\_SIZE, 
173                              -1.0,  TILE\_A[mmi][ki], TILE\_SIZE, 
174                               1.0, TILE\_A[mmi][mmi], tile\_size\_mm );
175             
176                 \textcolor{keywordflow}{for} ( ni = ki + 1; ni < mmi; ni++ )
177                 \{
178                 
179 \textcolor{preprocessor}{                    #pragma oss task in( TILE\_A[mmi][ki] ) \(\backslash\)}
180 \textcolor{preprocessor}{                        in( TILE\_A[ni][ki] ) \(\backslash\)}
181 \textcolor{preprocessor}{                        inout( TILE\_A[mmi][ni] ) \(\backslash\)}
182 \textcolor{preprocessor}{                        firstprivate( ni, mmi, ki ) \(\backslash\)}
183 \textcolor{preprocessor}{                        label( dgemm )}
184                         cblas\_dgemm( CblasRowMajor, 
185                                      ( CBLAS\_TRANSPOSE ) NoTrans,
186                                      ( CBLAS\_TRANSPOSE ) Trans,
187                                      TILE\_SIZE, 
188                                      TILE\_SIZE, 
189                                      TILE\_SIZE,
190                                      -1.0, TILE\_A[mmi][ki], TILE\_SIZE,
191                                             TILE\_A[ni][ki], TILE\_SIZE,
192                                       1.0, TILE\_A[mmi][ni], TILE\_SIZE );
193                 \}
194             \}
195         \}
196     \}
197     \textcolor{keywordflow}{else}
198     \{
199         \textcolor{comment}{// --UPLO = Upper-- }
200         \textcolor{keywordflow}{for} ( ki = 0; ki < nt; ki++ )
201         \{
202             tile\_size\_k = \hyperlink{ddss__tile_8c_a931442adba78807015ff9a076fb2ae49}{ddss\_tile\_size}( N, ki );
203             
204 \textcolor{preprocessor}{            #pragma oss task inout( TILE\_A[ki][ki] ) \(\backslash\)}
205 \textcolor{preprocessor}{                shared( TILE\_A ) \(\backslash\)}
206 \textcolor{preprocessor}{                firstprivate( ki ) \(\backslash\)}
207 \textcolor{preprocessor}{                label( dpotrf )}
208             LAPACKE\_dpotrf\_work( LAPACK\_ROW\_MAJOR, 
209                              \textcolor{charliteral}{'U'},
210                              tile\_size\_k, TILE\_A[ki][ki], 
211                              tile\_size\_k );
212 
213             \textcolor{keywordflow}{for} ( mi = ki + 1; mi < nt; mi++ )
214             \{
215                 tile\_size\_m = \hyperlink{ddss__tile_8c_a931442adba78807015ff9a076fb2ae49}{ddss\_tile\_size}( N, mi );
216             
217 \textcolor{preprocessor}{                #pragma oss task in( TILE\_A[ki][ki] ) \(\backslash\)}
218 \textcolor{preprocessor}{                    inout(TILE\_A[ki][mi]) \(\backslash\)}
219 \textcolor{preprocessor}{                    shared( TILE\_A ) \(\backslash\)}
220 \textcolor{preprocessor}{                    firstprivate( mi, ki ) \(\backslash\)}
221 \textcolor{preprocessor}{                    label( dtrsm )}
222                 cblas\_dtrsm( CblasRowMajor, 
223                              ( CBLAS\_SIDE ) Left, ( CBLAS\_UPLO ) Upper, 
224                              ( CBLAS\_TRANSPOSE ) Trans, ( CBLAS\_DIAG ) NonUnit, 
225                              TILE\_SIZE, tile\_size\_m, 
226                              1.0, TILE\_A[ki][ki], TILE\_SIZE, 
227                                   TILE\_A[ki][mi], tile\_size\_m );
228             \}
229             \textcolor{keywordflow}{for} ( mmi = ki + 1; mmi < nt; mmi++ )
230             \{
231                 tile\_size\_mm = \hyperlink{ddss__tile_8c_a931442adba78807015ff9a076fb2ae49}{ddss\_tile\_size}( N, mmi );
232             
233 \textcolor{preprocessor}{                #pragma oss task in( TILE\_A[ki][mmi] ) \(\backslash\)}
234 \textcolor{preprocessor}{                    inout( TILE\_A[mmi][mmi] ) \(\backslash\)}
235 \textcolor{preprocessor}{                    shared( TILE\_A ) \(\backslash\)}
236 \textcolor{preprocessor}{                    firstprivate( mmi, ki ) \(\backslash\)}
237 \textcolor{preprocessor}{                    label( dsyrk )}
238                 cblas\_dsyrk( CblasRowMajor, 
239                              ( CBLAS\_UPLO ) Upper, ( CBLAS\_TRANSPOSE ) Trans, 
240                              tile\_size\_mm, TILE\_SIZE, 
241                              -1.0,  TILE\_A[ki][mmi], tile\_size\_mm, 
242                               1.0, TILE\_A[mmi][mmi], tile\_size\_mm );
243             
244                 \textcolor{keywordflow}{for} ( ni = ki + 1; ni < mmi; ni++ )
245                 \{
246 \textcolor{preprocessor}{                    #pragma oss task in( TILE\_A[ki][ni] ) \(\backslash\)}
247 \textcolor{preprocessor}{                        in( TILE\_A[ki][mmi] ) \(\backslash\)}
248 \textcolor{preprocessor}{                        inout( TILE\_A[ni][mmi] ) \(\backslash\)}
249 \textcolor{preprocessor}{                        shared( TILE\_A ) \(\backslash\)}
250 \textcolor{preprocessor}{                        firstprivate( ni, mmi, ki ) \(\backslash\)}
251 \textcolor{preprocessor}{                        label( dgemm )}
252                         cblas\_dgemm( CblasRowMajor, 
253                                      ( CBLAS\_TRANSPOSE ) Trans,
254                                      ( CBLAS\_TRANSPOSE ) NoTrans,
255                                      TILE\_SIZE, 
256                                      TILE\_SIZE, 
257                                      TILE\_SIZE,
258                                      -1.0, TILE\_A[ki][ni],  TILE\_SIZE,
259                                            TILE\_A[ki][mmi], TILE\_SIZE,
260                                       1.0, TILE\_A[ni][mmi], TILE\_SIZE );
261                 \}
262             \}
263         \}
264     \}
265 
266     \textcolor{comment}{// --From tile data layout to flat data layout--    }
267     \hyperlink{ddss__tiled2flat_8c_a7a0f7b98f2430148a5f99fc403309816}{ddss\_dsymtiled2flat}( N, N, A, LDA, nt, nt, TILE\_A, UPLO );
268 
269     \textcolor{comment}{// --Tile A matrix free--}
270     free( TILE\_A );
271 
272     \textcolor{keywordflow}{return} Success;
273 
274 \}
\end{DoxyCode}
