00001
00006 #ifndef ___IPC_H___
00007 #define ___IPC_H___
00008
00009 #include <stdlib.h>
00010
00011 #include "ind_types.h"
00012
00013
00014
00015
00016
00017 #ifdef _CRAYMPP
00018 #ifdef __cplusplus
00019 #define LONG_LONG_UNAVAILABLE
00020 #endif
00021 #endif
00022
00023
00024
00025 typedef unsigned int ipc_datatype;
00026 typedef int ipc_status;
00027
00028 #define IPC_RAW8 ((ipc_datatype)1)
00029 #define IPC_RAW32 ((ipc_datatype)2)
00030 #define IPC_RAW64 ((ipc_datatype)3)
00031 #define IPC_CHAR ((ipc_datatype)4)
00032 #define IPC_SHORT ((ipc_datatype)5)
00033 #define IPC_INT ((ipc_datatype)6)
00034 #define IPC_LONG ((ipc_datatype)7)
00035 #define IPC_LONG_LONG ((ipc_datatype)8)
00036 #define IPC_UNSIGNED_CHAR ((ipc_datatype)9)
00037 #define IPC_UNSIGNED_SHORT ((ipc_datatype)10)
00038 #define IPC_UNSIGNED ((ipc_datatype)11)
00039 #define IPC_UNSIGNED_LONG ((ipc_datatype)12)
00040 #define IPC_FLOAT ((ipc_datatype)13)
00041 #define IPC_DOUBLE ((ipc_datatype)14)
00042 #define IPC_LONG_DOUBLE ((ipc_datatype)15)
00045 #define IPC_NO_ERROR 0
00046
00047 #define IPC_EXIT_NORMAL 0
00048 #define IPC_EXIT_WRONG_USAGE 1
00049 #define IPC_EXIT_FILE_PROBLEM 2
00050 #define IPC_EXIT_PARAM_VALUE_ERROR 3
00051 #define IPC_EXIT_OUT_OF_MEMORY 4
00052 #define IPC_EXIT_TOO_MANY_ERRORS 5
00053
00054
00055
00056
00057 #define IPC_NONE -10
00058 #define IPC_ERROR -6
00059 #define IPC_WARNING -4
00060 #define IPC_CAUTION -2
00061 #define IPC_ALERT 0
00062 #define IPC_REQUESTED 1
00063 #define IPC_SUMMARY 2
00064 #define IPC_STD 4
00065 #define IPC_VERBOSE 6
00066 #define IPC_OVERWHELM 10
00067
00068
00069
00070
00071
00072 #define IPC_ONE 0
00073 #define IPC_ALL -1
00074
00075
00076 extern int ipc_msg_level;
00077 extern int ipc_exit_on_error_num;
00078 extern int ipc_max_errors;
00079 extern int ipc_max_warnings;
00080 extern int ipc_msg_forceall_level;
00081 extern int ipc_msg_synch_level;
00082
00083
00084 extern const char* ipc_msg_level_docstring;
00085 extern const char* ipc_exit_on_error_num_docstring;
00086 extern const char* ipc_max_errors_docstring;
00087 extern const char* ipc_max_warnings_docstring;
00088 extern const char* ipc_msg_forceall_level_docstring;
00089 extern const char* ipc_msg_synch_level_docstring;
00090
00091
00092 int ipc_datatype_size(ipc_datatype datatype);
00093 int ipc_num_processes(void);
00094 int ipc_my_process(void);
00095 void ipc_barrier(void);
00096 void ipc_set_barrier(void);
00097
00098
00099
00100
00101 #ifndef __cplusplus
00102 ipc_status ipc_put(void *data, ipc_datatype datatype, size_t count, int process);
00103 ipc_status ipc_get(void *data, ipc_datatype datatype, size_t count, int process);
00104 ipc_status ipc_put_to(void *target_data, void *source_data, ipc_datatype datatype, size_t count, int process);
00105 ipc_status ipc_get_to(void *target_data, void *source_data, ipc_datatype datatype, size_t count, int process);
00106
00107
00108
00109
00110
00111 #else
00112 #define IPC_CALL_PROTO(name, type,ipc_type) \
00113 ipc_status ipc_ ## name (type *data, size_t count, int process); \
00114 ipc_status ipc_ ## name (type *data, ipc_datatype datatype, size_t count, int process); \
00115 ipc_status ipc_ ## name ## _to (type *target, type *source, size_t count, int process); \
00116 ipc_status ipc_ ## name ## _to (type *target, type *source, ipc_datatype datatype, size_t count, int process)
00117
00118
00119 IPC_CALL_PROTO(put, signed short ,IPC_SHORT );
00120 IPC_CALL_PROTO(put, signed int ,IPC_INT );
00121 IPC_CALL_PROTO(put, signed long ,IPC_LONG );
00122 #ifndef LONG_LONG_UNAVAILABLE
00123 IPC_CALL_PROTO(put, signed long long ,IPC_LONG_LONG );
00124 #endif
00125 IPC_CALL_PROTO(put, unsigned char ,IPC_UNSIGNED_CHAR );
00126 IPC_CALL_PROTO(put, unsigned short ,IPC_UNSIGNED_SHORT );
00127 IPC_CALL_PROTO(put, unsigned int ,IPC_UNSIGNED );
00128 IPC_CALL_PROTO(put, unsigned long ,IPC_UNSIGNED_LONG );
00129 IPC_CALL_PROTO(put, float ,IPC_FLOAT );
00130 IPC_CALL_PROTO(put, double ,IPC_DOUBLE );
00131 #ifndef LONG_DOUBLE_UNAVAILABLE
00132 IPC_CALL_PROTO(put, long double ,IPC_LONG_DOUBLE );
00133 #endif
00134
00135
00136 IPC_CALL_PROTO(get, signed short ,IPC_SHORT );
00137 IPC_CALL_PROTO(get, signed int ,IPC_INT );
00138 IPC_CALL_PROTO(get, signed long ,IPC_LONG );
00139 #ifndef LONG_LONG_UNAVAILABLE
00140 IPC_CALL_PROTO(get, signed long long ,IPC_LONG_LONG );
00141 #endif
00142 IPC_CALL_PROTO(get, unsigned char ,IPC_UNSIGNED_CHAR );
00143 IPC_CALL_PROTO(get, unsigned short ,IPC_UNSIGNED_SHORT );
00144 IPC_CALL_PROTO(get, unsigned int ,IPC_UNSIGNED );
00145 IPC_CALL_PROTO(get, unsigned long ,IPC_UNSIGNED_LONG );
00146 IPC_CALL_PROTO(get, float ,IPC_FLOAT );
00147 IPC_CALL_PROTO(get, double ,IPC_DOUBLE );
00148 #ifndef LONG_DOUBLE_UNAVAILABLE
00149 IPC_CALL_PROTO(get, long double ,IPC_LONG_DOUBLE );
00150 #endif
00151 #undef IPC_CALL_PROTO
00152
00153 #endif
00154
00155
00161 #define IPC_PUT_RAW_PROTO(bits) \
00162 ipc_status ipc_put ## bits(void *data, size_t count, int process);
00163 IPC_PUT_RAW_PROTO(8)
00164 IPC_PUT_RAW_PROTO(32)
00165 IPC_PUT_RAW_PROTO(64)
00166 #undef IPC_PUT_RAW_PROTO
00167
00168 #define IPC_GET_RAW_PROTO(bits) \
00169 ipc_status ipc_get ## bits(void *data, size_t count, int process);
00170 IPC_GET_RAW_PROTO(8)
00171 IPC_GET_RAW_PROTO(32)
00172 IPC_GET_RAW_PROTO(64)
00173 #undef IPC_GET_RAW_PROTO
00174
00175
00176 void ipc_pe_msg_delay( double scale );
00177 void ipc_init(void);
00178 void ipc_init_logfile(const char *basefilename);
00179
00180 void ipc_log( int print_pe, const char *format, ...);
00181 int ipc_notify( int print_pe, int message_level, const char *format, ...);
00182 void ipc_notify2(int terminateline, int print_pe, int message_level, const char *format, ...);
00183 void ipc_exit( int status, const char *format, ...);
00184 void ipc_abort( int status, const char *format, ...);
00185
00186
00187
00188
00189
00190
00191
00192 void ipc_error( void );
00193 void ipc_warning( void );
00194
00195
00196 #ifdef __cplusplus
00197 #ifndef NO_STRINGS
00198 #include <string>
00199 using std::string;
00200
00201 namespace Msg {
00210 void ipc_verbose (const string& s, const bool terminate=true);
00211 void ipc_notify (const string& s, const bool terminate=true);
00212 void ipc_requested (const string& s, const bool terminate=true);
00213 void ipc_error (const string& s, const bool terminate=true);
00214 void ipc_warning (const string& s, const bool terminate=true);
00216 }
00217 #endif
00218 #endif
00219
00220 #endif
00221
00222