[6328] | 1 | #ifndef TYPE_H |
---|
| 2 | #define TYPE_H |
---|
| 3 | |
---|
| 4 | /* type.h */ |
---|
| 5 | /* defines interface and types used for mpi-serial user-defined datatypes */ |
---|
| 6 | |
---|
| 7 | #include "mpiP.h" |
---|
| 8 | |
---|
| 9 | //for Fortran type sizes |
---|
| 10 | #ifdef HAVE_CONFIG_H |
---|
| 11 | #include <config.h> |
---|
| 12 | #endif |
---|
| 13 | |
---|
| 14 | //predefined type value used in typemap |
---|
| 15 | typedef int Simpletype; |
---|
| 16 | |
---|
| 17 | typedef struct |
---|
| 18 | { |
---|
| 19 | long disp; |
---|
| 20 | Simpletype type; |
---|
| 21 | } typepair; |
---|
| 22 | |
---|
| 23 | typedef struct |
---|
| 24 | { |
---|
| 25 | int count; |
---|
| 26 | long ub; |
---|
| 27 | long lb; |
---|
| 28 | int committed; //type has been committed |
---|
| 29 | int o_lb; //overridden lower/upper bound |
---|
| 30 | int o_ub; // " |
---|
| 31 | /* pairs[] is size 2 because of predefined types |
---|
| 32 | * such as MPI_2INT that have 2 typemap entries |
---|
| 33 | * upon initialization. |
---|
| 34 | */ |
---|
| 35 | typepair pairs[2]; |
---|
| 36 | } Typestruct; |
---|
| 37 | |
---|
| 38 | typedef Typestruct* Datatype; |
---|
| 39 | |
---|
| 40 | //Simpletype constants |
---|
| 41 | #define SIMPLE_CHAR 0 |
---|
| 42 | #define SIMPLE_SHORT 1 |
---|
| 43 | #define SIMPLE_INT 2 |
---|
| 44 | #define SIMPLE_LONG 3 |
---|
| 45 | #define SIMPLE_UCHAR 4 |
---|
| 46 | #define SIMPLE_USHORT 5 |
---|
| 47 | #define SIMPLE_UINT 6 |
---|
| 48 | #define SIMPLE_ULONG 7 |
---|
| 49 | #define SIMPLE_FLOAT 8 |
---|
| 50 | #define SIMPLE_DOUBLE 9 |
---|
| 51 | #define SIMPLE_LDOUBLE 10 |
---|
| 52 | #define SIMPLE_BYTE 11 |
---|
| 53 | #define SIMPLE_LOWER 12 |
---|
| 54 | #define SIMPLE_UPPER 13 |
---|
| 55 | #define SIMPLE_FINTEGER 14 |
---|
| 56 | #define SIMPLE_FREAL 15 |
---|
| 57 | #define SIMPLE_FDPRECISION 16 |
---|
| 58 | #define SIMPLE_FCOMPLEX 17 |
---|
| 59 | #define SIMPLE_FDCOMPLEX 18 |
---|
| 60 | #define SIMPLE_FLOGICAL 19 |
---|
| 61 | #define SIMPLE_FCHARACTER 20 |
---|
| 62 | |
---|
| 63 | #define SIMPLE_FINTEGER1 21 |
---|
| 64 | #define SIMPLE_FINTEGER2 22 |
---|
| 65 | #define SIMPLE_FINTEGER4 23 |
---|
| 66 | #define SIMPLE_FINTEGER8 24 |
---|
| 67 | #define SIMPLE_FINTEGER16 25 |
---|
| 68 | |
---|
| 69 | #define SIMPLE_FREAL4 26 |
---|
| 70 | #define SIMPLE_FREAL8 27 |
---|
| 71 | #define SIMPLE_FREAL16 28 |
---|
| 72 | |
---|
| 73 | #define SIMPLE_FCOMPLEX8 29 |
---|
| 74 | #define SIMPLE_FCOMPLEX16 30 |
---|
| 75 | #define SIMPLE_FCOMPLEX32 31 |
---|
| 76 | |
---|
| 77 | #define SIMPLE_LONGLONG 32 |
---|
| 78 | #define SIMPLE_ULONGLONG 33 |
---|
| 79 | |
---|
| 80 | #define SIMPLE_OFFSET 34 |
---|
| 81 | |
---|
| 82 | //internal type functions |
---|
| 83 | int Simpletype_length(Simpletype s); |
---|
| 84 | |
---|
| 85 | //testing only |
---|
| 86 | int print_typemap(MPI_Datatype in); |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | /* |
---|
| 90 | * Fortran type sizes |
---|
| 91 | * |
---|
| 92 | * If config.h is used and the user has specified |
---|
| 93 | * sizes using --enable-fort-real and --enable-fort-double |
---|
| 94 | * args, they will be used here. Otherwise just take a shot |
---|
| 95 | * in the dark? |
---|
| 96 | * |
---|
| 97 | */ |
---|
| 98 | |
---|
| 99 | #ifdef CONFIG_FORT_REAL |
---|
| 100 | #define FSIZE_REAL CONFIG_FORT_REAL |
---|
| 101 | #else |
---|
| 102 | #define FSIZE_REAL 4 //guess something reasonable |
---|
| 103 | #endif |
---|
| 104 | |
---|
| 105 | #ifdef CONFIG_FORT_DOUBLE |
---|
| 106 | #define FSIZE_DPRECISION CONFIG_FORT_DOUBLE |
---|
| 107 | #else |
---|
| 108 | #define FSIZE_DPRECISION 8 |
---|
| 109 | #endif |
---|
| 110 | |
---|
| 111 | #define FSIZE_INTEGER 4 |
---|
| 112 | #define FSIZE_COMPLEX 2*FSIZE_REAL |
---|
| 113 | #define FSIZE_DCOMPLEX 2*FSIZE_DPRECISION |
---|
| 114 | #define FSIZE_LOGICAL 4 |
---|
| 115 | #define FSIZE_CHARACTER 1 |
---|
| 116 | |
---|
| 117 | const extern Datatype simpletypes[]; |
---|
| 118 | Datatype* mpi_handle_to_datatype(int handle); |
---|
| 119 | |
---|
| 120 | extern int Unpack(void * inbuf, int insize, int * position, void *outbuf, |
---|
| 121 | int outcount, Datatype type, Comm* comm); |
---|
| 122 | extern int Pack(void *inbuf, int incount, Datatype type, |
---|
| 123 | void *outbuf, int outsize, int *position, Comm * comm); |
---|
| 124 | #endif /* TYPE_H */ |
---|