@@ -527,6 +527,8 @@ bool PCM::detectModel()
527
527
528
528
pcm_cpuid (7 , 0 , cpuinfo);
529
529
530
+ std::cerr << " \n ===== Processor information =====\n " ;
531
+
530
532
#ifdef __linux__
531
533
auto checkLinuxCpuinfoFlag = [](const std::string& flag) -> bool
532
534
{
@@ -1279,69 +1281,6 @@ bool PCM::discoverSystemTopology()
1279
1281
1280
1282
#endif // end of ifdef _MSC_VER
1281
1283
1282
- // produce debug output similar to Intel MPI cpuinfo
1283
- #ifndef PCM_DEBUG_TOPOLOGY
1284
- if (safe_getenv (" PCM_PRINT_TOPOLOGY" ) == " 1" )
1285
- #endif
1286
- {
1287
- std::cerr << " ===== Processor identification =====\n " ;
1288
- std::cerr << " Processor Thread Id. Core Id. Tile Id. Package Id. Core Type. Native CPU Model.\n " ;
1289
- std::map<uint32, std::vector<uint32> > os_id_by_core, os_id_by_tile, core_id_by_socket;
1290
- for (auto it = topology.begin (); it != topology.end (); ++it)
1291
- {
1292
- std::cerr << std::left << std::setfill (' ' )
1293
- << std::setw (16 ) << it->os_id
1294
- << std::setw (16 ) << it->thread_id
1295
- << std::setw (16 ) << it->core_id
1296
- << std::setw (16 ) << it->tile_id
1297
- << std::setw (16 ) << it->socket
1298
- << std::setw (16 ) << it->getCoreTypeStr ()
1299
- << std::setw (16 ) << it->native_cpu_model
1300
- << " \n " ;
1301
- if (std::find (core_id_by_socket[it->socket ].begin (), core_id_by_socket[it->socket ].end (), it->core_id )
1302
- == core_id_by_socket[it->socket ].end ())
1303
- core_id_by_socket[it->socket ].push_back (it->core_id );
1304
- // add socket offset to distinguish cores and tiles from different sockets
1305
- os_id_by_core[(it->socket << 15 ) + it->core_id ].push_back (it->os_id );
1306
- os_id_by_tile[(it->socket << 15 ) + it->tile_id ].push_back (it->os_id );
1307
- }
1308
- std::cerr << " ===== Placement on packages =====\n " ;
1309
- std::cerr << " Package Id. Core Id. Processors\n " ;
1310
- for (auto pkg = core_id_by_socket.begin (); pkg != core_id_by_socket.end (); ++pkg)
1311
- {
1312
- auto core_id = pkg->second .begin ();
1313
- std::cerr << std::left << std::setfill (' ' ) << std::setw (15 ) << pkg->first << *core_id;
1314
- for (++core_id; core_id != pkg->second .end (); ++core_id)
1315
- {
1316
- std::cerr << " ," << *core_id;
1317
- }
1318
- std::cerr << " \n " ;
1319
- }
1320
- std::cerr << " \n ===== Core/Tile sharing =====\n " ;
1321
- std::cerr << " Level Processors\n Core " ;
1322
- for (auto core = os_id_by_core.begin (); core != os_id_by_core.end (); ++core)
1323
- {
1324
- auto os_id = core->second .begin ();
1325
- std::cerr << " (" << *os_id;
1326
- for (++os_id; os_id != core->second .end (); ++os_id) {
1327
- std::cerr << " ," << *os_id;
1328
- }
1329
- std::cerr << " )" ;
1330
- }
1331
- std::cerr << " \n Tile / L2$ " ;
1332
- for (auto core = os_id_by_tile.begin (); core != os_id_by_tile.end (); ++core)
1333
- {
1334
- auto os_id = core->second .begin ();
1335
- std::cerr << " (" << *os_id;
1336
- for (++os_id; os_id != core->second .end (); ++os_id) {
1337
- std::cerr << " ," << *os_id;
1338
- }
1339
- std::cerr << " )" ;
1340
- }
1341
- std::cerr << " \n " ;
1342
- std::cerr << " \n " ;
1343
- }
1344
-
1345
1284
if (num_cores == 0 ) {
1346
1285
num_cores = (int32)topology.size ();
1347
1286
}
@@ -2091,6 +2030,10 @@ class CoreTaskQueue
2091
2030
}
2092
2031
};
2093
2032
2033
+ std::ofstream* PCM::outfile = nullptr ; // output file stream
2034
+ std::streambuf* PCM::backup_ofile = nullptr ; // backup of original output = cout
2035
+ std::streambuf* PCM::backup_ofile_cerr = nullptr ; // backup of original output = cerr
2036
+
2094
2037
PCM::PCM () :
2095
2038
cpu_family (-1 ),
2096
2039
cpu_model (-1 ),
@@ -2145,8 +2088,6 @@ PCM::PCM() :
2145
2088
forceRTMAbortMode (false ),
2146
2089
mode(INVALID_MODE),
2147
2090
canUsePerf(false ),
2148
- outfile(NULL ),
2149
- backup_ofile(NULL ),
2150
2091
run_state(1 ),
2151
2092
needToRestoreNMIWatchdog(false )
2152
2093
{
@@ -2182,8 +2123,19 @@ PCM::PCM() :
2182
2123
2183
2124
showSpecControlMSRs ();
2184
2125
2126
+ #ifndef PCM_DEBUG_TOPOLOGY
2127
+ if (safe_getenv (" PCM_PRINT_TOPOLOGY" ) == " 1" )
2128
+ #endif
2129
+ {
2130
+ printDetailedSystemTopology ();
2131
+ }
2132
+
2185
2133
initEnergyMonitoring ();
2186
2134
2135
+ #ifndef PCM_SILENT
2136
+ std::cerr << " \n " ;
2137
+ #endif
2138
+
2187
2139
initUncoreObjects ();
2188
2140
2189
2141
initRDT ();
@@ -2200,6 +2152,74 @@ PCM::PCM() :
2200
2152
{
2201
2153
coreTaskQueues.push_back (std::make_shared<CoreTaskQueue>(i));
2202
2154
}
2155
+
2156
+ #ifndef PCM_SILENT
2157
+ std::cerr << " \n " ;
2158
+ #endif
2159
+ }
2160
+
2161
+ void PCM::printDetailedSystemTopology ()
2162
+ {
2163
+ // produce debug output similar to Intel MPI cpuinfo
2164
+ if (true )
2165
+ {
2166
+ std::cerr << " \n ===== Processor topology =====\n " ;
2167
+ std::cerr << " OS_Processor Thread_Id Core_Id Tile_Id Package_Id Core_Type Native_CPU_Model\n " ;
2168
+ std::map<uint32, std::vector<uint32> > os_id_by_core, os_id_by_tile, core_id_by_socket;
2169
+ for (auto it = topology.begin (); it != topology.end (); ++it)
2170
+ {
2171
+ std::cerr << std::left << std::setfill (' ' )
2172
+ << std::setw (16 ) << it->os_id
2173
+ << std::setw (16 ) << it->thread_id
2174
+ << std::setw (16 ) << it->core_id
2175
+ << std::setw (16 ) << it->tile_id
2176
+ << std::setw (16 ) << it->socket
2177
+ << std::setw (16 ) << it->getCoreTypeStr ()
2178
+ << std::setw (16 ) << it->native_cpu_model
2179
+ << " \n " ;
2180
+ if (std::find (core_id_by_socket[it->socket ].begin (), core_id_by_socket[it->socket ].end (), it->core_id )
2181
+ == core_id_by_socket[it->socket ].end ())
2182
+ core_id_by_socket[it->socket ].push_back (it->core_id );
2183
+ // add socket offset to distinguish cores and tiles from different sockets
2184
+ os_id_by_core[(it->socket << 15 ) + it->core_id ].push_back (it->os_id );
2185
+ os_id_by_tile[(it->socket << 15 ) + it->tile_id ].push_back (it->os_id );
2186
+ }
2187
+ std::cerr << " ===== Placement on packages =====\n " ;
2188
+ std::cerr << " Package Id. Core Id. Processors\n " ;
2189
+ for (auto pkg = core_id_by_socket.begin (); pkg != core_id_by_socket.end (); ++pkg)
2190
+ {
2191
+ auto core_id = pkg->second .begin ();
2192
+ std::cerr << std::left << std::setfill (' ' ) << std::setw (15 ) << pkg->first << *core_id;
2193
+ for (++core_id; core_id != pkg->second .end (); ++core_id)
2194
+ {
2195
+ std::cerr << " ," << *core_id;
2196
+ }
2197
+ std::cerr << " \n " ;
2198
+ }
2199
+ std::cerr << " \n ===== Core/Tile sharing =====\n " ;
2200
+ std::cerr << " Level Processors\n Core " ;
2201
+ for (auto core = os_id_by_core.begin (); core != os_id_by_core.end (); ++core)
2202
+ {
2203
+ auto os_id = core->second .begin ();
2204
+ std::cerr << " (" << *os_id;
2205
+ for (++os_id; os_id != core->second .end (); ++os_id) {
2206
+ std::cerr << " ," << *os_id;
2207
+ }
2208
+ std::cerr << " )" ;
2209
+ }
2210
+ std::cerr << " \n Tile / L2$ " ;
2211
+ for (auto core = os_id_by_tile.begin (); core != os_id_by_tile.end (); ++core)
2212
+ {
2213
+ auto os_id = core->second .begin ();
2214
+ std::cerr << " (" << *os_id;
2215
+ for (++os_id; os_id != core->second .end (); ++os_id) {
2216
+ std::cerr << " ," << *os_id;
2217
+ }
2218
+ std::cerr << " )" ;
2219
+ }
2220
+ std::cerr << " \n " ;
2221
+ std::cerr << " \n " ;
2222
+ }
2203
2223
}
2204
2224
2205
2225
void PCM::enableJKTWorkaround (bool enable)
@@ -3855,11 +3875,16 @@ void PCM::cleanupRDT(const bool silent)
3855
3875
if (!silent) std::cerr << " Freeing up all RMIDs\n " ;
3856
3876
}
3857
3877
3858
- void PCM::setOutput (const std::string filename)
3878
+ void PCM::setOutput (const std::string filename, const bool cerrToo )
3859
3879
{
3860
3880
outfile = new std::ofstream (filename.c_str ());
3861
3881
backup_ofile = std::cout.rdbuf ();
3862
3882
std::cout.rdbuf (outfile->rdbuf ());
3883
+ if (cerrToo)
3884
+ {
3885
+ backup_ofile_cerr = std::cerr.rdbuf ();
3886
+ std::cerr.rdbuf (outfile->rdbuf ());
3887
+ }
3863
3888
}
3864
3889
3865
3890
void PCM::restoreOutput ()
@@ -3868,6 +3893,9 @@ void PCM::restoreOutput()
3868
3893
if (backup_ofile)
3869
3894
std::cout.rdbuf (backup_ofile);
3870
3895
3896
+ if (backup_ofile_cerr)
3897
+ std::cerr.rdbuf (backup_ofile_cerr);
3898
+
3871
3899
// close output file
3872
3900
if (outfile)
3873
3901
outfile->close ();
0 commit comments