00001 #ifndef _STATS_H 00002 #define _STATS_H 00003 00004 class Stats { 00005 private: 00006 UInt pe; 00007 UInt charesCreated; // # of new chare msgs sent 00008 UInt charesProcessed; // # of new chare msgs processed 00009 UInt forCharesCreated; // # of for chare msgs created 00010 UInt forCharesProcessed; // # of for chare msgs processed 00011 UInt groupInitsCreated; // # of group init msgs created 00012 UInt groupInitsProcessed; // # of groupinits processed 00013 UInt groupMsgsCreated; // # of for group msgs created 00014 UInt groupMsgsProcessed; // # of for group msgs processed 00015 UInt nodeGroupInitsCreated; // # of node group init msgs created 00016 UInt nodeGroupInitsProcessed; // # of node group inits processed 00017 UInt nodeGroupMsgsCreated; // # of for nodegroup msgs created 00018 UInt nodeGroupMsgsProcessed; // # of for nodegroup msgs processed 00019 public: 00020 void *operator new(size_t size) { return _allocMsg(StatMsg, size); } 00021 void operator delete(void *ptr) { CkFreeMsg(ptr); } 00022 Stats() { 00023 pe = CkMyPe(); 00024 charesCreated = 0; 00025 charesProcessed = 0; 00026 forCharesCreated = 0; 00027 forCharesProcessed = 0; 00028 groupInitsCreated = 0; 00029 groupInitsProcessed = 0; 00030 groupMsgsCreated = 0; 00031 groupMsgsProcessed = 0; 00032 nodeGroupInitsCreated = 0; 00033 nodeGroupInitsProcessed = 0; 00034 nodeGroupMsgsCreated = 0; 00035 nodeGroupMsgsProcessed = 0; 00036 } 00037 void combine(const Stats* const other) { 00038 charesCreated += other->charesCreated; 00039 charesProcessed += other->charesProcessed; 00040 forCharesCreated += other->forCharesCreated; 00041 forCharesProcessed += other->forCharesProcessed; 00042 groupInitsCreated += other->groupInitsCreated; 00043 groupInitsProcessed += other->groupInitsProcessed; 00044 groupMsgsCreated += other->groupMsgsCreated; 00045 groupMsgsProcessed += other->groupMsgsProcessed; 00046 nodeGroupInitsCreated += other->nodeGroupInitsCreated; 00047 nodeGroupInitsProcessed += other->nodeGroupInitsProcessed; 00048 nodeGroupMsgsCreated += other->nodeGroupMsgsCreated; 00049 nodeGroupMsgsProcessed += other->nodeGroupMsgsProcessed; 00050 } 00051 void recordCreateChare(int x=1) { charesCreated += x; } 00052 void recordProcessChare(int x=1) { charesProcessed += x; } 00053 void recordSendMsg(int x=1) { forCharesCreated += x; } 00054 void recordProcessMsg(int x=1) { forCharesProcessed += x; } 00055 void recordCreateGroup(int x=1) { groupInitsCreated += x; } 00056 void recordProcessGroup(int x=1) { groupInitsProcessed += x; } 00057 void recordSendBranch(int x=1) { groupMsgsCreated += x; } 00058 void recordProcessBranch(int x=1) { groupMsgsProcessed += x; } 00059 void recordCreateNodeGroup(int x=1) { nodeGroupInitsCreated += x; } 00060 void recordProcessNodeGroup(int x=1) { nodeGroupInitsProcessed += x; } 00061 void recordSendNodeBranch(int x=1) { nodeGroupMsgsCreated += x; } 00062 void recordProcessNodeBranch(int x=1) { nodeGroupMsgsProcessed += x; } 00063 UInt getPe(void) const { return pe; } 00064 UInt getCharesCreated(void) const { return charesCreated; } 00065 UInt getCharesProcessed(void) const { return charesProcessed; } 00066 UInt getForCharesCreated(void) const { return forCharesCreated; } 00067 UInt getForCharesProcessed(void) const { return forCharesProcessed; } 00068 UInt getGroupsCreated(void) const { return groupInitsCreated; } 00069 UInt getGroupsProcessed(void) const { return groupInitsProcessed; } 00070 UInt getGroupMsgsCreated(void) const { return groupMsgsCreated; } 00071 UInt getGroupMsgsProcessed(void) const { return groupMsgsProcessed; } 00072 UInt getNodeGroupsCreated(void) const { return nodeGroupInitsCreated; } 00073 UInt getNodeGroupsProcessed(void) const { return nodeGroupInitsProcessed; } 00074 UInt getNodeGroupMsgsCreated(void) const { return nodeGroupMsgsCreated; } 00075 UInt getNodeGroupMsgsProcessed(void) const {return nodeGroupMsgsProcessed;} 00076 }; 00077 00078 CkpvExtern(Stats*, _myStats); 00079 00080 #if CMK_WITH_STATS 00081 #define _STATS_RECORD_CREATE_CHARE_1() \ 00082 CkpvAccess(_myStats)->recordCreateChare() 00083 #define _STATS_RECORD_CREATE_CHARE_N(x) \ 00084 CkpvAccess(_myStats)->recordCreateChare(x) 00085 #define _STATS_RECORD_PROCESS_CHARE_1() \ 00086 CkpvAccess(_myStats)->recordProcessChare() 00087 #define _STATS_RECORD_PROCESS_CHARE_N(x) \ 00088 CkpvAccess(_myStats)->recordProcessChare(x) 00089 #define _STATS_RECORD_SEND_MSG_1() \ 00090 CkpvAccess(_myStats)->recordSendMsg() 00091 #define _STATS_RECORD_SEND_MSG_N(x) \ 00092 CkpvAccess(_myStats)->recordSendMsg(x) 00093 #define _STATS_RECORD_PROCESS_MSG_1() \ 00094 CkpvAccess(_myStats)->recordProcessMsg() 00095 #define _STATS_RECORD_PROCESS_MSG_N(x) \ 00096 CkpvAccess(_myStats)->recordProcessMsg(x) 00097 #define _STATS_RECORD_CREATE_GROUP_1() \ 00098 CkpvAccess(_myStats)->recordCreateGroup() 00099 #define _STATS_RECORD_CREATE_GROUP_N(x) \ 00100 CkpvAccess(_myStats)->recordCreateGroup(x) 00101 #define _STATS_RECORD_PROCESS_GROUP_1() \ 00102 CkpvAccess(_myStats)->recordProcessGroup() 00103 #define _STATS_RECORD_PROCESS_GROUP_N(x) \ 00104 CkpvAccess(_myStats)->recordProcessGroup(x) 00105 #define _STATS_RECORD_SEND_BRANCH_1() \ 00106 CkpvAccess(_myStats)->recordSendBranch() 00107 #define _STATS_RECORD_SEND_BRANCH_N(x) \ 00108 CkpvAccess(_myStats)->recordSendBranch(x) 00109 #define _STATS_RECORD_PROCESS_BRANCH_1() \ 00110 CkpvAccess(_myStats)->recordProcessBranch() 00111 #define _STATS_RECORD_PROCESS_BRANCH_N(x) \ 00112 CkpvAccess(_myStats)->recordProcessBranch(x) 00113 #define _STATS_RECORD_CREATE_NODE_GROUP_1() \ 00114 CkpvAccess(_myStats)->recordCreateNodeGroup() 00115 #define _STATS_RECORD_CREATE_NODE_GROUP_N(x) \ 00116 CkpvAccess(_myStats)->recordCreateNodeGroup(x) 00117 #define _STATS_RECORD_PROCESS_NODE_GROUP_1() \ 00118 CkpvAccess(_myStats)->recordProcessNodeGroup() 00119 #define _STATS_RECORD_PROCESS_NODE_GROUP_N(x) \ 00120 CkpvAccess(_myStats)->recordProcessNodeGroup(x) 00121 #define _STATS_RECORD_SEND_NODE_BRANCH_1() \ 00122 CkpvAccess(_myStats)->recordSendNodeBranch() 00123 #define _STATS_RECORD_SEND_NODE_BRANCH_N(x) \ 00124 CkpvAccess(_myStats)->recordSendNodeBranch(x) 00125 #define _STATS_RECORD_PROCESS_NODE_BRANCH_1() \ 00126 CkpvAccess(_myStats)->recordProcessNodeBranch() 00127 #define _STATS_RECORD_PROCESS_NODE_BRANCH_N(x) \ 00128 CkpvAccess(_myStats)->recordProcessNodeBranch(x) 00129 #else 00130 #define _STATS_RECORD_CREATE_CHARE_1() do{}while(0) 00131 #define _STATS_RECORD_CREATE_CHARE_N(x) do{}while(0) 00132 #define _STATS_RECORD_PROCESS_CHARE_1() do{}while(0) 00133 #define _STATS_RECORD_PROCESS_CHARE_N(x) do{}while(0) 00134 #define _STATS_RECORD_SEND_MSG_1() do{}while(0) 00135 #define _STATS_RECORD_SEND_MSG_N(x) do{}while(0) 00136 #define _STATS_RECORD_PROCESS_MSG_1() do{}while(0) 00137 #define _STATS_RECORD_PROCESS_MSG_N(x) do{}while(0) 00138 #define _STATS_RECORD_CREATE_GROUP_1() do{}while(0) 00139 #define _STATS_RECORD_CREATE_GROUP_N(x) do{}while(0) 00140 #define _STATS_RECORD_PROCESS_GROUP_1() do{}while(0) 00141 #define _STATS_RECORD_PROCESS_GROUP_N(x) do{}while(0) 00142 #define _STATS_RECORD_SEND_BRANCH_1() do{}while(0) 00143 #define _STATS_RECORD_SEND_BRANCH_N(x) do{}while(0) 00144 #define _STATS_RECORD_PROCESS_BRANCH_1() do{}while(0) 00145 #define _STATS_RECORD_PROCESS_BRANCH_N(x) do{}while(0) 00146 #define _STATS_RECORD_CREATE_NODE_GROUP_1() do{}while(0) 00147 #define _STATS_RECORD_CREATE_NODE_GROUP_N(x) do{}while(0) 00148 #define _STATS_RECORD_PROCESS_NODE_GROUP_1() do{}while(0) 00149 #define _STATS_RECORD_PROCESS_NODE_GROUP_N(x) do{}while(0) 00150 #define _STATS_RECORD_SEND_NODE_BRANCH_1() do{}while(0) 00151 #define _STATS_RECORD_SEND_NODE_BRANCH_N(x) do{}while(0) 00152 #define _STATS_RECORD_PROCESS_NODE_BRANCH_1() do{}while(0) 00153 #define _STATS_RECORD_PROCESS_NODE_BRANCH_N(x) do{}while(0) 00154 #endif 00155 #endif