Skip to content

Commit 0f5076b

Browse files
authored
Merge pull request #272 from opcm/push_202101
Push 202101
2 parents 0a178ec + 290d887 commit 0f5076b

35 files changed

+650
-229
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
*.htm
1010
*.html
1111
*.dll
12-
*.txt
1312
*.patch
1413
*.orig
1514
*.out

.gitlab-ci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,49 @@ build_linux:gcc5:
1717
- g++ --version
1818
- make -j
1919

20+
build_linux:gcc10:
21+
image: "ubuntu:groovy"
22+
stage: build
23+
before_script:
24+
- apt-get update -qq && apt-get install -qq -y make g++
25+
script:
26+
- g++ --version
27+
- make -j
28+
29+
build_linux:clang_scan:
30+
image: "ubuntu:groovy"
31+
stage: build
32+
before_script:
33+
- apt-get update -qq && apt-get install -qq -y make clang clang-tools perl g++
34+
script:
35+
- scan-build --status-bugs make -j
36+
37+
build_windows:
38+
stage: build
39+
before_script:
40+
- 'call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"'
41+
script:
42+
- 'msbuild pcm-all.sln /p:Configuration=Release;Platform=x64 /t:Clean,Build /m'
43+
tags:
44+
- windows
45+
46+
cppcheck:
47+
image: "ubuntu:groovy"
48+
stage: build
49+
before_script:
50+
- apt-get update -qq && apt-get install -qq -y cppcheck
51+
script:
52+
- sh cppcheck.sh . 28
53+
54+
build_linux:gcc9:
55+
image: "ubuntu:focal"
56+
stage: build
57+
before_script:
58+
- apt-get update -qq && apt-get install -qq -y make g++
59+
script:
60+
- g++ --version
61+
- make -j
62+
2063
build_linux:gcc7:
2164
image: "ubuntu:bionic"
2265
stage: build

ENVVAR_README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
`PCM_USE_UNCORE_PERF=1` : use Linux perf events API to program *uncore* PMUs (default is *not* to use it)
44

55
`PCM_NO_RDT=1` : don't use RDT metrics for a better interoperation with pqos utility (https://github.com/intel/intel-cmt-cat)
6+
7+
`PCM_USE_RESCTRL=1` : use Linux resctrl driver for RDT metrics

Makefile

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ ifeq ($(UNAME), Linux)
1818
EXE += daemon-binaries
1919
endif
2020

21-
CXXFLAGS += -Wall -g -O3 -Wno-unknown-pragmas -std=c++11 -fPIC
21+
CFLAGS += -Wall -g -O3 -Wno-unknown-pragmas -fPIC
22+
CXXFLAGS += $(CFLAGS) -std=c++11
2223

2324
# uncomment if your Linux kernel supports access to /dev/mem from user space
2425
# CXXFLAGS += -DPCM_USE_PCI_MM_LINUX
@@ -50,7 +51,7 @@ CXX=c++
5051
LIB= -lpthread -lc++
5152
endif
5253

53-
COMMON_OBJS = msr.o cpucounters.o pci.o mmio.o client_bw.o utils.o topology.o dashboard.o debug.o threadpool.o
54+
COMMON_OBJS = msr.o cpucounters.o pci.o mmio.o client_bw.o utils.o topology.o dashboard.o debug.o threadpool.o resctrl.o
5455
EXE_OBJS = $(EXE:.x=.o)
5556
OBJS = $(COMMON_OBJS) $(EXE_OBJS)
5657

@@ -83,10 +84,10 @@ libpcm.so: $(COMMON_OBJS) pcm-core.o
8384
$(CXX) $(LDFLAGS) $(CXXFLAGS) -DPCM_SILENT -shared $^ $(LIB) -o $@
8485

8586
c_example.x: c_example.c libpcm.so
86-
$(CC) -DPCM_DYNAMIC_LIB $< -ldl -Wl,-rpath,$(shell pwd) -o $@
87+
$(CC) $(CFLAGS) -DPCM_DYNAMIC_LIB $< -ldl -Wl,-rpath,$(shell pwd) -o $@
8788

8889
c_example_shlib.x: c_example.c libpcm.so
89-
$(CC) $< -L./ -Wl,-rpath,$(shell pwd) -lpcm -o $@
90+
$(CC) $(CFLAGS) $< -L./ -Wl,-rpath,$(shell pwd) -lpcm -o $@
9091

9192
%.o: %.cpp
9293
$(CXX) $(CXXFLAGS) -c $*.cpp -o $*.o
@@ -106,14 +107,11 @@ c_example_shlib.x: c_example.c libpcm.so
106107
@rm -f $*.d.tmp
107108

108109
memoptest.x: memoptest.cpp
109-
g++ -Wall -g -O0 -std=c++11 memoptest.cpp -o memoptest.x
110+
$(CXX) -Wall -g -O0 -std=c++11 memoptest.cpp -o memoptest.x
110111

111112
dashboardtest.x: dashboardtest.cpp $(COMMON_OBJS)
112113
$(CXX) -o $@ $^ $(LIB)
113114

114-
nice:
115-
uncrustify --replace -c ~/uncrustify.cfg *.cpp *.h WinMSRDriver/Win7/*.h WinMSRDriver/Win7/*.c WinMSRDriver/WinXP/*.h WinMSRDriver/WinXP/*.c PCM_Win/*.h PCM_Win/*.cpp
116-
117115
prefix=/usr
118116

119117
ifneq ($(DESTDIR),)

c_example.c

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
#include <stdio.h>
22
#include <dlfcn.h>
33
#include <stdint.h>
4+
#include <stdlib.h>
45

56
int pcm_getcpu()
67
{
7-
int id = -1;
8-
asm volatile (
9-
"rdtscp\n\t"
10-
"mov %%ecx, %0\n\t":
11-
"=r" (id) :: "%rax", "%rcx", "%rdx");
12-
// processor ID is in ECX: https://www.felixcloutier.com/x86/rdtscp
13-
return id;
8+
int id = -1;
9+
asm volatile (
10+
"rdtscp\n\t"
11+
"mov %%ecx, %0\n\t":
12+
"=r" (id) :: "%rax", "%rcx", "%rdx");
13+
// processor ID is in ECX: https://www.felixcloutier.com/x86/rdtscp
14+
// Linux encodes the NUMA node starting at bit 12, so remove the NUMA
15+
// bits when returning the CPU integer by masking with 0xFFF.
16+
return id & 0xFFF;
1417
}
1518

1619
struct {
@@ -38,8 +41,17 @@ uint64_t pcm_c_get_core_event(uint32_t, uint32_t);
3841
int main(int argc, const char *argv[])
3942
{
4043
int i,a[100],b[100],c[100];
44+
uint32_t total = 0;
4145
int lcore_id;
4246

47+
/* Seed for predictable rand() results */
48+
srand(0);
49+
for (i=0; i < 100; ++i) {
50+
a[i] = rand();
51+
b[i] = rand();
52+
c[i] = rand();
53+
}
54+
4355
#ifdef PCM_DYNAMIC_LIB
4456
void * handle = dlopen("libpcm.so", RTLD_LAZY);
4557
if(!handle) {
@@ -85,12 +97,19 @@ int main(int argc, const char *argv[])
8597
return -2;
8698
}
8799

100+
printf("[c_example] Initializing PCM measurements:\n");
88101
PCM.pcm_c_init();
102+
103+
printf("[c_example] Calling PCM start()\n");
89104
PCM.pcm_c_start();
90105
for(i=0;i<10000;i++)
91-
c[i%100] = 4 * a[i%100] + b[i%100];
106+
c[i%100] = 4 * a[i%100] + b[i%100];
107+
for(i=0;i<100;i++)
108+
total += c[i];
92109
PCM.pcm_c_stop();
93110

111+
printf("[c_example] PCM measurment stopped, compute result %u\n", total);
112+
94113
lcore_id = pcm_getcpu();
95114
printf("C:%lu I:%lu, IPC:%3.2f\n",
96115
PCM.pcm_c_get_cycles(lcore_id),

cppcheck.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
cppcheck $1 --force --enable=warning --inline-suppr -iPCM-Service_Win -j $2 2> cppcheck.out
3+
4+
if [ -s cppcheck.out ]
5+
then
6+
cat cppcheck.out
7+
exit 1
8+
fi
9+
10+
echo No issues found
11+

cpuasynchcounter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ class AsynchronCounterState {
4545

4646
friend void * UpdateCounters(void *);
4747

48-
// AsynchronCounterState(const& AsynchronCounterState); //unimplemeted
49-
// const& AsynchronCounterState operator=(const& AsynchronCounterState); //unimplemented
48+
AsynchronCounterState(const AsynchronCounterState &) = delete;
49+
const AsynchronCounterState & operator = (const AsynchronCounterState &) = delete;
5050

5151
public:
5252
AsynchronCounterState()

0 commit comments

Comments
 (0)