LASs - Linear Algebra Routines on OmpSs  1.0.0
LASs
ddss_tiled2flat.c
Go to the documentation of this file.
1 #include "../include/lass.h"
2 
3 /**
4  *
5  * @file ddss_tiled2flat.c
6  *
7  * @brief LASs-DDSs ddss_tiled2flat routines.
8  *
9  * LASs-DDSs is a software package provided by:
10  * Barcelona Supercomputing Center - Centro Nacional de Supercomputacion
11  *
12  * @author Pedro Valero-Lara pedro.valero@bsc.es
13  * @date 2017-05-10
14  * @reviewer
15  * @modified
16  *
17  **/
18 
19 /**
20  *
21  * @ingroup DDSs
22  *
23  * ddss_dtiled2flat:
24  * Performs the change of the data layout from tile layout to flat layout
25  * according to row-major order.
26  *
27 **/
28 
29 /**
30  *
31  * @param[in]
32  * M int.
33  * M specifies the number of rows of the flat matrix.
34  *
35  * @param[in]
36  * N int.
37  * N specifies the number of columns of the flat matrix.
38  *
39  * @param[in, out]
40  * A double *.
41  * A is a pointer to the flat matrix.
42  *
43  * @param[in]
44  * LDA int.
45  * LDA specifies the number of columns ( row-major order ) of matrix A.
46  *
47  * @param[in]
48  * MT int.
49  * MT specifies the number of rows of the matrix TILE_A.
50  *
51  * @param[in]
52  * NT int.
53  * NT specifies the number of columns of the matrix TILE_A.
54  *
55  * @param[in]
56  * TILE_A double *.
57  * TILE_A is a pointer to the tile matrix.
58  *
59  **/
60 
61 /**
62  *
63  * @sa ddss_dscatter_tile
64  * @sa ddss_tile_size
65  *
66  **/
67 
68 void ddss_dtiled2flat( int M, int N, double *A, int LDA, int MT, int NT,
69  double (*TILE_A)[NT][TILE_SIZE * TILE_SIZE] )
70 {
71 
72  // Local variables
73  int m, n;
74 
75  for ( m = 0; m < MT; m++ )
76  {
77  for ( n = 0; n < NT; n++ )
78  {
79  #pragma oss task inout(TILE_A[m][n]) \
80  label( dtiled2flat)
81  {
82  ddss_dscatter_tile( M, N,
83  &A[m * TILE_SIZE * N + n * TILE_SIZE], LDA,
84  TILE_A[m][n], m, n );
85  }
86  }
87  }
88 
89  #pragma oss taskwait
90 
91 }
92 
93 /**
94  *
95  * @ingroup DDSs
96  *
97  * ddss_dtiled2flat_nb:
98  * Performs the change of the data layout from tile layout to flat layout
99  * according to row-major order in a non-blocking execution mode.
100  *
101 **/
102 
103 /**
104  *
105  * @param[in]
106  * M int.
107  * M specifies the number of rows of the flat matrix.
108  *
109  * @param[in]
110  * N int.
111  * N specifies the number of columns of the flat matrix.
112  *
113  * @param[in, out]
114  * A double *.
115  * A is a pointer to the flat matrix.
116  *
117  * @param[in]
118  * LDA int.
119  * LDA specifies the number of columns ( row-major order ) of matrix A.
120  *
121  * @param[in]
122  * MT int.
123  * MT specifies the number of rows of the matrix TILE_A.
124  *
125  * @param[in]
126  * NT int.
127  * NT specifies the number of columns of the matrix TILE_A.
128  *
129  * @param[in]
130  * TILE_A double *.
131  * TILE_A is a pointer to the tile matrix.
132  *
133  **/
134 
135 /**
136  *
137  * @sa ddss_dscatter_tile
138  * @sa ddss_tile_size
139  *
140  **/
141 
142 void ddss_dtiled2flat_nb( int M, int N, double *A, int LDA, int MT, int NT,
143  double (*TILE_A)[NT][TILE_SIZE * TILE_SIZE] )
144 {
145 
146  // Local variables
147  int m, n;
148 
149  for ( m = 0; m < MT; m++ )
150  {
151  for ( n = 0; n < NT; n++ )
152  {
153  #pragma oss task inout(TILE_A[m][n]) \
154  label( dtiled2flat)
155  {
156  ddss_dscatter_tile( M, N,
157  &A[m * TILE_SIZE * N + n * TILE_SIZE], LDA,
158  TILE_A[m][n], m, n );
159  }
160  }
161  }
162 
163 }
164 
165 
166 /**
167  *
168  * @ingroup DDSs
169  *
170  * ddss_dsymtiled2flat:
171  * Performs the change of the data layout from tile layout to flat layout
172  * for symmetric matrices according to row-major order.
173  *
174 **/
175 
176 /**
177  *
178  * @param[in]
179  * M int.
180  * M specifies the number of rows of the flat matrix.
181  *
182  * @param[in]
183  * N int.
184  * N specifies the number of columns of the flat matrix.
185  *
186  * @param[in, out]
187  * A double *.
188  * A is a pointer to the flat matrix.
189  *
190  * @param[in]
191  * LDA int.
192  * LDA specifies the number of columns ( row-major order ) of matrix A.
193  *
194  * @param[in]
195  * MT int.
196  * MT specifies the number of rows of the matrix TILE_A.
197  *
198  * @param[in]
199  * NT int.
200  * NT specifies the number of columns of the matrix TILE_A.
201  *
202  * @param[in]
203  * TILE_A double *.
204  * TILE_A is a pointer to the tile matrix.
205  *
206  * @param[in]
207  * UPLO enum DDSS_UPLO.
208  * UPLO specifies the form of A is stored:
209  * - Lower: Lower triangle of A is stored. The upper traingular part is
210  * not referenced.
211  * - Upper: Upper triangle of A is stored. The lower triangular part is
212  * not referenced.
213  *
214  **/
215 
216 /**
217  *
218  * @sa ddss_dscatter_tile
219  * @sa ddss_tile_size
220  *
221  **/
222 
223 void ddss_dsymtiled2flat( int M, int N, double *A, int LDA, int MT, int NT,
224  double (*TILE_A)[NT][TILE_SIZE * TILE_SIZE], enum DDSS_UPLO UPLO )
225 {
226 
227  // Local variables
228  int m, n;
229 
230  if ( UPLO == Upper )
231  {
232  for ( m = 0; m < MT; m++ )
233  {
234  for ( n = NT-1; n >= m; n-- )
235  {
236  #pragma oss task inout(TILE_A[m][n]) \
237  label( dsymmtiled2flat )
238  {
239  ddss_dscatter_tile( M, N,
240  &A[m * TILE_SIZE * N + n * TILE_SIZE], LDA,
241  TILE_A[m][n], m, n );
242  }
243  }
244  }
245  }
246  else if ( UPLO == Lower )
247  {
248  for ( m = 0; m < MT; m++ )
249  {
250  for ( n = 0; n <= m; n++ )
251  {
252  #pragma oss task inout(TILE_A[m][n]) \
253  label( dsymmtiled2flat )
254  {
255  ddss_dscatter_tile( M, N,
256  &A[m * TILE_SIZE * N + n * TILE_SIZE], LDA,
257  TILE_A[m][n], m, n );
258  }
259  }
260  }
261  }
262 
263  #pragma oss taskwait
264 }
265 
266 /**
267  *
268  * @ingroup DDSs
269  *
270  * ddss_dsymtiled2flat_nb:
271  * Performs the change of the data layout from tile layout to flat layout
272  * for symmetric matrices according to row-major order in a non-blocking
273  * execution mode.
274  *
275 **/
276 
277 /**
278  *
279  * @param[in]
280  * M int.
281  * M specifies the number of rows of the flat matrix.
282  *
283  * @param[in]
284  * N int.
285  * N specifies the number of columns of the flat matrix.
286  *
287  * @param[in, out]
288  * A double *.
289  * A is a pointer to the flat matrix.
290  *
291  * @param[in]
292  * LDA int.
293  * LDA specifies the number of columns ( row-major order ) of matrix A.
294  *
295  * @param[in]
296  * MT int.
297  * MT specifies the number of rows of the matrix TILE_A.
298  *
299  * @param[in]
300  * NT int.
301  * NT specifies the number of columns of the matrix TILE_A.
302  *
303  * @param[in]
304  * TILE_A double *.
305  * TILE_A is a pointer to the tile matrix.
306  *
307  * @param[in]
308  * UPLO enum DDSS_UPLO.
309  * UPLO specifies the form of A is stored:
310  * - Lower: Lower triangle of A is stored. The upper traingular part is
311  * not referenced.
312  * - Upper: Upper triangle of A is stored. The lower triangular part is
313  * not referenced.
314  *
315  **/
316 
317 /**
318  *
319  * @sa ddss_dscatter_tile
320  * @sa ddss_tile_size
321  *
322  **/
323 
324 void ddss_dsymtiled2flat_nb( int M, int N, double *A, int LDA, int MT, int NT,
325  double (*TILE_A)[NT][TILE_SIZE * TILE_SIZE], enum DDSS_UPLO UPLO )
326 {
327 
328  // Local variables
329  int m, n;
330 
331  if ( UPLO == Upper )
332  {
333  for ( m = 0; m < MT; m++ )
334  {
335  for ( n = NT-1; n >= m; n-- )
336  {
337  #pragma oss task inout(TILE_A[m][n]) \
338  label( dsymmtiled2flat_nb )
339  {
340  ddss_dscatter_tile( M, N,
341  &A[m * TILE_SIZE * N + n * TILE_SIZE], LDA,
342  TILE_A[m][n], m, n );
343  }
344  }
345  }
346  }
347  else if ( UPLO == Lower )
348  {
349  for ( m = 0; m < MT; m++ )
350  {
351  for ( n = 0; n <= m; n++ )
352  {
353  #pragma oss task inout(TILE_A[m][n]) \
354  label( dsymmtiled2flat_nb )
355  {
356  ddss_dscatter_tile( M, N,
357  &A[m * TILE_SIZE * N + n * TILE_SIZE], LDA,
358  TILE_A[m][n], m, n );
359  }
360  }
361  }
362  }
363 
364 }
365 
366 /**
367  *
368  * @ingroup DDSs
369  *
370  * ddss_dscatter_tile:
371  * Performs the copy of a tile from the tile matrix TILE_A to the flat matrix A
372  * for the MT, NT tile.
373  *
374 **/
375 
376 /**
377  *
378  * @param[in]
379  * M int.
380  * M specifies the number of rows of the flat matrix.
381  *
382  * @param[in]
383  * N int.
384  * N specifies the number of columns of the flat matrix.
385  *
386  * @param[in, out]
387  * A double *.
388  * A is a pointer to the flat matrix.
389  *
390  * @param[in]
391  * LDA int.
392  * LDA specifies the number of columns ( row-major order ) of matrix A.
393  *
394  * @param[in]
395  * TILE_A double *.
396  * TILE_A is a pointer to the tile matrix.
397  *
398  * @param[in]
399  * MID int.
400  * MID specifies the row id of the tile.
401  *
402  * @param[in]
403  * NID int.
404  * NID specifies the column id of the tile.
405  **/
406 
407 /**
408  *
409  * @sa ddss_tile_size
410  * @sa ddss_dtiled2flat
411  *
412  **/
413 
414 void ddss_dscatter_tile( int M, int N, double *A, int LDA,
415  double *TILE_A, int MID, int NID )
416 {
417 
418  //Local variables
419  int i, j;
420  int tile_size_m, tile_size_n;
421 
422  tile_size_m = ddss_tile_size( M, MID );
423  tile_size_n = ddss_tile_size( N, NID );
424 
425  for ( i = 0; i < tile_size_m; i++ )
426  {
427  for ( j = 0; j < tile_size_n; j++ )
428  {
429  A[i * LDA + j] = TILE_A[i * tile_size_n + j];
430  }
431  }
432 
433 }
void ddss_dsymtiled2flat(int M, int N, double *A, int LDA, int MT, int NT, double(*TILE_A)[NT][TILE_SIZE *TILE_SIZE], enum DDSS_UPLO UPLO)
void ddss_dscatter_tile(int M, int N, double *A, int LDA, double *TILE_A, int MID, int NID)
void ddss_dtiled2flat_nb(int M, int N, double *A, int LDA, int MT, int NT, double(*TILE_A)[NT][TILE_SIZE *TILE_SIZE])
void ddss_dsymtiled2flat_nb(int M, int N, double *A, int LDA, int MT, int NT, double(*TILE_A)[NT][TILE_SIZE *TILE_SIZE], enum DDSS_UPLO UPLO)
void ddss_dtiled2flat(int M, int N, double *A, int LDA, int MT, int NT, double(*TILE_A)[NT][TILE_SIZE *TILE_SIZE])
int ddss_tile_size(int M, int MT)
Definition: ddss_tile.c:52