libflame  revision_anchor
FLA_macro_defs.h
Go to the documentation of this file.
1 /*
2 
3  Copyright (C) 2014, The University of Texas at Austin
4 
5  This file is part of libflame and is available under the 3-Clause
6  BSD license, which can be found in the LICENSE file at the top-level
7  directory, or at http://opensource.org/licenses/BSD-3-Clause
8 
9 */
10 
11 
12 
13 // --- Miscellaneous macro definitions -----------------------------------------
14 
15 #undef NULL
16 #define NULL 0
17 
18 #ifdef FLA_ENABLE_WINDOWS_BUILD
19  #define restrict __restrict
20 #endif
21 
22 
23 // --- Type-related macro definitions ------------------------------------------
24 
25 // FLA_Bool
26 #undef TRUE
27 #undef FALSE
28 #define TRUE 1
29 #define FALSE 0
30 
31 // FLA_Error (non-specific)
32 #define FLA_SUCCESS (-1)
33 #define FLA_FAILURE (-2)
34 
35 // FLA_Quadrant
36 #define FLA_TL 11
37 #define FLA_TR 12
38 #define FLA_BL 21
39 #define FLA_BR 22
40 
41 // FLA_Datatype
42 #define FLA_FLOAT 100
43 #define FLA_DOUBLE 101
44 #define FLA_COMPLEX 102
45 #define FLA_DOUBLE_COMPLEX 103
46 #define FLA_INT 104
47 #define FLA_CONSTANT 105
48 
49 // FLA_Elemtype
50 #define FLA_MATRIX 150
51 #define FLA_SCALAR 151
52 
53 // FLA_Side
54 #define FLA_TOP 200
55 #define FLA_BOTTOM 201
56 #define FLA_LEFT 210
57 #define FLA_RIGHT 211
58 #define FLA_SIDE_MASK 0x1
59 
60 // FLA_Uplo
61 #define FLA_LOWER_TRIANGULAR 300
62 #define FLA_UPPER_TRIANGULAR 301
63 #define FLA_ZERO_MATRIX 310
64 #define FLA_FULL_MATRIX 311
65 #define FLA_UPLO_MASK 0x1
66 
67 // FLA_Trans
68 #define FLA_NO_TRANSPOSE 400
69 #define FLA_TRANSPOSE 401
70 #define FLA_CONJ_TRANSPOSE 402
71 #define FLA_CONJ_NO_TRANSPOSE 403
72 #define FLA_TRANS_MASK 0x3
73 
74 // FLA_Conj
75 #define FLA_NO_CONJUGATE 450
76 #define FLA_CONJUGATE 451
77 
78 // FLA_Diag
79 #define FLA_UNIT_DIAG 500
80 #define FLA_NONUNIT_DIAG 501
81 #define FLA_ZERO_DIAG 502
82 #define FLA_DIAG_MASK 0x3
83 
84 // FLA_Dimension
85 #define FLA_DIMENSION_M 600
86 #define FLA_DIMENSION_K 601
87 #define FLA_DIMENSION_N 602
88 #define FLA_DIMENSION_MIN 603
89 
90 // FLA_Dimension_index
91 #define FLA_DIM_M_INDEX 0
92 #define FLA_DIM_K_INDEX 1
93 #define FLA_DIM_N_INDEX 2
94 #define FLA_DIM_MIN_INDEX 3
95 #define FLA_DIM_INDEX_MASK 0x3
96 
97 // FLA_Pivot_type
98 #define FLA_NATIVE_PIVOTS 700
99 #define FLA_LAPACK_PIVOTS 701
100 
101 // FLA_Direct
102 #define FLA_FORWARD 800
103 #define FLA_BACKWARD 801
104 
105 // FLA_Store
106 #define FLA_COLUMNWISE 900
107 #define FLA_ROWWISE 901
108 
109 // FLA_Matrix_type
110 #define FLA_FLAT 1000
111 #define FLA_HIER 1001
112 
113 // FLA_Precision
114 #define FLA_SINGLE_PRECISION 1100
115 #define FLA_DOUBLE_PRECISION 1101
116 
117 // FLA_Domain
118 #define FLA_REAL_DOMAIN 1200
119 #define FLA_COMPLEX_DOMAIN 1201
120 
121 // FLA_Inv
122 #define FLA_NO_INVERSE 1300
123 #define FLA_INVERSE 1301
124 
125 // FLA_Evd_type
126 #define FLA_EVD_WITHOUT_VECTORS 1400
127 #define FLA_EVD_WITH_VECTORS 1401
128 #define FLA_EVD_OF_TRIDIAG_WITH_VECTORS 1402
129 
130 // FLA_Svd_type
131 #define FLA_SVD_VECTORS_ALL 1500
132 #define FLA_SVD_VECTORS_MIN_COPY 1501
133 #define FLA_SVD_VECTORS_MIN_OVERWRITE 1502
134 #define FLA_SVD_VECTORS_NONE 1503
135 
136 // FLA_Machval
137 #define FLA_MACH_START 1600
138 #define FLA_MACH_EPS 1600
139 #define FLA_MACH_SFMIN 1601
140 #define FLA_MACH_BASE 1602
141 #define FLA_MACH_PREC 1603
142 #define FLA_MACH_NDIGMANT 1604
143 #define FLA_MACH_RND 1605
144 #define FLA_MACH_EMIN 1606
145 #define FLA_MACH_RMIN 1607
146 #define FLA_MACH_EMAX 1608
147 #define FLA_MACH_RMAX 1609
148 #define FLA_MACH_EPS2 1610
149 #define FLA_MACH_N_VALS 11
150 
151 // FLA_Diag_off
152 #define FLA_SUPER_DIAGONAL ( 1)
153 #define FLA_MAIN_DIAGONAL 0
154 #define FLA_SUB_DIAGONAL (-1)
155 
156 // FLAME threading model
157 #define FLA_OPENMP 1
158 #define FLA_PTHREADS 2
159 
160 // FLAME vector intrinsics types
161 #define FLA_NO_INTRINSICS 0
162 #define FLA_SSE_INTRINSICS 3
163 
164 // FLAME internal error checking level
165 #define FLA_FULL_ERROR_CHECKING 2
166 #define FLA_MIN_ERROR_CHECKING 1
167 #define FLA_NO_ERROR_CHECKING 0
168 
169 // FLA_Datatype_index
170 #define FLA_S_INDEX 0
171 #define FLA_D_INDEX 1
172 #define FLA_C_INDEX 2
173 #define FLA_Z_INDEX 3
174 #define FLA_DTYPE_INDEX_MASK 0x3
175 
176 // Default blocksize if none are available.
177 #ifndef FLA_DEFAULT_M_BLOCKSIZE
178  #define FLA_DEFAULT_M_BLOCKSIZE 128
179 #endif
180 #ifndef FLA_DEFAULT_K_BLOCKSIZE
181  #define FLA_DEFAULT_K_BLOCKSIZE 128
182 #endif
183 #ifndef FLA_DEFAULT_N_BLOCKSIZE
184  #define FLA_DEFAULT_N_BLOCKSIZE 128
185 #endif
186 
187 // QR and LQ factorizations typically has an inner blocksize that corresponds
188 // to the length of the S (or T) block Householder matrix. For consistency, we
189 // define the ratio of the inner blocksize to the outer blocksize here, as it
190 // is used in several places. Note that other operations have analagous inner
191 // blocksizes, which we also define in terms of the outer storage blocksize,
192 // or in some cases such as Hessenberg, tridiagonal, and bidiagonal reductions,
193 // in terms of the system-wide default blocksize.
194 #define FLA_QR_INNER_TO_OUTER_B_RATIO (0.25)
195 #define FLA_LQ_INNER_TO_OUTER_B_RATIO (0.25)
196 #define FLA_LU_INNER_TO_OUTER_B_RATIO (0.25)
197 #define FLA_UDDATE_INNER_TO_OUTER_B_RATIO (0.25)
198 #define FLA_HESS_INNER_TO_OUTER_B_RATIO (0.25)
199 #define FLA_TRIDIAG_INNER_TO_OUTER_B_RATIO (0.25)
200 #define FLA_BIDIAG_INNER_TO_OUTER_B_RATIO (0.25)
201 #define FLA_CAQR_INNER_TO_OUTER_B_RATIO (0.25)
202 
203 
204 
205 // --- Error-related macro definitions -----------------------------------------
206 
207 // Useful when determining the relative index base of the error codes.
208 #define FLA_ERROR_CODE_MIN (-10)
209 
210 // FLA_Error values.
211 #define FLA_INVALID_SIDE (-10)
212 #define FLA_INVALID_UPLO (-11)
213 #define FLA_INVALID_TRANS (-12)
214 #define FLA_INVALID_TRANS_GIVEN_DATATYPE (-13)
215 #define FLA_INVALID_CONJ (-14)
216 #define FLA_INVALID_DIRECT (-15)
217 #define FLA_INVALID_STOREV (-16)
218 #define FLA_INVALID_DATATYPE (-17)
219 #define FLA_INVALID_INTEGER_DATATYPE (-18)
220 #define FLA_INVALID_REAL_DATATYPE (-19)
221 #define FLA_INVALID_COMPLEX_DATATYPE (-20)
222 #define FLA_OBJECT_NOT_INTEGER (-21)
223 #define FLA_OBJECT_NOT_REAL (-22)
224 #define FLA_OBJECT_NOT_COMPLEX (-23)
225 #define FLA_OBJECT_NOT_SQUARE (-24)
226 #define FLA_OBJECT_NOT_SCALAR (-25)
227 #define FLA_OBJECT_NOT_VECTOR (-26)
228 #define FLA_INCONSISTENT_DATATYPES (-27)
229 #define FLA_NONCONFORMAL_DIMENSIONS (-28)
230 #define FLA_UNEQUAL_VECTOR_DIMS (-29)
231 #define FLA_INVALID_HESSENBERG_INDICES (-30)
232 #define FLA_NULL_POINTER (-32)
233 #define FLA_SPECIFIED_OBJ_DIM_MISMATCH (-33)
234 #define FLA_INVALID_PIVOT_TYPE (-35)
235 #define FLA_MALLOC_RETURNED_NULL_POINTER (-37)
236 #define FLA_OBJECT_BASE_BUFFER_MISMATCH (-38)
237 #define FLA_OBJECTS_NOT_VERTICALLY_ADJ (-39)
238 #define FLA_OBJECTS_NOT_HORIZONTALLY_ADJ (-40)
239 #define FLA_ADJACENT_OBJECT_DIM_MISMATCH (-41)
240 #define FLA_OBJECTS_NOT_VERTICALLY_ALIGNED (-42)
241 #define FLA_OBJECTS_NOT_HORIZONTALLY_ALIGNED (-43)
242 #define FLA_INVALID_FLOATING_DATATYPE (-44)
243 #define FLA_OBJECT_NOT_FLOATING_POINT (-45)
244 #define FLA_INVALID_BLOCKSIZE_VALUE (-46)
245 #define FLA_OPEN_RETURNED_ERROR (-47)
246 #define FLA_LSEEK_RETURNED_ERROR (-48)
247 #define FLA_CLOSE_RETURNED_ERROR (-49)
248 #define FLA_UNLINK_RETURNED_ERROR (-50)
249 #define FLA_READ_RETURNED_ERROR (-51)
250 #define FLA_WRITE_RETURNED_ERROR (-52)
251 #define FLA_INVALID_QUADRANT (-53)
252 #define FLA_NOT_YET_IMPLEMENTED (-54)
253 #define FLA_EXPECTED_NONNEGATIVE_VALUE (-55)
254 #define FLA_SUPERMATRIX_NOT_ENABLED (-56)
255 #define FLA_UNDEFINED_ERROR_CODE (-57)
256 #define FLA_INVALID_DIAG (-58)
257 #define FLA_INCONSISTENT_OBJECT_PRECISION (-59)
258 #define FLA_INVALID_BLOCKSIZE_OBJ (-60)
259 #define FLA_VECTOR_DIM_BELOW_MIN (-61)
260 #define FLA_PTHREAD_CREATE_RETURNED_ERROR (-63)
261 #define FLA_PTHREAD_JOIN_RETURNED_ERROR (-64)
262 #define FLA_INVALID_ISGN_VALUE (-65)
263 #define FLA_CHOL_FAILED_MATRIX_NOT_SPD (-67)
264 #define FLA_INVALID_ELEMTYPE (-68)
265 #define FLA_POSIX_MEMALIGN_FAILED (-69)
266 #define FLA_INVALID_SUBMATRIX_DIMS (-70)
267 #define FLA_INVALID_SUBMATRIX_OFFSET (-71)
268 #define FLA_OBJECT_NOT_SCALAR_ELEMTYPE (-72)
269 #define FLA_OBJECT_NOT_MATRIX_ELEMTYPE (-73)
270 #define FLA_ENCOUNTERED_NON_POSITIVE_NTHREADS (-74)
271 #define FLA_INVALID_CONJ_GIVEN_DATATYPE (-75)
272 #define FLA_INVALID_COMPLEX_TRANS (-76)
273 #define FLA_INVALID_REAL_TRANS (-77)
274 #define FLA_INVALID_BLAS_TRANS (-78)
275 #define FLA_INVALID_NONCONSTANT_DATATYPE (-79)
276 #define FLA_OBJECT_NOT_NONCONSTANT (-80)
277 #define FLA_OBJECT_DATATYPES_NOT_EQUAL (-82)
278 #define FLA_DIVIDE_BY_ZERO (-83)
279 #define FLA_OBJECT_ELEMTYPES_NOT_EQUAL (-84)
280 #define FLA_INVALID_PIVOT_INDEX_RANGE (-85)
281 #define FLA_HOUSEH_PANEL_MATRIX_TOO_SMALL (-86)
282 #define FLA_INVALID_OBJECT_LENGTH (-87)
283 #define FLA_INVALID_OBJECT_WIDTH (-88)
284 #define FLA_INVALID_ERROR_CHECKING_LEVEL (-89)
285 #define FLA_ATTEMPTED_OVER_REPART_2X2 (-90)
286 #define FLA_ATTEMPTED_OVER_REPART_2X1 (-91)
287 #define FLA_ATTEMPTED_OVER_REPART_1X2 (-92)
288 #define FLA_EXTERNAL_LAPACK_NOT_IMPLEMENTED (-93)
289 #define FLA_INVALID_ROW_STRIDE (-94)
290 #define FLA_INVALID_COL_STRIDE (-95)
291 #define FLA_INVALID_STRIDE_COMBINATION (-96)
292 #define FLA_INVALID_VECTOR_DIM (-97)
293 #define FLA_EXPECTED_ROW_VECTOR (-98)
294 #define FLA_EXPECTED_COL_VECTOR (-99)
295 #define FLA_INVALID_INVERSE (-100)
296 #define FLA_MALLOC_GPU_RETURNED_NULL_POINTER (-101)
297 #define FLA_INVALID_EVD_TYPE (-102)
298 #define FLA_INVALID_SVD_TYPE (-103)
299 #define FLA_INVALID_MACHVAL (-104)
300 #define FLA_INVALID_DIAG_OFFSET (-105)
301 #define FLA_EXPECTED_COL_STORAGE (-106)
302 #define FLA_EXPECTED_ROW_STORAGE (-107)
303 #define FLA_LAPAC2FLAME_INVALID_RETURN (-108)
304 #define FLA_INVALID_SVD_TYPE_COMBINATION (-109)
305 #define FLA_INVALID_SVD_TYPE_AND_TRANS_COMBINATION (-110)
306 #define FLA_OBJECT_NOT_COMPARABLE (-111)
307 
308 // Necessary when computing whether an error code is defined.
309 #define FLA_ERROR_CODE_MAX (-111)
310 
311 // Internal string matrix limits.
312 #define FLA_MAX_NUM_ERROR_MSGS 150
313 #define FLA_MAX_ERROR_MSG_LENGTH 200
314 
315 // Error code translation and output macro definition.
316 #define FLA_Check_error_code( code ) \
317  FLA_Check_error_code_helper( code, __FILE__, __LINE__ )
318 
319 
320 
321 // --- Common functions implemented as macros ----------------------------------
322 
323 #undef min
324 #define min( x, y ) ( (x) < (y) ? (x) : (y) )
325 
326 #undef max
327 #define max( x, y ) ( (x) > (y) ? (x) : (y) )
328 
329 #undef signof
330 #define signof( a, b ) ( (b) >= 0 ? (a) : -(a) )
331 
332 #undef exchange
333 #define exchange( a, b, temp ) { temp = a; a = b; b = temp; }
334 
335 // --- Other macro definitions -------------------------------------------------
336 
337 #define FLA_NEGATE( a ) \
338  ( a.base == FLA_ONE.base ? FLA_MINUS_ONE : FLA_ONE )
339 
340