1 #ifndef CADO_TYPEDEFS_H_ 2 #define CADO_TYPEDEFS_H_ 3 4 // pragma no prototypes 5 #include <inttypes.h> // PRIx32 etc 6 #include "ularith.h" /* NEEDED for LONG_BIT (32 or 64) */ 7 8 /* data type to store the (p,r) values */ 9 #ifndef SIZEOF_P_R_VALUES 10 #define SIZEOF_P_R_VALUES 4 11 #elif SIZEOF_P_R_VALUES != 4 && SIZEOF_P_R_VALUES != 8 12 #error "Defined constant SIZEOF_P_R_VALUES should be 4 or 8" 13 #endif 14 15 /* data type to store the renumber table */ 16 #ifndef SIZEOF_INDEX 17 #define SIZEOF_INDEX 4 18 #elif SIZEOF_INDEX < 4 || 8 < SIZEOF_INDEX 19 #error "Defined constant SIZEOF_INDEX should be in [4..8]" 20 #endif 21 22 #if SIZEOF_INDEX > SIZEOF_P_R_VALUES 23 #error "SIZEOF_INDEX should be smaller or equal to SIZEOF_P_R_VALUES" 24 #endif 25 26 #if (SIZEOF_P_R_VALUES * 8) > LONG_BIT 27 #error "SIZEOF_P_R_VALUES cannot be greater than LONG_BIT / 8" 28 #endif 29 30 #if SIZEOF_P_R_VALUES == 4 31 typedef uint32_t p_r_values_t; 32 #define CADO_MPI_P_R_VALUES_T CADO_MPI_UINT32_T 33 #define PRpr PRIx32 34 #define SCNpr SCNx32 35 #else /* SIZEOF_P_R_VALUES == 8 */ 36 typedef uint64_t p_r_values_t; 37 #define CADO_MPI_P_R_VALUES_T CADO_MPI_UINT64_T 38 #define PRpr PRIx64 39 #define SCNpr SCNx64 40 #endif 41 42 #if SIZEOF_INDEX == 4 43 typedef uint32_t index_t; 44 typedef int32_t index_signed_t; 45 #define PRid PRIx32 46 #define SCNid SCNx32 47 #else /* SIZEOF_INDEX == 8 */ 48 typedef uint64_t index_t; 49 typedef int64_t index_signed_t; 50 #define PRid PRIx64 51 #define SCNid SCNx64 52 #endif 53 54 /* The weight of ideals saturates at 255 */ 55 /* For relations, we hope that there will never be more */ 56 /* than 255 ideals per relation */ 57 typedef uint8_t weight_t; 58 typedef int8_t exponent_t; 59 #define REL_MAX_SIZE 255 60 61 typedef struct { 62 index_t h; 63 p_r_values_t p; 64 exponent_t e; 65 uint8_t side; 66 } prime_t; 67 68 typedef struct { 69 index_t id; 70 int32_t e; 71 } ideal_merge_t; 72 73 typedef struct { 74 uint64_t nrows; 75 uint64_t ncols; 76 double W; /* weight of the active part of the matrix */ 77 } info_mat_t; 78 79 #endif /* CADO_TYPEDEFS_H_ */ 80