1 2 3 /** @file 4 @brief 5 Macros and constants, which are type specific. 6 \n 7 Here reside declarations related to supported matrix numerical types, and other declarations 8 according to the build time options. 9 \n 10 If you wish to use this library with different matrix numerical types, you shall regenerate 11 the library source code accordingly; see the README file how to do this. 12 \n 13 Only a small part of these declarations is needed to the user (see \ref matrix_type_symbols_section). 14 \n 15 Therefore, only the declarations which are commented are actually meant to be used in functions; 16 please regard the remaining ones as internal. 17 */ 18 19 /* 20 21 Copyright (C) 2008-2020 Michele Martone 22 23 This file is part of librsb. 24 25 librsb is free software; you can redistribute it and/or modify it 26 under the terms of the GNU Lesser General Public License as published 27 by the Free Software Foundation; either version 3 of the License, or 28 (at your option) any later version. 29 30 librsb is distributed in the hope that it will be useful, but WITHOUT 31 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 32 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 33 License for more details. 34 35 You should have received a copy of the GNU Lesser General Public 36 License along with librsb; see the file COPYING. 37 If not, see <http://www.gnu.org/licenses/>. 38 39 */ 40 /* 41 The code in this file was generated automatically by an M4 script. 42 It is not meant to be used as an API (Application Programming Interface). 43 p.s.: right now, only row major matrix access is considered. 44 45 */ 46 #ifndef RSB_TYPES_H_INCLUDED 47 #define RSB_TYPES_H_INCLUDED 48 49 #ifdef __cplusplus 50 extern "C" { 51 #endif /* __cplusplus */ 52 53 54 #ifndef __cplusplus 55 /* complex.h is ISO C99 */ 56 #include <complex.h> 57 #endif /* __cplusplus */ 58 /* 59 Each one of the following symbols is assigned to a type which is supported 60 by an option set at library code generation time. 61 Other types may be enabled by regenerating the whole library code. 62 To enable types, please read the documentation. 63 */ 64 65 /* Miscellaneous version strings. 66 Adopting a naming scheme similar to that of png.h. 67 */ 68 #define RSB_LIBRSB_VER_STRING "1.2.0" /*!< \brief Library version string. */ 69 #define RSB_HEADER_VERSION_STRING "librsb version 1.2.RSB_M4_WANT_LIBRSB_VER_PATCH9 - 20201204" /*!< \brief Library header version string. */ 70 #define RSB_LIBRSB_VER_MAJOR 1 /*!< \brief Major version. */ 71 #define RSB_LIBRSB_VER_MINOR 2 /*!< \brief Minor version. */ 72 #define RSB_LIBRSB_VER_PATCH 0 /*!< \brief Patch version. */ 73 #define RSB_LIBRSB_VER 10201 /*!< \brief Version number. */ 74 #define RSB_LIBRSB_VER_DATE 20201204 /*!< \brief Version release date. */ 75 76 #define RSB_HAVE_TYPE_DOUBLE 1 /*!< \brief Type double is supported, so RSB_HAVE_TYPE_DOUBLE is defined .*/ 77 #define RSB_HAVE_TYPE_FLOAT 1 /*!< \brief Type float is supported, so RSB_HAVE_TYPE_FLOAT is defined .*/ 78 #define RSB_HAVE_TYPE_FLOAT_COMPLEX 1 /*!< \brief Type float complex is supported, so RSB_HAVE_TYPE_FLOAT_COMPLEX is defined .*/ 79 #define RSB_HAVE_TYPE_DOUBLE_COMPLEX 1 /*!< \brief Type double complex is supported, so RSB_HAVE_TYPE_DOUBLE_COMPLEX is defined .*/ 80 #define RSB_DEFAULT_TYPE double /*!< \brief The default numerical matrix type (can be used for declarations), used in the example programs. */ 81 #define RSB_DEFAULT_POSSIBLY_INTEGER_TYPE double/*!< \brief The default, integer if possible , numerical type (can be used for declarations). */ 82 #define RSB_DEFAULT_POSSIBLY_FIRST_BLAS_TYPE float /*!< \brief The default, blas if possible , numerical type (can be used for declarations). */ 83 #define RSB_DEFAULT_TYPE_STRING "double" /*!< \brief A string specifying the name of the default type. */ 84 #define RSB_DEFAULT_POSSIBLY_INTEGER_TYPE_STRING "double" /*!< \brief A string specifying the name of the default possibly integer type.*/ 85 #define RSB_DEFAULT_SYMMETRY RSB_SYMMETRY_U /*!< \brief The default symmetry flag. */ 86 #define RSB_DEFAULT_TRANSPOSITION RSB_TRANSPOSITION_N /*!< \brief The default transposition flag (no transposition). */ 87 #define RSB_ROWS_TRANSPOSITIONS_ARRAY {RSB_TRANSPOSITION_N, RSB_TRANSPOSITION_T, RSB_TRANSPOSITION_C, RSB_INVALID_TRANS } /*!< \brief An array with transposition constants. */ 88 89 /*! This preprocessor index can be used to address the double-related arrays. */ 90 #define RSB_TYPE_INDEX_DOUBLE 0 91 /*! This preprocessor index can be used to address the float-related arrays. */ 92 #define RSB_TYPE_INDEX_FLOAT 1 93 /*! This preprocessor index can be used to address the float complex-related arrays. */ 94 #define RSB_TYPE_INDEX_FLOAT_COMPLEX 2 95 /*! This preprocessor index can be used to address the double complex-related arrays. */ 96 #define RSB_TYPE_INDEX_DOUBLE_COMPLEX 3 97 98 /* @cond INNERDOC */ 99 /* 100 Each one of the following symbols is assigned to an operation which is supported 101 by an option set at library code generation time. 102 \n 103 Other operations may be enabled by regenerating the whole library code. 104 To enable operations, please read the documentation. 105 */ 106 #define RSB_HAVE_OPTYPE_SPMV_UAUA 1 107 #define RSB_HAVE_OPTYPE_SPMV_UAUZ 1 108 #define RSB_HAVE_OPTYPE_SPMV_UXUA 1 109 #define RSB_HAVE_OPTYPE_SPMV_UNUA 1 110 #define RSB_HAVE_OPTYPE_SPMV_SASA 1 111 #define RSB_HAVE_OPTYPE_SPSV_UXUA 1 112 #define RSB_HAVE_OPTYPE_SPMV_SXSA 1 113 #define RSB_HAVE_OPTYPE_SPSV_SXSX 1 114 #define RSB_HAVE_OPTYPE_INFTY_NORM 1 115 #define RSB_HAVE_OPTYPE_ROWSSUMS 1 116 #define RSB_HAVE_OPTYPE_SCALE 1 117 118 /*! 119 * These preprocessor indices can be used to address various mop-related arrays. 120 */ 121 #define RSB_OPTYPE_INDEX_SPMV_UAUA 0 122 #define RSB_OPTYPE_INDEX_SPMV_UAUZ 1 123 #define RSB_OPTYPE_INDEX_SPMV_UXUA 2 124 #define RSB_OPTYPE_INDEX_SPMV_UNUA 3 125 #define RSB_OPTYPE_INDEX_SPMV_SASA 4 126 #define RSB_OPTYPE_INDEX_SPSV_UXUA 5 127 #define RSB_OPTYPE_INDEX_SPMV_SXSA 6 128 #define RSB_OPTYPE_INDEX_SPSV_SXSX 7 129 #define RSB_OPTYPE_INDEX_INFTY_NORM 8 130 #define RSB_OPTYPE_INDEX_ROWSSUMS 9 131 #define RSB_OPTYPE_INDEX_SCALE 10 132 #define RSB_OPTYPE_INDEX_MAT_STATS 11 133 134 /** 135 \name Values for valid matrix coordinate index types flags. 136 */ 137 #define RSB_COORDINATE_TYPE_C 0x01 /*!< \brief Character code for type rsb_coo_idx_t.*/ 138 #define RSB_COORDINATE_TYPE_H 0x02 /*!< \brief Character code for type rsb_half_idx_t.*/ 139 /* @endcond */ 140 /** 141 \name Values for valid matrix transposition flags. 142 \anchor matrix_transposition_flags_section 143 The Hermitian flag will act as simple transposed, for non complex types. 144 */ 145 #define RSB_TRANSPOSITION_N 0x4E /*!< \brief N: Non transposed flag, valid for \ref rsb_trans_t typed variables. */ 146 #define RSB_TRANSPOSITION_T 0x54 /*!< \brief T: Transposed flag value, valid for \ref rsb_trans_t valued variables. */ 147 #define RSB_TRANSPOSITION_C 0x43 /*!< \brief C: Conjugated transpose flag, valid for \ref rsb_trans_t typed variables. */ 148 /* @cond INNERDOC */ 149 #define RSB_TRANSPOSITION_INVALID 0x3F /*!< \brief ?: Transposition type flag value guaranteed to be invalid. Useful for tests. (undocumented in 1.2.0.10) */ 150 /** 151 \name Values for valid matrix symmetry flags. 152 \anchor matrix_symmetry_flags_section 153 */ 154 #define RSB_SYMMETRY_U 0x00 /* */ 155 #define RSB_SYMMETRY_S RSB_FLAG_SYMMETRIC /* */ 156 #define RSB_SYMMETRY_H RSB_FLAG_HERMITIAN /* */ 157 /* @endcond */ 158 /** 159 \name Values for inner diagonal specification values. 160 \anchor matrix_diagonal_flags_section 161 */ 162 /* @cond INNERDOC */ 163 #define RSB_DIAGONAL_E 0x01 /* */ /*!< \brief */ 164 #define RSB_DIAGONAL_I 0x02 /* */ /*!< \brief */ 165 /* @endcond */ 166 /* @cond INNERDOC */ 167 /** 168 \name Values for valid matrix storage formats. 169 \anchor matrix_storage_flags_section 170 */ 171 #define RSB_MATRIX_STORAGE_BCOR 0x40 /* */ 172 #define RSB_MATRIX_STORAGE_BCSR 0x01 /* */ 173 /** 174 \name Values for valid matrix storage formats strings. 175 \anchor matrix_storage_strings_section 176 */ 177 #define RSB_MATRIX_STORAGE_BCOR_STRING "BCOR" 178 #define RSB_MATRIX_STORAGE_BCSR_STRING "BCSR" 179 /* @endcond */ 180 181 /** 182 \name Valid symbol values for matrix numerical type specification -- type codes -- (type \see #rsb_type_t). 183 \anchor matrix_type_symbols_section 184 */ 185 #define RSB_NUMERICAL_TYPE_SAME_TYPE 1 /*!< \brief a bogus type flag for specifying no type conversion */ 186 #define RSB_NUMERICAL_TYPE_DOUBLE 'D' /*!< \brief Character code for type double. */ 187 #define RSB_NUMERICAL_TYPE_SAME_TYPE 1 /*!< \brief a bogus type flag for specifying no type conversion */ 188 #define RSB_NUMERICAL_TYPE_FLOAT 'S' /*!< \brief Character code for type float. */ 189 #define RSB_NUMERICAL_TYPE_SAME_TYPE 1 /*!< \brief a bogus type flag for specifying no type conversion */ 190 #define RSB_NUMERICAL_TYPE_FLOAT_COMPLEX 'C' /*!< \brief Character code for type float complex. */ 191 #define RSB_NUMERICAL_TYPE_SAME_TYPE 1 /*!< \brief a bogus type flag for specifying no type conversion */ 192 #define RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX 'Z' /*!< \brief Character code for type double complex. */ 193 194 #define RSB_NUMERICAL_TYPE_FORTRAN_SAME_TYPE 1 /*!< \brief a bogus type flag for specifying no type conversion */ 195 #define RSB_NUMERICAL_TYPE_FORTRAN_INT ICHAR('I') /*!< \brief Character code for type int, to be used (only) from Fortran. */ 196 #define RSB_NUMERICAL_TYPE_FORTRAN_DOUBLE ICHAR('D') /*!< \brief Character code for type double, to be used (only) from Fortran. */ 197 #define RSB_NUMERICAL_TYPE_FORTRAN_FLOAT ICHAR('S') /*!< \brief Character code for type float, to be used (only) from Fortran. */ 198 #define RSB_NUMERICAL_TYPE_FORTRAN_FLOAT_COMPLEX ICHAR('C') /*!< \brief Character code for type float complex, to be used (only) from Fortran. */ 199 #define RSB_NUMERICAL_TYPE_FORTRAN_DOUBLE_COMPLEX ICHAR('Z') /*!< \brief Character code for type double complex, to be used (only) from Fortran. */ 200 201 #define RSB_NUMERICAL_TYPE_DEFAULT RSB_NUMERICAL_TYPE_DOUBLE /*!< \brief A default numerical matrix type. */ 202 #define RSB_NUMERICAL_TYPE_DEFAULT_INTEGER RSB_NUMERICAL_TYPE_DOUBLE /*!< \brief A default numerical matrix type; if possible, an integer one. */ 203 #define RSB_NUMERICAL_TYPE_INVALID_TYPE '?' /*!< \brief By definition, an invalid type code. */ 204 #define RSB_NUMERICAL_TYPE_FIRST_BLAS RSB_NUMERICAL_TYPE_FLOAT /*!< \brief A default numerical matrix type; if possible, not integer one. If no such type is configured in, then the invalid type. */ 205 206 #define RSB_CHAR_AS_TRANSPOSITION(TRANSC) \ 207 ( \ 208 (TRANSC) == ('N') ? (RSB_TRANSPOSITION_N) : \ 209 (TRANSC) == ('n') ? (RSB_TRANSPOSITION_N) : \ 210 (TRANSC) == ('T') ? (RSB_TRANSPOSITION_T) : \ 211 (TRANSC) == ('t') ? (RSB_TRANSPOSITION_T) : \ 212 (TRANSC) == ('C') ? (RSB_TRANSPOSITION_C) : \ 213 (TRANSC) == ('c') ? (RSB_TRANSPOSITION_C) : \ 214 '?' \ 215 ) /*!< \brief Get the right transposition flag out of either n, c, t chars. */ 216 217 218 /** 219 \name Miscellaneous constants. 220 */ 221 #define RSB_CONST_MAX_TUNING_ROUNDS 16 /*!< \brief Maximal count of tuning rounds in one invocation of (rsb_tune_spmm/rsb_tune_spsm). */ 222 223 /* @cond INNERDOC */ 224 /** 225 \name Values for other numerical type related macros. 226 */ 227 #define RSB_NUMERICAL_TYPE_PREPROCESSOR_SYMBOLS "D S C Z " 228 229 /* a bogus type for pattern input (TODO : should also implement ANY, just for matrix input) */ 230 #define RSB_NUMERICAL_TYPE_PATTERN 0 231 /* @endcond */ 232 /* @cond INNERDOC */ 233 234 #define RSB_MATRIX_STORAGE_DOUBLE_PRINTF_STRING "%.17g" 235 #define RSB_MATRIX_STORAGE_FLOAT_PRINTF_STRING "%.9g" 236 #define RSB_MATRIX_STORAGE_FLOAT_COMPLEX_PRINTF_STRING "%.9g %.9g" 237 #define RSB_MATRIX_STORAGE_DOUBLE_COMPLEX_PRINTF_STRING "%.17g %.17g" 238 239 240 241 #if 1 242 243 #define RSB_ROWS_TRANSPOSITIONS_ARRAY_AS_CHAR {'n', 't', 'c', RSB_TRANSPOSITION_INVALID } 244 245 246 #define RSB_TRANSPOSITIONS_PREPROCESSOR_SYMBOLS "n t c " 247 248 #define RSB_TRANSPOSITION_AS_CHAR(TRANSA) \ 249 ( \ 250 (TRANSA) == (RSB_TRANSPOSITION_N) ? ('N') : \ 251 (TRANSA) == (RSB_TRANSPOSITION_T) ? ('T') : \ 252 (TRANSA) == (RSB_TRANSPOSITION_C) ? ('C') : \ 253 '?' \ 254 ) 255 256 257 #define RSB_NUMERICAL_TYPE_STRING(CSP,TYPE) \ 258 { \ 259 switch(TYPE) \ 260 { \ 261 /* supported (double,float,float complex,double complex) */ \ 262 case RSB_NUMERICAL_TYPE_DOUBLE :CSP="double";break; \ 263 case RSB_NUMERICAL_TYPE_FLOAT :CSP="float";break; \ 264 case RSB_NUMERICAL_TYPE_FLOAT_COMPLEX :CSP="float_complex";break; \ 265 case RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX :CSP="double_complex";break; \ 266 /* unsupported type */ \ 267 default : CSP="?"; \ 268 } \ 269 } 270 271 272 273 #define RSB_NUMERICAL_TYPE_SIZE(TYPE) \ 274 ( (TYPE)==(RSB_NUMERICAL_TYPE_DOUBLE ) ? sizeof(double) : \ 275 (( (TYPE)==(RSB_NUMERICAL_TYPE_FLOAT ) ? sizeof(float) : \ 276 (( (TYPE)==(RSB_NUMERICAL_TYPE_FLOAT_COMPLEX ) ? sizeof(float complex) : \ 277 (( (TYPE)==(RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX ) ? sizeof(double complex) : \ 278 (0 ) ) ) ) ) ) ) ) 279 280 #define RSB_SIZEOF_BACKUP(TYPE) /* This is for rsb__pr_load. Please feed in upper case char codes (toupper(...)). */ \ 281 ( (TYPE)==(73) ? 4 : \ 282 (( (TYPE)==(68) ? 8 : \ 283 (( (TYPE)==(83) ? 4 : \ 284 (( (TYPE)==(67) ? 8 : \ 285 (( (TYPE)==(90) ? 16 : \ 286 (0 ) ) ) ) ) ) ) ) ) ) 287 288 #define RSB_NUMERICAL_TYPE_REAL_TYPE(TYPE) \ 289 ( (TYPE)==(RSB_NUMERICAL_TYPE_DOUBLE ) ? RSB_NUMERICAL_TYPE_DOUBLE : \ 290 (( (TYPE)==(RSB_NUMERICAL_TYPE_FLOAT ) ? RSB_NUMERICAL_TYPE_FLOAT : \ 291 (( (TYPE)==(RSB_NUMERICAL_TYPE_FLOAT_COMPLEX ) ? RSB_NUMERICAL_TYPE_FLOAT : \ 292 (( (TYPE)==(RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX ) ? RSB_NUMERICAL_TYPE_DOUBLE : \ 293 (0 ) ) ) ) ) ) ) ) 294 295 #define RSB_NUMERICAL_TYPE_CAST_TO_ANY_P(CTYPE,CVAR,TYPE,TP,TOFF) \ 296 { \ 297 switch(TYPE) \ 298 { \ 299 /* supported (double,float,float complex,double complex) */ \ 300 case RSB_NUMERICAL_TYPE_DOUBLE :\ 301 (CVAR)=(CTYPE)((double*)TP)[TOFF] ; break; \ 302 case RSB_NUMERICAL_TYPE_FLOAT :\ 303 (CVAR)=(CTYPE)((float*)TP)[TOFF] ; break; \ 304 case RSB_NUMERICAL_TYPE_FLOAT_COMPLEX :\ 305 (CVAR)=(CTYPE)((float complex*)TP)[TOFF] ; break; \ 306 case RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX :\ 307 (CVAR)=(CTYPE)((double complex*)TP)[TOFF] ; break; \ 308 /* unsupported type */ \ 309 default : ; \ 310 } \ 311 } 312 313 /* *A += abs(*B) */ 314 #define RSB_NUMERICAL_TYPE_ABS_SUM_AND_STORE_ELEMENTS(A,B,TYPE) \ 315 { \ 316 switch(TYPE) \ 317 { \ 318 /* supported (double,float,float complex,double complex) */ \ 319 case RSB_NUMERICAL_TYPE_DOUBLE : *(double*)(A)+= ( \ 320 *(double*)(B) < (double)(0) ? - *(double*)(B) : *(double*)(B) ); break; \ 321 case RSB_NUMERICAL_TYPE_FLOAT : *(float*)(A)+= ( \ 322 *(float*)(B) < (float)(0) ? - *(float*)(B) : *(float*)(B) ); break; \ 323 case RSB_NUMERICAL_TYPE_FLOAT_COMPLEX : *(float complex*)(A)+= ( \ 324 *(float complex*)(B) < (float complex)(0) ? - *(float complex*)(B) : *(float complex*)(B) ); break; \ 325 case RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX : *(double complex*)(A)+= ( \ 326 *(double complex*)(B) < (double complex)(0) ? - *(double complex*)(B) : *(double complex*)(B) ); break; \ 327 /* unsupported type */ \ 328 default : ; \ 329 } \ 330 } 331 332 /* *A += *B */ 333 #define RSB_NUMERICAL_TYPE_SUM_AND_STORE_ELEMENTS(A,B,TYPE) \ 334 { \ 335 switch(TYPE) \ 336 { \ 337 /* supported (double,float,float complex,double complex) */ \ 338 case RSB_NUMERICAL_TYPE_DOUBLE : *(double*)(A)+=*(double*)(B); break; \ 339 case RSB_NUMERICAL_TYPE_FLOAT : *(float*)(A)+=*(float*)(B); break; \ 340 case RSB_NUMERICAL_TYPE_FLOAT_COMPLEX : *(float complex*)(A)+=*(float complex*)(B); break; \ 341 case RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX : *(double complex*)(A)+=*(double complex*)(B); break; \ 342 /* unsupported type */ \ 343 default : ; \ 344 } \ 345 } 346 347 #define RSB_NUMERICAL_TYPE_SET_ELEMENT(DST,SRC,TYPE) \ 348 { \ 349 switch(TYPE) \ 350 { \ 351 /* supported (double,float,float complex,double complex) */ \ 352 case RSB_NUMERICAL_TYPE_DOUBLE : *(double*)(DST)=*(double*)(SRC); break; \ 353 case RSB_NUMERICAL_TYPE_FLOAT : *(float*)(DST)=*(float*)(SRC); break; \ 354 case RSB_NUMERICAL_TYPE_FLOAT_COMPLEX : *(float complex*)(DST)=*(float complex*)(SRC); break; \ 355 case RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX : *(double complex*)(DST)=*(double complex*)(SRC); break; \ 356 /* unsupported type */ \ 357 default : ; \ 358 } \ 359 } 360 361 #define RSB_NUMERICAL_TYPE_SET_ELEMENT_REAL(DST,SRC,TYPE) \ 362 { \ 363 switch(TYPE) \ 364 { \ 365 case RSB_NUMERICAL_TYPE_DOUBLE : *(double*)(DST)=(*(double*)(SRC)); break; \ 366 case RSB_NUMERICAL_TYPE_FLOAT : *(float*)(DST)=(*(float*)(SRC)); break; \ 367 case RSB_NUMERICAL_TYPE_FLOAT_COMPLEX : *(float*)(DST)=crealf(*(float complex*)(SRC)); break; \ 368 case RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX : *(double*)(DST)=creal(*(double complex*)(SRC)); break; \ 369 /* unsupported type */ \ 370 default : ; \ 371 } \ 372 } 373 374 #define RSB_NUMERICAL_TYPE_SET_ELEMENT_FROM_DOUBLE(DST,DSRC,TYPE) \ 375 { \ 376 switch(TYPE) \ 377 { \ 378 /* supported (double,float,float complex,double complex) */ \ 379 case RSB_NUMERICAL_TYPE_DOUBLE : *(double*)(DST)=(double)(DSRC); break; \ 380 case RSB_NUMERICAL_TYPE_FLOAT : *(float*)(DST)=(float)(DSRC); break; \ 381 case RSB_NUMERICAL_TYPE_FLOAT_COMPLEX : *(float complex*)(DST)=(float complex)(DSRC); break; \ 382 case RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX : *(double complex*)(DST)=(double complex)(DSRC); break; \ 383 /* unsupported type */ \ 384 default : ; \ 385 } \ 386 } 387 388 /* CODE NOT DEBUGGED */ 389 #define RSB_VECTOR_FIND_MAXIMAL_ELEMENT(INDEX,ARRAY,ELEMENTS,TYPE) \ 390 { \ 391 int _index; \ 392 switch(TYPE) \ 393 { \ 394 /* supported (double,float,float complex,double complex) */ \ 395 case RSB_NUMERICAL_TYPE_DOUBLE : \ 396 { \ 397 double * _array = (double*)(ARRAY); \ 398 double _maxel=(double)(0); \ 399 int _maxindex=0; \ 400 _maxel=_maxel-_maxel; /* could this be evil ? */ \ 401 for(_index=0;_index<(ELEMENTS);++_index) \ 402 if(fabs(_maxel)<fabs(_array[_index])){_maxel=_array[_index];_maxindex=_index;} \ 403 (INDEX)=_maxindex; \ 404 } \ 405 break; \ 406 case RSB_NUMERICAL_TYPE_FLOAT : \ 407 { \ 408 float * _array = (float*)(ARRAY); \ 409 float _maxel=(float)(0); \ 410 int _maxindex=0; \ 411 _maxel=_maxel-_maxel; /* could this be evil ? */ \ 412 for(_index=0;_index<(ELEMENTS);++_index) \ 413 if(fabsf(_maxel)<fabsf(_array[_index])){_maxel=_array[_index];_maxindex=_index;} \ 414 (INDEX)=_maxindex; \ 415 } \ 416 break; \ 417 case RSB_NUMERICAL_TYPE_FLOAT_COMPLEX : \ 418 { \ 419 float complex * _array = (float complex*)(ARRAY); \ 420 float complex _maxel=(float complex)(0); \ 421 int _maxindex=0; \ 422 _maxel=_maxel-_maxel; /* could this be evil ? */ \ 423 for(_index=0;_index<(ELEMENTS);++_index) \ 424 if(cabsf(_maxel)<cabsf(_array[_index])){_maxel=_array[_index];_maxindex=_index;} \ 425 (INDEX)=_maxindex; \ 426 } \ 427 break; \ 428 case RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX : \ 429 { \ 430 double complex * _array = (double complex*)(ARRAY); \ 431 double complex _maxel=(double complex)(0); \ 432 int _maxindex=0; \ 433 _maxel=_maxel-_maxel; /* could this be evil ? */ \ 434 for(_index=0;_index<(ELEMENTS);++_index) \ 435 if(cabs(_maxel)<cabs(_array[_index])){_maxel=_array[_index];_maxindex=_index;} \ 436 (INDEX)=_maxindex; \ 437 } \ 438 break; \ 439 /* unsupported type */ \ 440 default : (INDEX)=-1; \ 441 } \ 442 } 443 444 #define RSB_NUMERICAL_OP_INDEX_FROM_CODE(CODE) \ 445 ( ((CODE)==RSB_OPTYPE_INDEX_SPMV_UAUA )?(0): \ 446 ( ((CODE)==RSB_OPTYPE_INDEX_SPMV_UAUZ )?(1): \ 447 ( ((CODE)==RSB_OPTYPE_INDEX_SPMV_UXUA )?(2): \ 448 ( ((CODE)==RSB_OPTYPE_INDEX_SPMV_UNUA )?(3): \ 449 ( ((CODE)==RSB_OPTYPE_INDEX_SPMV_SASA )?(4): \ 450 ( ((CODE)==RSB_OPTYPE_INDEX_SPSV_UXUA )?(5): \ 451 ( ((CODE)==RSB_OPTYPE_INDEX_SPMV_SXSA )?(6): \ 452 ( ((CODE)==RSB_OPTYPE_INDEX_SPSV_SXSX )?(7): \ 453 ( ((CODE)==RSB_OPTYPE_INDEX_INFTY_NORM )?(8): \ 454 ( ((CODE)==RSB_OPTYPE_INDEX_ROWSSUMS )?(9): \ 455 ( ((CODE)==RSB_OPTYPE_INDEX_SCALE )?(10): \ 456 ( ((CODE)==RSB_OPTYPE_INDEX_MAT_STATS )?(11): \ 457 -1 ) \ 458 ) \ 459 ) \ 460 ) \ 461 ) \ 462 ) \ 463 ) \ 464 ) \ 465 ) \ 466 ) \ 467 ) \ 468 ) \ 469 /* uhm. does it seem redundant ? */ 470 #define RSB_NUMERICAL_TYPE_INDEX_FROM_CODE(CODE) \ 471 ( ((CODE)==RSB_NUMERICAL_TYPE_DOUBLE )?(0): \ 472 ( ((CODE)==RSB_NUMERICAL_TYPE_FLOAT )?(1): \ 473 ( ((CODE)==RSB_NUMERICAL_TYPE_FLOAT_COMPLEX )?(2): \ 474 ( ((CODE)==RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX )?(3): \ 475 -1 ) \ 476 ) \ 477 ) \ 478 ) \ 479 /* uhm. seems redundant ? */ 480 481 482 #define RSB_IS_ELEMENT_MINUS_ONE(SRC,TYPE) \ 483 ( \ 484 (TYPE) == (RSB_NUMERICAL_TYPE_DOUBLE ) ? (*(double*)(SRC)==(double)(-1)) : \ 485 (TYPE) == (RSB_NUMERICAL_TYPE_FLOAT ) ? (*(float*)(SRC)==(float)(-1)) : \ 486 (TYPE) == (RSB_NUMERICAL_TYPE_FLOAT_COMPLEX ) ? (*(float complex*)(SRC)==(float complex)(-1)) : \ 487 (TYPE) == (RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX ) ? (*(double complex*)(SRC)==(double complex)(-1)) : \ 488 0 \ 489 ) 490 491 #define RSB_IS_ELEMENT_ONE(SRC,TYPE) \ 492 ( \ 493 (TYPE) == (RSB_NUMERICAL_TYPE_DOUBLE ) ? (*(double*)(SRC)==(double)1) : \ 494 (TYPE) == (RSB_NUMERICAL_TYPE_FLOAT ) ? (*(float*)(SRC)==(float)1) : \ 495 (TYPE) == (RSB_NUMERICAL_TYPE_FLOAT_COMPLEX ) ? (*(float complex*)(SRC)==(float complex)1) : \ 496 (TYPE) == (RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX ) ? (*(double complex*)(SRC)==(double complex)1) : \ 497 0 \ 498 ) 499 500 #define RSB_IS_ELEMENT_ZERO(SRC,TYPE) \ 501 ( \ 502 (TYPE) == (RSB_NUMERICAL_TYPE_DOUBLE ) ? (*(double*)(SRC)==(double)0) : \ 503 (TYPE) == (RSB_NUMERICAL_TYPE_FLOAT ) ? (*(float*)(SRC)==(float)0) : \ 504 (TYPE) == (RSB_NUMERICAL_TYPE_FLOAT_COMPLEX ) ? (*(float complex*)(SRC)==(float complex)0) : \ 505 (TYPE) == (RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX ) ? (*(double complex*)(SRC)==(double complex)0) : \ 506 0 \ 507 ) 508 509 #define RSB_IS_ELEMENT_NONZERO(SRC,TYPE) (!(RSB_IS_ELEMENT_ZERO(SRC,TYPE))) 510 511 #define RSB_MATRIX_UNSUPPORTED_TYPE(TYPE) ( \ 512 (TYPE)!=RSB_NUMERICAL_TYPE_DOUBLE && \ 513 (TYPE)!=RSB_NUMERICAL_TYPE_FLOAT && \ 514 (TYPE)!=RSB_NUMERICAL_TYPE_FLOAT_COMPLEX && \ 515 (TYPE)!=RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX && \ 516 1 ) 517 518 #define RSB_IS_MATRIX_TYPE_COMPLEX(TYPE) \ 519 ( \ 520 (TYPE) == (RSB_NUMERICAL_TYPE_DOUBLE ) ? 0 : \ 521 (TYPE) == (RSB_NUMERICAL_TYPE_FLOAT ) ? 0 : \ 522 (TYPE) == (RSB_NUMERICAL_TYPE_FLOAT_COMPLEX ) ? 1 : \ 523 (TYPE) == (RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX ) ? 1 : \ 524 0 \ 525 ) 526 527 #define RSB_IS_ELEMENT_LESS_THAN(SRC,CMPSRC,TYPE) \ 528 ( ( (TYPE)==RSB_NUMERICAL_TYPE_DOUBLE && (*(double*)(SRC))<(*(double*)(CMPSRC)) ) || \ 529 ( (TYPE)==RSB_NUMERICAL_TYPE_FLOAT && (*(float*)(SRC))<(*(float*)(CMPSRC)) ) || \ 530 ( (TYPE)==RSB_NUMERICAL_TYPE_FLOAT_COMPLEX && crealf(*(float complex*)(SRC))<crealf(*(float complex*)(CMPSRC)) ) || \ 531 ( (TYPE)==RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX && creal(*(double complex*)(SRC))<creal(*(double complex*)(CMPSRC)) ) || \ 532 0 ) 533 534 535 /** use RSB_MAXIMAL_CONFIGURED_BLOCK_SIZE to oversize your arrays safely */ 536 #define RSB_MAXIMAL_CONFIGURED_BLOCK_SIZE 1 537 /** use RSB_MAXIMAL_CONFIGURED_BLOCK_SIZE_EXTRA to oversize your arrays safely */ 538 #define RSB_MAXIMAL_CONFIGURED_BLOCK_SIZE_EXTRA (1-1) 539 #define RSB_CONST_MATRIX_IMPLEMENTATION_CODE_STRING_MAX_LENGTH (2*1024) /** chars to reserve for a matrix implementation code */ 540 541 /* Section dedicated to implemented operations on matrices. */ 542 543 544 545 #define RSB_ROWS_UNROLL_ARRAY { 1 } 546 #define RSB_COLUMNS_UNROLL_ARRAY { 1 } 547 548 549 #define RSB_ROWS_UNROLL_ARRAY_LENGTH 1 550 #define RSB_COLUMNS_UNROLL_ARRAY_LENGTH 1 551 #define RSB_IMPLEMENTED_META_MOPS 12 552 #define RSB_IMPLEMENTED_MOPS 11 553 #define RSB_IMPLEMENTED_TYPES 4 554 #define RSB_IMPLEMENTED_SOME_BLAS_TYPES 1 555 556 #define RSB_MATRIX_OPS_ARRAY { "spmv_uaua","spmv_uauz","spmv_uxua","spmv_unua","spmv_sasa","spsv_uxua","spmv_sxsa","spsv_sxsx","infty_norm","rowssums","scale","mat_stats" } 557 #define RSB_MATRIX_TYPES_ARRAY { "double","float","float complex","double complex", } 558 #define RSB_MATRIX_TYPE_CODES_ARRAY { RSB_NUMERICAL_TYPE_DOUBLE ,RSB_NUMERICAL_TYPE_FLOAT ,RSB_NUMERICAL_TYPE_FLOAT_COMPLEX ,RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX , } 559 #define RSB_MATRIX_SPBLAS_TYPE_CODES_ARRAY { RSB_NUMERICAL_TYPE_FLOAT ,RSB_NUMERICAL_TYPE_DOUBLE ,RSB_NUMERICAL_TYPE_FLOAT_COMPLEX ,RSB_NUMERICAL_TYPE_DOUBLE_COMPLEX , } 560 561 #define RSB_M4_MATRIX_META_OPS_STRING "spmv_uaua,spmv_uauz,spmv_uxua,spmv_unua,spmv_sasa,spsv_uxua,spmv_sxsa,spsv_sxsx,infty_norm,rowssums,scale" 562 #define RSB_M4_MATRIX_TYPES_STRING "double,float,float complex,double complex" 563 #define RSB_M4_WANT_COLUMN_UNLOOP_FACTORS_STRING "1" 564 #define RSB_M4_WANT_ROW_UNLOOP_FACTORS_STRING "1" 565 566 /** 567 \name Macro to check matrix storage flags correctness 568 */ 569 #define RSB_IS_MATRIX_STORAGE_ALLOWED_FOR_LEAF(MATRIX_STORAGE) (( \ 570 ((MATRIX_STORAGE)==RSB_MATRIX_STORAGE_BCOR) || \ 571 ((MATRIX_STORAGE)==RSB_MATRIX_STORAGE_BCSR) || \ 572 0 ) ? RSB_BOOL_TRUE:RSB_BOOL_FALSE ) 573 574 #ifdef __cplusplus 575 } 576 #endif /* __cplusplus */ 577 578 #endif 579 #endif /* RSB_TYPES_H_INCLUDED */ 580 /* @endcond */ 581