libflame
12600
|
00001 /* 00002 libflame 00003 An object-based infrastructure for developing high-performance 00004 dense linear algebra libraries. 00005 00006 Copyright (C) 2011, The University of Texas 00007 00008 libflame is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU Lesser General Public License as 00010 published by the Free Software Foundation; either version 2.1 of 00011 the License, or (at your option) any later version. 00012 00013 libflame is distributed in the hope that it will be useful, but 00014 WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Lesser General Public License for more details. 00017 00018 You should have received a copy of the GNU Lesser General Public 00019 License along with libflame; if you did not receive a copy, see 00020 http://www.gnu.org/licenses/. 00021 00022 For more information, please contact us at flame@cs.utexas.edu or 00023 send mail to: 00024 00025 Field G. Van Zee and/or 00026 Robert A. van de Geijn 00027 The University of Texas at Austin 00028 Department of Computer Sciences 00029 1 University Station C0500 00030 Austin TX 78712 00031 */ 00032 00033 00034 00035 // --- Miscellaneous macro definitions ----------------------------------------- 00036 00037 #undef NULL 00038 #define NULL 0 00039 00040 #ifdef FLA_ENABLE_WINDOWS_BUILD 00041 #define restrict __restrict 00042 #endif 00043 00044 00045 // --- Type-related macro definitions ------------------------------------------ 00046 00047 // FLA_Bool 00048 #undef TRUE 00049 #undef FALSE 00050 #define TRUE 1 00051 #define FALSE 0 00052 00053 // FLA_Error (non-specific) 00054 #define FLA_SUCCESS (-1) 00055 #define FLA_FAILURE (-2) 00056 00057 // FLA_Quadrant 00058 #define FLA_TL 11 00059 #define FLA_TR 12 00060 #define FLA_BL 21 00061 #define FLA_BR 22 00062 00063 // FLA_Datatype 00064 #define FLA_FLOAT 100 00065 #define FLA_DOUBLE 101 00066 #define FLA_COMPLEX 102 00067 #define FLA_DOUBLE_COMPLEX 103 00068 #define FLA_INT 104 00069 #define FLA_CONSTANT 105 00070 00071 // FLA_Elemtype 00072 #define FLA_MATRIX 150 00073 #define FLA_SCALAR 151 00074 00075 // FLA_Side 00076 #define FLA_TOP 200 00077 #define FLA_BOTTOM 201 00078 #define FLA_LEFT 210 00079 #define FLA_RIGHT 211 00080 #define FLA_SIDE_MASK 0x1 00081 00082 // FLA_Uplo 00083 #define FLA_LOWER_TRIANGULAR 300 00084 #define FLA_UPPER_TRIANGULAR 301 00085 #define FLA_ZERO_MATRIX 310 00086 #define FLA_FULL_MATRIX 311 00087 #define FLA_UPLO_MASK 0x1 00088 00089 // FLA_Trans 00090 #define FLA_NO_TRANSPOSE 400 00091 #define FLA_TRANSPOSE 401 00092 #define FLA_CONJ_TRANSPOSE 402 00093 #define FLA_CONJ_NO_TRANSPOSE 403 00094 #define FLA_TRANS_MASK 0x3 00095 00096 // FLA_Conj 00097 #define FLA_NO_CONJUGATE 450 00098 #define FLA_CONJUGATE 451 00099 00100 // FLA_Diag 00101 #define FLA_UNIT_DIAG 500 00102 #define FLA_NONUNIT_DIAG 501 00103 #define FLA_ZERO_DIAG 502 00104 #define FLA_DIAG_MASK 0x3 00105 00106 // FLA_Dimension 00107 #define FLA_DIMENSION_M 600 00108 #define FLA_DIMENSION_K 601 00109 #define FLA_DIMENSION_N 602 00110 #define FLA_DIMENSION_MIN 603 00111 00112 // FLA_Dimension_index 00113 #define FLA_DIM_M_INDEX 0 00114 #define FLA_DIM_K_INDEX 1 00115 #define FLA_DIM_N_INDEX 2 00116 #define FLA_DIM_MIN_INDEX 3 00117 #define FLA_DIM_INDEX_MASK 0x3 00118 00119 // FLA_Pivot_type 00120 #define FLA_NATIVE_PIVOTS 700 00121 #define FLA_LAPACK_PIVOTS 701 00122 00123 // FLA_Direct 00124 #define FLA_FORWARD 800 00125 #define FLA_BACKWARD 801 00126 00127 // FLA_Store 00128 #define FLA_COLUMNWISE 900 00129 #define FLA_ROWWISE 901 00130 00131 // FLA_Matrix_type 00132 #define FLA_FLAT 1000 00133 #define FLA_HIER 1001 00134 00135 // FLA_Precision 00136 #define FLA_SINGLE_PRECISION 1100 00137 #define FLA_DOUBLE_PRECISION 1101 00138 00139 // FLA_Domain 00140 #define FLA_REAL_DOMAIN 1200 00141 #define FLA_COMPLEX_DOMAIN 1201 00142 00143 // FLA_Inv 00144 #define FLA_NO_INVERSE 1300 00145 #define FLA_INVERSE 1301 00146 00147 // FLA_Evd_type 00148 #define FLA_EVD_WITHOUT_VECTORS 1400 00149 #define FLA_EVD_WITH_VECTORS 1401 00150 #define FLA_EVD_OF_TRIDIAG_WITH_VECTORS 1402 00151 00152 // FLA_Svd_type 00153 #define FLA_SVD_VECTORS_ALL 1500 00154 #define FLA_SVD_VECTORS_MIN_COPY 1501 00155 #define FLA_SVD_VECTORS_MIN_OVERWRITE 1502 00156 #define FLA_SVD_VECTORS_NONE 1503 00157 00158 // FLA_Machval 00159 #define FLA_MACH_START 1600 00160 #define FLA_MACH_EPS 1600 00161 #define FLA_MACH_SFMIN 1601 00162 #define FLA_MACH_BASE 1602 00163 #define FLA_MACH_PREC 1603 00164 #define FLA_MACH_NDIGMANT 1604 00165 #define FLA_MACH_RND 1605 00166 #define FLA_MACH_EMIN 1606 00167 #define FLA_MACH_RMIN 1607 00168 #define FLA_MACH_EMAX 1608 00169 #define FLA_MACH_RMAX 1609 00170 #define FLA_MACH_EPS2 1610 00171 #define FLA_MACH_N_VALS 11 00172 00173 // FLA_Diag_off 00174 #define FLA_SUPER_DIAGONAL ( 1) 00175 #define FLA_MAIN_DIAGONAL 0 00176 #define FLA_SUB_DIAGONAL (-1) 00177 00178 // FLAME threading model 00179 #define FLA_OPENMP 1 00180 #define FLA_PTHREADS 2 00181 00182 // FLAME vector intrinsics types 00183 #define FLA_NO_INTRINSICS 0 00184 #define FLA_SSE_INTRINSICS 3 00185 00186 // FLAME internal error checking level 00187 #define FLA_FULL_ERROR_CHECKING 2 00188 #define FLA_MIN_ERROR_CHECKING 1 00189 #define FLA_NO_ERROR_CHECKING 0 00190 00191 // FLA_Datatype_index 00192 #define FLA_S_INDEX 0 00193 #define FLA_D_INDEX 1 00194 #define FLA_C_INDEX 2 00195 #define FLA_Z_INDEX 3 00196 #define FLA_DTYPE_INDEX_MASK 0x3 00197 00198 // Default blocksize if none are available. 00199 #ifndef FLA_DEFAULT_M_BLOCKSIZE 00200 #define FLA_DEFAULT_M_BLOCKSIZE 128 00201 #endif 00202 #ifndef FLA_DEFAULT_K_BLOCKSIZE 00203 #define FLA_DEFAULT_K_BLOCKSIZE 128 00204 #endif 00205 #ifndef FLA_DEFAULT_N_BLOCKSIZE 00206 #define FLA_DEFAULT_N_BLOCKSIZE 128 00207 #endif 00208 00209 // QR and LQ factorizations typically has an inner blocksize that corresponds 00210 // to the length of the S (or T) block Householder matrix. For consistency, we 00211 // define the ratio of the inner blocksize to the outer blocksize here, as it 00212 // is used in several places. Note that other operations have analagous inner 00213 // blocksizes, which we also define in terms of the outer storage blocksize, 00214 // or in some cases such as Hessenberg, tridiagonal, and bidiagonal reductions, 00215 // in terms of the system-wide default blocksize. 00216 #define FLA_QR_INNER_TO_OUTER_B_RATIO (0.25) 00217 #define FLA_LQ_INNER_TO_OUTER_B_RATIO (0.25) 00218 #define FLA_LU_INNER_TO_OUTER_B_RATIO (0.25) 00219 #define FLA_UDDATE_INNER_TO_OUTER_B_RATIO (0.25) 00220 #define FLA_HESS_INNER_TO_OUTER_B_RATIO (0.25) 00221 #define FLA_TRIDIAG_INNER_TO_OUTER_B_RATIO (0.25) 00222 #define FLA_BIDIAG_INNER_TO_OUTER_B_RATIO (0.25) 00223 #define FLA_CAQR_INNER_TO_OUTER_B_RATIO (0.25) 00224 00225 00226 00227 // --- Error-related macro definitions ----------------------------------------- 00228 00229 // Useful when determining the relative index base of the error codes. 00230 #define FLA_ERROR_CODE_MIN (-10) 00231 00232 // FLA_Error values. 00233 #define FLA_INVALID_SIDE (-10) 00234 #define FLA_INVALID_UPLO (-11) 00235 #define FLA_INVALID_TRANS (-12) 00236 #define FLA_INVALID_TRANS_GIVEN_DATATYPE (-13) 00237 #define FLA_INVALID_CONJ (-14) 00238 #define FLA_INVALID_DIRECT (-15) 00239 #define FLA_INVALID_STOREV (-16) 00240 #define FLA_INVALID_DATATYPE (-17) 00241 #define FLA_INVALID_INTEGER_DATATYPE (-18) 00242 #define FLA_INVALID_REAL_DATATYPE (-19) 00243 #define FLA_INVALID_COMPLEX_DATATYPE (-20) 00244 #define FLA_OBJECT_NOT_INTEGER (-21) 00245 #define FLA_OBJECT_NOT_REAL (-22) 00246 #define FLA_OBJECT_NOT_COMPLEX (-23) 00247 #define FLA_OBJECT_NOT_SQUARE (-24) 00248 #define FLA_OBJECT_NOT_SCALAR (-25) 00249 #define FLA_OBJECT_NOT_VECTOR (-26) 00250 #define FLA_INCONSISTENT_DATATYPES (-27) 00251 #define FLA_NONCONFORMAL_DIMENSIONS (-28) 00252 #define FLA_UNEQUAL_VECTOR_DIMS (-29) 00253 #define FLA_INVALID_HESSENBERG_INDICES (-30) 00254 #define FLA_NULL_POINTER (-32) 00255 #define FLA_SPECIFIED_OBJ_DIM_MISMATCH (-33) 00256 #define FLA_INVALID_PIVOT_TYPE (-35) 00257 #define FLA_MALLOC_RETURNED_NULL_POINTER (-37) 00258 #define FLA_OBJECT_BASE_BUFFER_MISMATCH (-38) 00259 #define FLA_OBJECTS_NOT_VERTICALLY_ADJ (-39) 00260 #define FLA_OBJECTS_NOT_HORIZONTALLY_ADJ (-40) 00261 #define FLA_ADJACENT_OBJECT_DIM_MISMATCH (-41) 00262 #define FLA_OBJECTS_NOT_VERTICALLY_ALIGNED (-42) 00263 #define FLA_OBJECTS_NOT_HORIZONTALLY_ALIGNED (-43) 00264 #define FLA_INVALID_FLOATING_DATATYPE (-44) 00265 #define FLA_OBJECT_NOT_FLOATING_POINT (-45) 00266 #define FLA_INVALID_BLOCKSIZE_VALUE (-46) 00267 #define FLA_OPEN_RETURNED_ERROR (-47) 00268 #define FLA_LSEEK_RETURNED_ERROR (-48) 00269 #define FLA_CLOSE_RETURNED_ERROR (-49) 00270 #define FLA_UNLINK_RETURNED_ERROR (-50) 00271 #define FLA_READ_RETURNED_ERROR (-51) 00272 #define FLA_WRITE_RETURNED_ERROR (-52) 00273 #define FLA_INVALID_QUADRANT (-53) 00274 #define FLA_NOT_YET_IMPLEMENTED (-54) 00275 #define FLA_EXPECTED_NONNEGATIVE_VALUE (-55) 00276 #define FLA_SUPERMATRIX_NOT_ENABLED (-56) 00277 #define FLA_UNDEFINED_ERROR_CODE (-57) 00278 #define FLA_INVALID_DIAG (-58) 00279 #define FLA_INCONSISTENT_OBJECT_PRECISION (-59) 00280 #define FLA_INVALID_BLOCKSIZE_OBJ (-60) 00281 #define FLA_VECTOR_DIM_BELOW_MIN (-61) 00282 #define FLA_PTHREAD_CREATE_RETURNED_ERROR (-63) 00283 #define FLA_PTHREAD_JOIN_RETURNED_ERROR (-64) 00284 #define FLA_INVALID_ISGN_VALUE (-65) 00285 #define FLA_CHOL_FAILED_MATRIX_NOT_SPD (-67) 00286 #define FLA_INVALID_ELEMTYPE (-68) 00287 #define FLA_POSIX_MEMALIGN_FAILED (-69) 00288 #define FLA_INVALID_SUBMATRIX_DIMS (-70) 00289 #define FLA_INVALID_SUBMATRIX_OFFSET (-71) 00290 #define FLA_OBJECT_NOT_SCALAR_ELEMTYPE (-72) 00291 #define FLA_OBJECT_NOT_MATRIX_ELEMTYPE (-73) 00292 #define FLA_ENCOUNTERED_NON_POSITIVE_NTHREADS (-74) 00293 #define FLA_INVALID_CONJ_GIVEN_DATATYPE (-75) 00294 #define FLA_INVALID_COMPLEX_TRANS (-76) 00295 #define FLA_INVALID_REAL_TRANS (-77) 00296 #define FLA_INVALID_BLAS_TRANS (-78) 00297 #define FLA_INVALID_NONCONSTANT_DATATYPE (-79) 00298 #define FLA_OBJECT_NOT_NONCONSTANT (-80) 00299 #define FLA_OBJECT_DATATYPES_NOT_EQUAL (-82) 00300 #define FLA_DIVIDE_BY_ZERO (-83) 00301 #define FLA_OBJECT_ELEMTYPES_NOT_EQUAL (-84) 00302 #define FLA_INVALID_PIVOT_INDEX_RANGE (-85) 00303 #define FLA_HOUSEH_PANEL_MATRIX_TOO_SMALL (-86) 00304 #define FLA_INVALID_OBJECT_LENGTH (-87) 00305 #define FLA_INVALID_OBJECT_WIDTH (-88) 00306 #define FLA_INVALID_ERROR_CHECKING_LEVEL (-89) 00307 #define FLA_ATTEMPTED_OVER_REPART_2X2 (-90) 00308 #define FLA_ATTEMPTED_OVER_REPART_2X1 (-91) 00309 #define FLA_ATTEMPTED_OVER_REPART_1X2 (-92) 00310 #define FLA_EXTERNAL_LAPACK_NOT_IMPLEMENTED (-93) 00311 #define FLA_INVALID_ROW_STRIDE (-94) 00312 #define FLA_INVALID_COL_STRIDE (-95) 00313 #define FLA_INVALID_STRIDE_COMBINATION (-96) 00314 #define FLA_INVALID_VECTOR_DIM (-97) 00315 #define FLA_EXPECTED_ROW_VECTOR (-98) 00316 #define FLA_EXPECTED_COL_VECTOR (-99) 00317 #define FLA_INVALID_INVERSE (-100) 00318 #define FLA_MALLOC_GPU_RETURNED_NULL_POINTER (-101) 00319 #define FLA_INVALID_EVD_TYPE (-102) 00320 #define FLA_INVALID_SVD_TYPE (-103) 00321 #define FLA_INVALID_MACHVAL (-104) 00322 #define FLA_INVALID_DIAG_OFFSET (-105) 00323 #define FLA_EXPECTED_COL_STORAGE (-106) 00324 #define FLA_EXPECTED_ROW_STORAGE (-107) 00325 #define FLA_LAPAC2FLAME_INVALID_RETURN (-108) 00326 #define FLA_INVALID_SVD_TYPE_COMBINATION (-109) 00327 #define FLA_INVALID_SVD_TYPE_AND_TRANS_COMBINATION (-110) 00328 #define FLA_OBJECT_NOT_COMPARABLE (-111) 00329 00330 // Necessary when computing whether an error code is defined. 00331 #define FLA_ERROR_CODE_MAX (-111) 00332 00333 // Internal string matrix limits. 00334 #define FLA_MAX_NUM_ERROR_MSGS 150 00335 #define FLA_MAX_ERROR_MSG_LENGTH 200 00336 00337 // Error code translation and output macro definition. 00338 #define FLA_Check_error_code( code ) \ 00339 FLA_Check_error_code_helper( code, __FILE__, __LINE__ ) 00340 00341 00342 00343 // --- Common functions implemented as macros ---------------------------------- 00344 00345 #undef min 00346 #define min( x, y ) ( (x) < (y) ? (x) : (y) ) 00347 00348 #undef max 00349 #define max( x, y ) ( (x) > (y) ? (x) : (y) ) 00350 00351 #undef signof 00352 #define signof( a, b ) ( (b) >= 0 ? (a) : -(a) ) 00353 00354 #undef exchange 00355 #define exchange( a, b, temp ) { temp = a; a = b; b = temp; } 00356 00357 // --- Other macro definitions ------------------------------------------------- 00358 00359 #define FLA_NEGATE( a ) \ 00360 ( a.base == FLA_ONE.base ? FLA_MINUS_ONE : FLA_ONE ) 00361 00362