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