00001 #ifndef MOC_INTERNAL_CORE_ 00002 #define MOC_INTERNAL_CORE_ 00003 00004 00005 #include <stdint.h> 00006 00007 00008 /** 00009 * \addtogroup internal_core 00010 * 00011 * This section deals with the data-structures and the basic concepts which 00012 * form the core of this implementation. 00013 * 00014 * \section icore_struct Data-Structures 00015 * 00016 * Basically there are four data-structures. \ref moc_message_envelope_struct 00017 * holds meta-information about a message and \ref moc_message_status_struct holds 00018 * information about used buffer-space and provide means for a receiving proccess 00019 * to send some information back to the sending process. 00020 * 00021 * \ref moc_process_struct stores information every node needs to know about the 00022 * other nodes to successfully communicate with them. 00023 * 00024 * The forth data-structure (actually there are two) \ref moc_node_handle_ppu_struct 00025 * respectively \ref moc_node_handle_spu_struct holds information a node know about 00026 * itself and the execution environment. 00027 * 00028 * \section core_conc Concepts 00029 * 00030 * Every node has (N-1) queues for incoming messages, where N is the overall number 00031 * of node. Each queue is exclusively used by a specific remote node to write 00032 * meta-data about the message to be send into it (queue-entries are of type \ref 00033 * moc_message_envelope_struct). Because there are several independend queues and no 00034 * global time is available, an exact order of all incoming messages cannot be guaranteed. 00035 * Corrent ordering can only be guaranteed for messages from the same source-node. 00036 * The queues are implemented in form of a big array which is divided in (N-1) equally 00037 * sized pieces. 00038 * 00039 * Furthermore every node has an array of size (N-1)*m where m is the size of a 00040 * message-queue (entries are of type \ref moc_message_status_struct). 00041 * This array is used for buffer-management and to report the status of a message 00042 * back to the sender. 00043 * Every message currently under progress has a message-id which is unique in respect 00044 * to the sending-node. This message-id is equal to the index of the corresponding 00045 * entry of the status-array. 00046 * 00047 * In order to communicate with other nodes every node also keeps a list of all nodes 00048 * in the execution environment (entries are of type \ref moc_process_struct). 00049 * 00050 * Pointers to the own arrays and some further information a node needs to know (e.g. 00051 * own rank) is stored in the globally accessible variable \ref node_handle. 00052 **/ 00053 //@{ 00054 /** 00055 * @name PPU & SPU 00056 **/ 00057 //@{ 00058 00059 00060 /** 00061 * Default size of the message-queues. 00062 **/ 00063 #define MOC_QUEUE_SIZE 4 00064 00065 /** 00066 * Default size of the buffers used for buffered communication. 00067 **/ 00068 #define MOC_BUFFER_SIZE 2048 00069 00070 00071 /** 00072 * Message-envelope structure. 00073 * 00074 * Is used to store meta-data about the message in the message-queues of the receiving process. 00075 **/ 00076 typedef struct moc_message_envelope_struct 00077 { 00078 uint8_t id; /**< Message-ID. Also index of message-status-array*/ 00079 uint8_t tag; /**< Message-tag*/ 00080 uint8_t communicator; /**< Communicator of message*/ 00081 union 00082 { 00083 struct 00084 { 00085 unsigned int valid : 1; /**< Is the message valid? */ 00086 unsigned int signal_back : 1; /**< Should the status be reported back to the 00087 sending process */ 00088 unsigned int special : 1; /**< Is this message a special message? */ 00089 unsigned int collaborative : 1; /**< Is this message part of a collaborative 00090 communication? */ 00091 unsigned int channel : 2; /**< Which channel is used to transport the message? */ 00092 unsigned int in_mm : 1; /**< Are the data in Main-Memory? */ 00093 unsigned int keep_valid : 1; /**< Should the message-status-entry be invalidated? */ 00094 } __attribute__((__packed__)) bits; /**< flag-struct */ 00095 uint8_t value; /**< union-value */ 00096 } flags; /**< flag-union */ 00097 unsigned int size : 24; /**< Message-size in byte*/ 00098 unsigned int datatype : 8; /**< Data-type of message-entries */ 00099 uint64_t message_address; /**< Effective address of message-data*/ 00100 } __attribute__((__packed__)) moc_message_envelope_t; 00101 00102 00103 /** 00104 * Constant for moc_message_envelope_t.flags.channel. 00105 * 00106 * Message is transported via a DMA-Call. 00107 **/ 00108 #define IMOC_MESSAGE_CHANNEL_DMA 0 00109 00110 00111 /** 00112 * Constant for moc_message_envelope_t.flags.channel. 00113 * 00114 * Message is embedded in message-envelope. 00115 **/ 00116 #define IMOC_MESSAGE_CHANNEL_ENV 1 00117 00118 00119 /** 00120 * Message-status structure. 00121 * 00122 * Is used to store information about the message-status and the buffer used in the 00123 * message-status-array. 00124 **/ 00125 typedef struct moc_message_status_struct 00126 { 00127 uint32_t buffer_offset; /**< allocated buffer-offset from buffer-base */ 00128 uint32_t message_size; /**< size of message in byte */ 00129 uint32_t error_value; /**< optional error-code of message */ 00130 union 00131 { 00132 struct 00133 { 00134 unsigned int valid : 1; /**< Is this entry valid? */ 00135 unsigned int outstanding : 1; /**< Message is not yet received? */ 00136 unsigned int buffer_used : 1; /**< Is Bufferspace used? */ 00137 unsigned int reserved : 5; /**< reserved */ 00138 } __attribute__((__packed__)) bits; /**< flag-struct */ 00139 uint8_t value; /**< union-value */ 00140 } flags; /**< flag-union */ 00141 uint8_t reserved[3]; /**< reserved */ 00142 } __attribute__((__packed__)) moc_message_status_t; 00143 00144 00145 /** 00146 * Constant for moc_process_struct.type. 00147 **/ 00148 #define MOC_PPU_PROCESS 0 00149 00150 /** 00151 * Constant for moc_process_struct.type. 00152 **/ 00153 #define MOC_SPU_PROCESS 1 00154 00155 00156 /** 00157 * Process-information structure. 00158 * 00159 * Stores information about a MOC-Process. This information is used for communication 00160 * between the processes. 00161 */ 00162 typedef struct moc_process_struct 00163 { 00164 uint8_t type; /**< Process-type (SPU or PPU) */ 00165 uint8_t reserved[7]; /**< reserved */ 00166 uint64_t inbox_queue_base; /**< effective base-address of message-queues */ 00167 uint64_t stat_array_base; /**< effective base-address of message-status-array */ 00168 uint64_t ps_base; /**< effective base-address of problem-state (Signals, mailboxes, ...)*/ 00169 } __attribute__((__packed__)) moc_process_t; 00170 00171 //@} 00172 //@} 00173 #endif /*MOC_INTERNAL_CORE_*/
1.5.6