arch/net/machine-ammasso.h

Go to the documentation of this file.
00001 
00020 
00021 // Defines, Types, etc. ////////////////////////////////////////////////////////////////////////////
00022 
00023 #define AMMASSO_PORT        2583
00024 
00025 /* The size of the initial allocated buffers is AMMASSO_BUFSIZE*AMMASSO_INITIAL_BUFFERS
00026    with 8500, the buffers become aligned to 64 bytes (16 bytes per buffer are support) */
00027 #define AMMASSO_BUFSIZE            8488
00028 #define AMMASSO_INITIAL_BUFFERS    1024
00029 #define AMMASSO_BUFFERS_INFLY       128
00030 
00031 /*
00032 #define AMMASSO_CTRLMSG_LEN        7
00033 #define CtrlHeader_Construct(buf, ctrlType)  { *((int*)buf) = Cmi_charmrun_pid;                               \
00034                                                *((short*)((char*)buf + sizeof(int))) = contextBlock->myNode;  \
00035                                                *((char*)buf + sizeof(int) + sizeof(short)) = ctrlType;        \
00036                                              }
00037 
00038 #define CtrlHeader_GetCharmrunPID(buf)   (*((int*)buf))
00039 #define CtrlHeader_GetNode(buf)          (*((short*)((char*)buf + sizeof(int))))
00040 #define CtrlHeader_GetCtrlType(buf)      (*((char*)buf + sizeof(int) + sizeof(short)))
00041 */
00042 
00043 #define ACK_MASK               (1<<31)
00044 
00045 /* ACK_WRAPPING is used when the ACK overflows, rare condition */
00046 #define ACK_WRAPPING           0x01
00047 /* AMMASSO_ALLOCATE is used by the receiving side to allocate more buffers on
00048    the sender. The sender will reply with a AMMASSO_ALLOCATED message,
00049    specifying so where they have been allocated. AMMASSO_MOREBUFFERS is instead
00050    a message sent from the sender to the receiver asking for more buffers. The
00051    receiver can decide to allocate more buffers or just ignore the message. */
00052 #define AMMASSO_ALLOCATE       0x02
00053 #define AMMASSO_ALLOCATED      0x04
00054 #define AMMASSO_MOREBUFFERS    0x08
00055 /* AMMASSO_RELEASE is used by the receiver to ask the sender to release a
00056    certain amount of buffers which are allocated to it. The sender can answer
00057    with an AMMASSO_RELEASED message specifying how many buffers have been
00058    released. The sender can also decide to ignore an AMMASSO_RELEASE message, or
00059    to release some buffers on its own idea. */
00060 #define AMMASSO_RELEASE        0x10
00061 #define AMMASSO_RELEASED       0x20
00062 /* AMMASSO_READY is used at the beginning of the program to synchronize all
00063    processors */
00064 #define AMMASSO_READY          0x40
00065 
00066 typedef struct __cmi_idle_state {
00067   char none;
00068 } CmiIdleState;
00069 
00070 typedef struct __ammasso_private_data {
00071   int node;
00072   cc_stag_t stag;
00073   cc_uint64_t to;
00074   cc_uint64_t ack_to;
00075 } AmmassoPrivateData;
00076 
00077 typedef struct __ammasso_token_description {
00078   cc_stag_t stag;
00079   cc_uint64_t to;
00080 } AmmassoTokenDescription;
00081 
00082 typedef CmiUInt4 ammasso_ack_t;
00083 
00084 /* Structures to deal with the buffering */
00085 typedef struct __ammasso_tailer {
00086   ammasso_ack_t ack;
00087   char flags;
00088   char pad;
00089   CmiUInt2 length;
00090 } PACKED Tailer;
00091 
00092 /* AMMASSO_BUFSIZE should be updated if this structure size is changed */
00093 typedef struct __ammasso_buffer {
00094   char buf[AMMASSO_BUFSIZE];
00095   Tailer tail;
00096   union {
00097     struct {
00098       cc_stag_t stag;
00099       struct __ammasso_buffer *next;
00100     };
00101     char pad[12];
00102   };
00103 } PACKED AmmassoBuffer;
00104 
00105 typedef struct __ammasso_token {
00106   AmmassoBuffer *localBuf;
00107   AmmassoBuffer *remoteBuf;
00108   struct __ammasso_token *next;
00109   cc_sq_wr_t wr;
00110 } AmmassoToken;
00111 
00112 // if "name" is null, then "num_##name"==0 and "last_##name" is not defined
00113 #define LIST_DEFINE(type, name) \
00114     type *name; \
00115     type *last_ ## name; \
00116     int    num_ ## name
00117 
00118 // NOTE: in order to use LIST_*, no space has to be present in the parenthesis
00119 #define LIST_ENQUEUE(prefix, suffix, newtoken) \
00120     prefix num_ ## suffix ++; \
00121     newtoken ->next = NULL; \
00122     if (prefix suffix != NULL) { \
00123       prefix last_ ## suffix ->next = newtoken; \
00124     } else { \
00125       prefix suffix = newtoken; \
00126     } \
00127     prefix last_ ## suffix = newtoken
00128 
00129 #define LIST_DEQUEUE(prefix, suffix, thetoken) \
00130     CmiAssert(prefix num_ ## suffix > 0); \
00131     prefix num_ ## suffix --; \
00132     thetoken = prefix suffix; \
00133     prefix suffix = thetoken ->next
00134 
00135 // DMK : This is copied from "qp_rping.c" in Ammasso's Example Code (modify as needed for our machine layer).
00136 // User Defined Context that will be sent to function handlers for asynchronous events.
00137 typedef struct __context_block {
00138 
00139   cc_rnic_handle_t       rnic;     // The RNIC Handle
00140   cc_eh_ce_handler_id_t  eh_id;    // Event Handler ID
00141   cc_pdid_t              pd_id;    // Protection Domain Handle
00142 
00143   // DMK : TODO : When there is a global buffer pool, the send and recv (or just single) completion queues' handles can go here
00144   //              instead of in the OtherNode structure.  All of the memory buffers will move here also.
00145 
00146   // Extra Useful Info
00147   int                    numNodes;                    // The number of nodes total
00148   int                    myNode;                      // "My" node index for this node
00149   int                    outstandingConnectionCount;  // Synch. variable used to block until all connections to other nodes are made
00150   int                    nodeReadyCount;              // Synch. variable used to block until all other nodes are ready
00151 
00152   // Free Receive Buffer Pool, typically empty when allocated to processors
00153   LIST_DEFINE(AmmassoBuffer,freeRecvBuffers);
00154   //CmiNodeLock bufferPoolLock;
00155   LIST_DEFINE(AmmassoToken,freeTokens);
00156 
00157   int pinnedMemory;
00158   int conditionRegistered;
00159 } mycb_t;
00160 
00161 // Global instance of the mycb_t structure to be used throughout this machine layer
00162 mycb_t *contextBlock = NULL;
00163 
00164 // NOTE: I couldn't find functions similar to these in the CCIL API, if found, use the API ones instead.  They
00165 //   are basically just utility functions.
00166 char* cc_status_to_string(cc_status_t errorCode);
00167 char* cc_conn_error_to_string(cc_connect_status_t errorCode);
00168 void displayQueueQuery(cc_qp_handle_t qp, cc_qp_query_attrs_t *attrs);
00169 char* cc_qp_state_to_string(cc_qp_state_t qpState);
00170 char* cc_event_id_to_string(cc_event_id_t id);
00171 char* cc_connect_status_to_string(cc_connect_status_t status);
00172 
00173 
00174 #define AMMASSO_STATS   0
00175 #if AMMASSO_STATS
00176 
00177 #define AMMASSO_STATS_VARS(event)   double event ## _start;    \
00178                                     double event ## _end;      \
00179                                     double event ## _total;    \
00180                                     long event ## _count;
00181 
00182 typedef struct __ammasso_stats {
00183 
00184   AMMASSO_STATS_VARS(MachineInit)
00185 
00186   AMMASSO_STATS_VARS(AmmassoDoIdle)
00187 
00188   AMMASSO_STATS_VARS(DeliverViaNetwork)
00189   AMMASSO_STATS_VARS(DeliverViaNetwork_pre_lock)
00190   AMMASSO_STATS_VARS(DeliverViaNetwork_lock)
00191   AMMASSO_STATS_VARS(DeliverViaNetwork_post_lock)
00192   AMMASSO_STATS_VARS(DeliverViaNetwork_send)
00193 
00194   AMMASSO_STATS_VARS(getQPSendBuffer)
00195   AMMASSO_STATS_VARS(getQPSendBuffer_lock)
00196   AMMASSO_STATS_VARS(getQPSendBuffer_CEH)
00197   AMMASSO_STATS_VARS(getQPSendBuffer_loop)
00198 
00199   AMMASSO_STATS_VARS(sendDataOnQP)
00200   AMMASSO_STATS_VARS(sendDataOnQP_pre_send)
00201   AMMASSO_STATS_VARS(sendDataOnQP_send)
00202   AMMASSO_STATS_VARS(sendDataOnQP_post_send)
00203 
00204   AMMASSO_STATS_VARS(sendDataOnQP_1024)
00205   AMMASSO_STATS_VARS(sendDataOnQP_2048)
00206   AMMASSO_STATS_VARS(sendDataOnQP_4096)
00207   AMMASSO_STATS_VARS(sendDataOnQP_16384)
00208   AMMASSO_STATS_VARS(sendDataOnQP_over)
00209 
00210   AMMASSO_STATS_VARS(AsynchronousEventHandler)
00211   AMMASSO_STATS_VARS(CompletionEventHandler)
00212   AMMASSO_STATS_VARS(ProcessMessage)
00213   AMMASSO_STATS_VARS(processAmmassoControlMessage)
00214 
00215   AMMASSO_STATS_VARS(sendAck)
00216 
00217   AMMASSO_STATS_VARS(CommunicationServer)
00218 
00219 } AmmassoStats;
00220 
00221 AmmassoStats __stats;
00222 
00223 #define AMMASSO_STATS_INIT_AUX(event)  { __stats.event ## _total = 0.0; __stats.event ## _count = 0; }
00224 #define AMMASSO_STATS_INIT   {                                                  \
00225                                AMMASSO_STATS_INIT_AUX(MachineInit)                  \
00226                                AMMASSO_STATS_INIT_AUX(AmmassoDoIdle)                \
00227                                AMMASSO_STATS_INIT_AUX(DeliverViaNetwork)            \
00228                                AMMASSO_STATS_INIT_AUX(DeliverViaNetwork_pre_lock)   \
00229                                AMMASSO_STATS_INIT_AUX(DeliverViaNetwork_lock)       \
00230                                AMMASSO_STATS_INIT_AUX(DeliverViaNetwork_post_lock)  \
00231                                AMMASSO_STATS_INIT_AUX(DeliverViaNetwork_send)       \
00232                                AMMASSO_STATS_INIT_AUX(getQPSendBuffer)              \
00233                                AMMASSO_STATS_INIT_AUX(getQPSendBuffer_lock)         \
00234                                AMMASSO_STATS_INIT_AUX(getQPSendBuffer_CEH)          \
00235                                AMMASSO_STATS_INIT_AUX(getQPSendBuffer_loop)         \
00236                                AMMASSO_STATS_INIT_AUX(sendDataOnQP)                 \
00237                                AMMASSO_STATS_INIT_AUX(sendDataOnQP_pre_send)        \
00238                                AMMASSO_STATS_INIT_AUX(sendDataOnQP_send)            \
00239                                AMMASSO_STATS_INIT_AUX(sendDataOnQP_post_send)       \
00240                                AMMASSO_STATS_INIT_AUX(sendDataOnQP_1024)            \
00241                                AMMASSO_STATS_INIT_AUX(sendDataOnQP_2048)            \
00242                                AMMASSO_STATS_INIT_AUX(sendDataOnQP_4096)            \
00243                                AMMASSO_STATS_INIT_AUX(sendDataOnQP_16384)           \
00244                                AMMASSO_STATS_INIT_AUX(sendDataOnQP_over)            \
00245                                AMMASSO_STATS_INIT_AUX(AsynchronousEventHandler)     \
00246                                AMMASSO_STATS_INIT_AUX(CompletionEventHandler)       \
00247                                AMMASSO_STATS_INIT_AUX(ProcessMessage)               \
00248                                AMMASSO_STATS_INIT_AUX(processAmmassoControlMessage) \
00249                                AMMASSO_STATS_INIT_AUX(sendAck)                      \
00250                                AMMASSO_STATS_INIT_AUX(CommunicationServer)          \
00251                              }
00252 
00253 #define TO_NS  ((double)1000000000.0)
00254 
00255 #define AMMASSO_STATS_START(event) { __stats.event ## _start = CmiWallTimer();     \
00256                                    }
00257 
00258 #define AMMASSO_STATS_END(event)   { __stats.event ## _end = CmiWallTimer();         \
00259                                      __stats.event ## _count++;                      \
00260                                      __stats.event ## _total += (__stats.event ## _end - __stats.event ## _start);   \
00261                                    }
00262 
00263 #define AMMASSO_STATS_DISPLAY_VERBOSE(event) { char buf[128];                        \
00264                                                CmiPrintf("[%d] Ammasso Stats: event -> " #event "_count = %d\n", CmiMyPe(), __stats.event ## _count);   \
00265                                                CmiPrintf("[%d]                event -> " #event "_total = %.3fns\n", CmiMyPe(), __stats.event ## _total * TO_NS);   \
00266                                                CmiPrintf("[%d]                                                    " #event " average: %.3fns\n", CmiMyPe(), (((double)__stats.event ## _total)/(__stats.event ## _count)) * TO_NS); \
00267                                              }
00268 
00269 #define AMMASSO_STATS_DISPLAY(event) {                                               \
00270                                        CmiPrintf("[%d] " #event " average: %.3fns\n", CmiMyPe(), (((double)__stats.event ## _total)/(__stats.event ## _count)) * TO_NS); \
00271                                      }
00272 
00273 #else
00274 
00275 #define AMMASSO_STATS_INIT_AUX(event)
00276 #define AMMASSO_STATS_INIT
00277 #define AMMASSO_STATS_START(event)
00278 #define AMMASSO_STATS_END(event)
00279 #define AMMASSO_STATS_DISPLAY(event)
00280 
00281 #endif
00282 

Generated on Sun Jun 29 13:29:06 2008 for Charm++ by  doxygen 1.5.1