LASs - Linear Algebra Routines on OmpSs  1.0.0
LASs
ddss_flat2tiled.c
Go to the documentation of this file.
1 #include "../include/lass.h"
2 
3 /**
4  *
5  * @file ddss_flat2tiled.c
6  *
7  * @brief LASs-DDSs ddss_flat2tiled 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-11
14  * @reviewer
15  * @modified
16  *
17  **/
18 
19 /**
20  *
21  * @ingroup DDSs
22  *
23  * ddss_dflat2tiled:
24  * Performs the change of the data layout from flat layout to tiled 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]
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, out]
56  * TILE_A double *.
57  * TILE_A is a pointer to the tile matrix.
58  *
59  **/
60 
61 /**
62  *
63  * @sa ddss_dgather_tile
64  * @sa ddss_tile_size
65  *
66  **/
67 
68 void ddss_dflat2tiled( 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( dflat2tiled )
81  {
82  ddss_dgather_tile( M, N, &A[m * TILE_SIZE * N + n * TILE_SIZE],
83  LDA, TILE_A[m][n], m, n );
84  }
85  }
86  }
87 
88 }
89 
90 /**
91  *
92  * @ingroup DDSs
93  *
94  * ddss_dsymflat2tiled:
95  * Performs the change of the data layout from flat layout to tiled layout
96  * for symmetric matrices according to row-major order.
97  *
98 **/
99 
100 /**
101  *
102  * @param[in]
103  * M int.
104  * M specifies the number of rows of the flat matrix.
105  *
106  * @param[in]
107  * N int.
108  * N specifies the number of columns of the flat matrix.
109  *
110  * @param[in]
111  * A double *.
112  * A is a pointer to the flat matrix.
113  *
114  * @param[in]
115  * LDA int.
116  * LDA specifies the number of columns ( row-major order ) of matrix A.
117  *
118  * @param[in]
119  * MT int.
120  * MT specifies the number of rows of the matrix TILE_A.
121  *
122  * @param[in]
123  * NT int.
124  * NT specifies the number of columns of the matrix TILE_A.
125  *
126  * @param[in, out]
127  * TILE_A double *.
128  * TILE_A is a pointer to the tile matrix.
129  *
130  * @param[in]
131  * UPLO enum DDSS_UPLO.
132  * UPLO specifies the form of A is stored:
133  * - Lower: Lower triangle of A is stored. The upper traingular part is
134  * not referenced.
135  * - Upper: Upper triangle of A is stored. The lower triangular part is
136  * not referenced.
137 
138  **/
139 
140 /**
141  *
142  * @sa ddss_dgather_tile
143  * @sa ddss_tile_size
144  *
145  **/
146 
147 void ddss_dsymflat2tiled( int M, int N, double *A, int LDA, int MT, int NT,
148  double (*TILE_A)[NT][TILE_SIZE * TILE_SIZE], enum DDSS_UPLO UPLO )
149 {
150 
151  // Local variables
152  int m, n;
153 
154  if ( UPLO == Upper )
155  {
156  for ( m = 0; m < MT; m++ )
157  {
158  for ( n = NT-1; n >= m; n-- )
159  {
160  #pragma oss task inout(TILE_A[m][n]) \
161  label( dsymmflat2tiled )
162  {
163  ddss_dgather_tile( M, N,
164  &A[m * TILE_SIZE * N + n * TILE_SIZE],
165  LDA, TILE_A[m][n], m, n );
166  }
167  }
168  }
169  }
170  else if ( UPLO == Lower )
171  {
172  for ( m = 0; m < MT; m++ )
173  {
174  for ( n = 0; n <= m; n++ )
175  {
176  #pragma oss task inout(TILE_A[m][n]) \
177  label( dsymmflat2tiled )
178  {
179  ddss_dgather_tile( M, N,
180  &A[m * TILE_SIZE * N + n * TILE_SIZE],
181  LDA, TILE_A[m][n], m, n );
182  }
183  }
184  }
185  }
186 
187 }
188 
189 
190 /**
191  *
192  * @ingroup DDSs
193  *
194  * ddss_dgather_tile:
195  * Performs the copy of a tile from the flat matrix A to the tile matrix TILE_A
196  * for the MT, NT tile.
197  *
198 **/
199 
200 /**
201  *
202  * @param[in]
203  * M int.
204  * M specifies the number of rows of the flat matrix.
205  *
206  * @param[in]
207  * N int.
208  * N specifies the number of columns of the flat matrix.
209  *
210  * @param[in]
211  * A double *.
212  * A is a pointer to the flat matrix.
213  *
214  * @param[in]
215  * LDA int.
216  * LDA specifies the number of columns ( row-major order ) of matrix A.
217  *
218  * @param[in, out]
219  * TILE_A double *.
220  * TILE_A is a pointer to the tile matrix.
221  *
222  * @param[in]
223  * MID int.
224  * MID specifies the row id of the tile.
225  *
226  * @param[in]
227  * NID int.
228  * NID specifies the column id of the tile.
229  **/
230 
231 /**
232  *
233  * @sa ddss_tile_size
234  * @sa ddss_dflat2tiled
235  *
236  **/
237 
238 void ddss_dgather_tile( int M, int N, double *A, int LDA,
239  double *TILE_A, int MID, int NID )
240 {
241 
242  //Local variables
243  int i, j;
244  int tile_size_m, tile_size_n;
245 
246  tile_size_m = ddss_tile_size( M, MID );
247  tile_size_n = ddss_tile_size( N, NID );
248 
249  for ( i = 0; i < tile_size_m; i++ )
250  {
251  for ( j = 0; j < tile_size_n; j++ )
252  {
253  TILE_A[i * tile_size_n + j] = A[i * LDA + j];
254  }
255  }
256 
257 }
void ddss_dgather_tile(int M, int N, double *A, int LDA, double *TILE_A, int MID, int NID)
void ddss_dflat2tiled(int M, int N, double *A, int LDA, int MT, int NT, double(*TILE_A)[NT][TILE_SIZE *TILE_SIZE])
void ddss_dsymflat2tiled(int M, int N, double *A, int LDA, int MT, int NT, double(*TILE_A)[NT][TILE_SIZE *TILE_SIZE], enum DDSS_UPLO UPLO)
int ddss_tile_size(int M, int MT)
Definition: ddss_tile.c:52