Link conv-cpm as C++
[charm.git] / src / ck-perf / trace-controlPoints-BGP.C
blobdadb0057d47209382bdf0b08be26928f0936a3b9
1 //#include "conv-mach.h" 
2 #include "converse.h"
4 #include <spi/UPC.h>
5 #include <spi/UPC_Events.h>
6 #include <iostream>
10 /// An initcall that registers the idle time reducer idleTimeReduction()
11 void initBGP_UPC_Counters(void) {
13     // every process on the node calls BGP_UPC_Initialize()
14     BGP_UPC_Initialize();
17     // just one rank per node sets the counter config and zeros the counters
18     
19     // counter_mode = 0, 1, 2, 3 (plus some others … see UPC.h)
20     // counter_trigger = BGP_UPC_CFG_LEVEL_HIGH, BGP_UPC_CFG_EDGE_DEFAULT
21     
22     BGP_UPC_Mode_t counter_mode = BGP_UPC_MODE_2;
23     BGP_UPC_Event_Edge_t counter_trigger = BGP_UPC_CFG_EDGE_DEFAULT;
24     
25     BGP_UPC_Initialize_Counter_Config(counter_mode, counter_trigger);
27     BGP_UPC_Zero_Counter_Values();
28     BGP_UPC_Start(0);
36 /// print out the counters
37 void printBGP_UPC_Counters(void) {
38     
40     BGP_UPC_Stop();
41    
42     CmiMyPe();
44     // Should look at BGP_TORUS_XP_NO_TOKENS to determine if there is contention
45 //    BGP_UPC_Print_Counter_Values(BGP_UPC_READ_EXCLUSIVE);
48 #if 0
49     int64_t cxp = BGP_UPC_Read_Counter_Value(BGP_TORUS_XP_PACKETS, BGP_UPC_READ_EXCLUSIVE);
50     std::cout << "BGP_UPC_Read_Counter_Value returned torus xp = " << cxp << std::endl;
52     int64_t cxm = BGP_UPC_Read_Counter_Value(BGP_TORUS_XM_PACKETS, BGP_UPC_READ_EXCLUSIVE);
53     std::cout << "BGP_UPC_Read_Counter_Value returned torus xm = " << cxm << std::endl;
55     int64_t cyp = BGP_UPC_Read_Counter_Value(BGP_TORUS_YP_PACKETS, BGP_UPC_READ_EXCLUSIVE);
56     std::cout << "BGP_UPC_Read_Counter_Value returned torus yp = " << cyp << std::endl;
58     int64_t cym = BGP_UPC_Read_Counter_Value(BGP_TORUS_YM_PACKETS, BGP_UPC_READ_EXCLUSIVE);
59     std::cout << "BGP_UPC_Read_Counter_Value returned torus ym = " << cym << std::endl;
61     int64_t czp = BGP_UPC_Read_Counter_Value(BGP_TORUS_ZP_PACKETS, BGP_UPC_READ_EXCLUSIVE);
62     std::cout << "BGP_UPC_Read_Counter_Value returned torus zp = " << czp << std::endl;
64     int64_t czm = BGP_UPC_Read_Counter_Value(BGP_TORUS_ZM_PACKETS, BGP_UPC_READ_EXCLUSIVE);
65     std::cout << "BGP_UPC_Read_Counter_Value returned torus zm = " << czm << std::endl;
69     int64_t cxpc = BGP_UPC_Read_Counter_Value(BGP_TORUS_XP_32BCHUNKS, BGP_UPC_READ_EXCLUSIVE);
70     std::cout << "BGP_UPC_Read_Counter_Value returned torus xp chunks = " << cxpc << std::endl;
72     int64_t cxmc = BGP_UPC_Read_Counter_Value(BGP_TORUS_XM_32BCHUNKS, BGP_UPC_READ_EXCLUSIVE);
73     std::cout << "BGP_UPC_Read_Counter_Value returned torus xm chunks = " << cxmc << std::endl;
75     int64_t cypc = BGP_UPC_Read_Counter_Value(BGP_TORUS_YP_32BCHUNKS, BGP_UPC_READ_EXCLUSIVE);
76     std::cout << "BGP_UPC_Read_Counter_Value returned torus yp chunks = " << cypc << std::endl;
78     int64_t cymc = BGP_UPC_Read_Counter_Value(BGP_TORUS_YM_32BCHUNKS, BGP_UPC_READ_EXCLUSIVE);
79     std::cout << "BGP_UPC_Read_Counter_Value returned torus ym chunks = " << cymc << std::endl;
81     int64_t czpc = BGP_UPC_Read_Counter_Value(BGP_TORUS_ZP_32BCHUNKS, BGP_UPC_READ_EXCLUSIVE);
82     std::cout << "BGP_UPC_Read_Counter_Value returned torus zp chunks = " << czpc << std::endl;
84     int64_t czmc = BGP_UPC_Read_Counter_Value(BGP_TORUS_ZM_32BCHUNKS, BGP_UPC_READ_EXCLUSIVE);
85     std::cout << "BGP_UPC_Read_Counter_Value returned torus zm chunks = " << czmc << std::endl;
86 #else
88     int pe = CmiMyPe();
91 std::cout << "[" << pe << "] BGP_TORUS_XP_NO_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_XP_NO_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
92 std::cout << "[" << pe << "] BGP_TORUS_XM_NO_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_XM_NO_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
93 std::cout << "[" << pe << "] BGP_TORUS_YP_NO_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_YP_NO_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
94 std::cout << "[" << pe << "] BGP_TORUS_YM_NO_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_YM_NO_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
95 std::cout << "[" << pe << "] BGP_TORUS_ZP_NO_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_ZP_NO_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
96 std::cout << "[" << pe << "] BGP_TORUS_ZM_NO_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_ZM_NO_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
97 std::cout << "[" << pe << "] BGP_TORUS_XP_NO_VCD0_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_XP_NO_VCD0_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
98 std::cout << "[" << pe << "] BGP_TORUS_XM_NO_VCD0_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_XM_NO_VCD0_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
99 std::cout << "[" << pe << "] BGP_TORUS_YP_NO_VCD0_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_YP_NO_VCD0_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
100 std::cout << "[" << pe << "] BGP_TORUS_YM_NO_VCD0_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_YM_NO_VCD0_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
101 std::cout << "[" << pe << "] BGP_TORUS_ZP_NO_VCD0_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_ZP_NO_VCD0_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
102 std::cout << "[" << pe << "] BGP_TORUS_ZM_NO_VCD0_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_ZM_NO_VCD0_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
103 std::cout << "[" << pe << "] BGP_TORUS_XP_NO_VCBN_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_XP_NO_VCBN_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
104 std::cout << "[" << pe << "] BGP_TORUS_XM_NO_VCBN_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_XM_NO_VCBN_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
105 std::cout << "[" << pe << "] BGP_TORUS_YP_NO_VCBN_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_YP_NO_VCBN_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
106 std::cout << "[" << pe << "] BGP_TORUS_YM_NO_VCBN_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_YM_NO_VCBN_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
107 std::cout << "[" << pe << "] BGP_TORUS_ZP_NO_VCBN_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_ZP_NO_VCBN_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
108 //std::cout << "[" << pe << "] BGP_TORUS_ZM_NO_VCBN_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_ZM_NO_VCBN_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
109 std::cout << "[" << pe << "] BGP_TORUS_XP_NO_VCBP_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_XP_NO_VCBP_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
110 std::cout << "[" << pe << "] BGP_TORUS_XM_NO_VCBP_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_XM_NO_VCBP_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
111 std::cout << "[" << pe << "] BGP_TORUS_YP_NO_VCBP_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_YP_NO_VCBP_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
112 std::cout << "[" << pe << "] BGP_TORUS_YM_NO_VCBP_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_YM_NO_VCBP_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
113 std::cout << "[" << pe << "] BGP_TORUS_ZP_NO_VCBP_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_ZP_NO_VCBP_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
114 //std::cout << "[" << pe << "] BGP_TORUS_ZM_NO_VCBP_TOKENS=" << BGP_UPC_Read_Counter_Value(BGP_TORUS_ZM_NO_VCBP_TOKENS, BGP_UPC_READ_EXCLUSIVE) << "\n";
116 #endif
118     //    Save the counter values from the counter_data structure …
119     BGP_UPC_Start(0);
120