Skip to content

Commit 3ed1b35

Browse files
authored
Merge pull request #237 from intel-innersource/agorneanu/pcm-raw-fixes-for-edp-proc-offlined-cores
Fix EDP prints for offlined cores
2 parents a4afcec + ea1b3cc commit 3ed1b35

File tree

4 files changed

+41
-6
lines changed

4 files changed

+41
-6
lines changed

.github/workflows/ci-test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,9 @@ jobs:
7575
with:
7676
name: test-log-raw-json-${{ github.sha }}
7777
path: build/bin/raw_json.json
78+
79+
- name: upload-artifact
80+
uses: actions/upload-artifact@v2
81+
with:
82+
name: test-log-raw-edp-offlined-cores-${{ github.sha }}
83+
path: build/bin/raw_edp_offlined_cores.txt

src/cpucounters.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,31 +1383,39 @@ bool PCM::discoverSystemTopology()
13831383

13841384
void PCM::printSystemTopology() const
13851385
{
1386-
if (num_cores == num_online_cores && hybrid == false)
1386+
const bool all_cores_online_no_hybrid = (num_cores == num_online_cores && hybrid == false);
1387+
1388+
if (all_cores_online_no_hybrid)
13871389
{
13881390
std::cerr << "Number of physical cores: " << (num_cores/threads_per_core) << "\n";
13891391
}
13901392

13911393
std::cerr << "Number of logical cores: " << num_cores << "\n";
13921394
std::cerr << "Number of online logical cores: " << num_online_cores << "\n";
13931395

1394-
if (num_cores == num_online_cores && hybrid == false)
1396+
if (all_cores_online_no_hybrid)
13951397
{
13961398
std::cerr << "Threads (logical cores) per physical core: " << threads_per_core << "\n";
13971399
}
13981400
else
13991401
{
1402+
std::cerr << "Threads (logical cores) per physical core: " << threads_per_core << " (maybe imprecise due to core offlining/hybrid CPU)\n";
14001403
std::cerr << "Offlined cores: ";
14011404
for (int i = 0; i < (int)num_cores; ++i)
14021405
if(isCoreOnline((int32)i) == false)
14031406
std::cerr << i << " ";
14041407
std::cerr << "\n";
14051408
}
14061409
std::cerr << "Num sockets: " << num_sockets << "\n";
1407-
if (num_phys_cores_per_socket > 0 && hybrid == false)
1410+
if (all_cores_online_no_hybrid)
14081411
{
14091412
std::cerr << "Physical cores per socket: " << num_phys_cores_per_socket << "\n";
14101413
}
1414+
else
1415+
{
1416+
std::cerr << "Physical cores per socket: " << num_cores / num_sockets / threads_per_core << " (maybe imprecise due to core offlining/hybrid CPU)\n";
1417+
}
1418+
14111419
if (hybrid == false)
14121420
{
14131421
std::cerr << "Last level cache slices per socket: " << getMaxNumOfCBoxes() << "\n";
@@ -2218,10 +2226,11 @@ void PCM::printDetailedSystemTopology()
22182226
std::cerr << "\n===== Processor topology =====\n";
22192227
std::cerr << "OS_Processor Thread_Id Core_Id Tile_Id Package_Id Core_Type Native_CPU_Model\n";
22202228
std::map<uint32, std::vector<uint32> > os_id_by_core, os_id_by_tile, core_id_by_socket;
2229+
size_t counter = 0;
22212230
for (auto it = topology.begin(); it != topology.end(); ++it)
22222231
{
22232232
std::cerr << std::left << std::setfill(' ')
2224-
<< std::setw(16) << it->os_id
2233+
<< std::setw(16) << ((it->os_id >= 0) ? it->os_id : counter)
22252234
<< std::setw(16) << it->thread_id
22262235
<< std::setw(16) << it->core_id
22272236
<< std::setw(16) << it->tile_id
@@ -2235,6 +2244,8 @@ void PCM::printDetailedSystemTopology()
22352244
// add socket offset to distinguish cores and tiles from different sockets
22362245
os_id_by_core[(it->socket << 15) + it->core_id].push_back(it->os_id);
22372246
os_id_by_tile[(it->socket << 15) + it->tile_id].push_back(it->os_id);
2247+
2248+
++counter;
22382249
}
22392250
std::cerr << "===== Placement on packages =====\n";
22402251
std::cerr << "Package Id. Core Id. Processors\n";

src/pcm-raw.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ void printRow(const std::string & EventName, MetricFunc metricFunc, const std::v
10051005

10061006
for (uint32 core = 0; core < m->getNumCores(); ++core)
10071007
{
1008-
if (!(m->isCoreOnline(core) == false || (show_partial_core_output && ycores.test(core) == false)))
1008+
if (!(show_partial_core_output && ycores.test(core) == false))
10091009
{
10101010
if (outputType == Header1) {
10111011
cout << separator << "SKT" << m->getSocketId(core) << "CORE" << core;
@@ -1465,7 +1465,7 @@ void print(const PCM::RawPMUConfigs& curPMUConfigs,
14651465
{
14661466
for (uint32 core = 0; core < m->getNumCores(); ++core)
14671467
{
1468-
if (m->isCoreOnline(core) == false || (show_partial_core_output && ycores.test(core) == false))
1468+
if (show_partial_core_output && ycores.test(core) == false)
14691469
continue;
14701470

14711471
const uint64 fixedCtrValues[] = {

tests/test.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,5 +341,23 @@ if [ "$?" -ne "0" ]; then
341341
exit 1
342342
fi
343343

344+
echo Testing pcm-raw with -edp and offlined cores
345+
346+
online_offline_cores() {
347+
for i in {5..10};
348+
do
349+
echo $1 > /sys/devices/system/cpu/cpu$i/online
350+
done
351+
}
352+
353+
online_offline_cores 0
354+
./pcm-raw -edp -out raw_edp_offlined_cores.txt 0.25 -tr -i=4 -el event_file_test.txt
355+
if [ "$?" -ne "0" ]; then
356+
online_offline_cores 1
357+
echo "Error in pcm-raw with offlined cores"
358+
exit 1
359+
fi
360+
online_offline_cores 1
361+
344362

345363
popd

0 commit comments

Comments
 (0)