Skip to content

Commit 599a460

Browse files
authored
Merge pull request #416 from opcm/push-2022-07-22
Push 2022 07 22
2 parents 0d031d8 + a17df42 commit 599a460

File tree

7 files changed

+63
-11
lines changed

7 files changed

+63
-11
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

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ include(GNUInstallDirs)
1313
set(THREADS_PREFER_PTHREAD_FLAG ON)
1414
find_package(Threads REQUIRED)
1515

16+
# Check for pcm*.x artifacts generated by an old build scenario using Makefiles
17+
file(GLOB_RECURSE PCM_X_ARTIFACTS ${CMAKE_CURRENT_SOURCE_DIR}/*.x)
18+
foreach(file ${PCM_X_ARTIFACTS})
19+
file(REMOVE ${file})
20+
message(STATUS "Removing old artifact from current source directory : ${file}")
21+
endforeach()
22+
if(PCM_X_ARTIFACTS)
23+
message(WARNING
24+
" Old pcm utilities (.x) were indicated in build folder.\n"
25+
" Old binaries are expected to be installed in system.\n"
26+
" Make sure to install the new binaries(run 'cmake --install .') after building.)")
27+
endif()
28+
1629
message(STATUS "System: ${CMAKE_SYSTEM}")
1730
if(UNIX AND NOT APPLE)
1831
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")

scripts/pmu-query.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import urllib.parse
55
import json
66
import csv
7-
import subprocess
7+
# subprocess is used as multiplatform approach, usage is verified (20-07-2022)
8+
import subprocess # nosec
89
import sys
910
import platform
1011
import getopt
@@ -31,7 +32,8 @@
3132
sys.exit(-2)
3233

3334
if filename is None:
34-
map_file_raw = urllib.request.urlopen("https://download.01.org/perfmon/mapfile.csv").read().decode('utf-8')
35+
# vefified that link to mapfile.csv is safe and correct (20-07-2022)
36+
map_file_raw = urllib.request.urlopen("https://download.01.org/perfmon/mapfile.csv").read().decode('utf-8') # nosec
3537
map_dict = csv.DictReader(io.StringIO(map_file_raw), delimiter=',')
3638
map_file = []
3739
core_path = ""
@@ -67,7 +69,8 @@
6769
print(model)
6870

6971
if core_path:
70-
json_core_data = urllib.request.urlopen(
72+
# vefified that links, created on base of map_file are correct (20-07-2022)
73+
json_core_data = urllib.request.urlopen( # nosec
7174
"https://download.01.org/perfmon" + core_path
7275
)
7376
core_events = json.load(json_core_data)
@@ -79,7 +82,8 @@
7982
sys.exit(-1)
8083

8184
if offcore_path:
82-
json_offcore_data = urllib.request.urlopen(
85+
# vefified that links, created on base of map_file are correct (20-07-2022)
86+
json_offcore_data = urllib.request.urlopen( # nosec
8387
"https://download.01.org/perfmon" + offcore_path
8488
)
8589
offcore_events = json.load(json_offcore_data)

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/mmio.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class PCMPmem : public WinPmem {
7171

7272
std::shared_ptr<WinPmem> WinPmemMMIORange::pmem;
7373
Mutex WinPmemMMIORange::mutex;
74-
bool WinPmemMMIORange::writeSupported;
74+
bool WinPmemMMIORange::writeSupported = false;
7575

7676
WinPmemMMIORange::WinPmemMMIORange(uint64 baseAddr_, uint64 /* size_ */, bool readonly_) : startAddr(baseAddr_), readonly(readonly_)
7777
{

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)