Skip to content

Commit

Permalink
Merge pull request #272 from opcm/push_202101
Browse files Browse the repository at this point in the history
Push 202101
  • Loading branch information
opcm authored Feb 2, 2021
2 parents 0a178ec + 290d887 commit 0f5076b
Show file tree
Hide file tree
Showing 35 changed files with 650 additions and 229 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*.htm
*.html
*.dll
*.txt
*.patch
*.orig
*.out
Expand Down
43 changes: 43 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,49 @@ build_linux:gcc5:
- g++ --version
- make -j

build_linux:gcc10:
image: "ubuntu:groovy"
stage: build
before_script:
- apt-get update -qq && apt-get install -qq -y make g++
script:
- g++ --version
- make -j

build_linux:clang_scan:
image: "ubuntu:groovy"
stage: build
before_script:
- apt-get update -qq && apt-get install -qq -y make clang clang-tools perl g++
script:
- scan-build --status-bugs make -j

build_windows:
stage: build
before_script:
- 'call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"'
script:
- 'msbuild pcm-all.sln /p:Configuration=Release;Platform=x64 /t:Clean,Build /m'
tags:
- windows

cppcheck:
image: "ubuntu:groovy"
stage: build
before_script:
- apt-get update -qq && apt-get install -qq -y cppcheck
script:
- sh cppcheck.sh . 28

build_linux:gcc9:
image: "ubuntu:focal"
stage: build
before_script:
- apt-get update -qq && apt-get install -qq -y make g++
script:
- g++ --version
- make -j

build_linux:gcc7:
image: "ubuntu:bionic"
stage: build
Expand Down
2 changes: 2 additions & 0 deletions ENVVAR_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
`PCM_USE_UNCORE_PERF=1` : use Linux perf events API to program *uncore* PMUs (default is *not* to use it)

`PCM_NO_RDT=1` : don't use RDT metrics for a better interoperation with pqos utility (https://github.com/intel/intel-cmt-cat)

`PCM_USE_RESCTRL=1` : use Linux resctrl driver for RDT metrics
14 changes: 6 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ ifeq ($(UNAME), Linux)
EXE += daemon-binaries
endif

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

# uncomment if your Linux kernel supports access to /dev/mem from user space
# CXXFLAGS += -DPCM_USE_PCI_MM_LINUX
Expand Down Expand Up @@ -50,7 +51,7 @@ CXX=c++
LIB= -lpthread -lc++
endif

COMMON_OBJS = msr.o cpucounters.o pci.o mmio.o client_bw.o utils.o topology.o dashboard.o debug.o threadpool.o
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
EXE_OBJS = $(EXE:.x=.o)
OBJS = $(COMMON_OBJS) $(EXE_OBJS)

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

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

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

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

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

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

nice:
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

prefix=/usr

ifneq ($(DESTDIR),)
Expand Down
35 changes: 27 additions & 8 deletions c_example.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#include <stdio.h>
#include <dlfcn.h>
#include <stdint.h>
#include <stdlib.h>

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

struct {
Expand Down Expand Up @@ -38,8 +41,17 @@ uint64_t pcm_c_get_core_event(uint32_t, uint32_t);
int main(int argc, const char *argv[])
{
int i,a[100],b[100],c[100];
uint32_t total = 0;
int lcore_id;

/* Seed for predictable rand() results */
srand(0);
for (i=0; i < 100; ++i) {
a[i] = rand();
b[i] = rand();
c[i] = rand();
}

#ifdef PCM_DYNAMIC_LIB
void * handle = dlopen("libpcm.so", RTLD_LAZY);
if(!handle) {
Expand Down Expand Up @@ -85,12 +97,19 @@ int main(int argc, const char *argv[])
return -2;
}

printf("[c_example] Initializing PCM measurements:\n");
PCM.pcm_c_init();

printf("[c_example] Calling PCM start()\n");
PCM.pcm_c_start();
for(i=0;i<10000;i++)
c[i%100] = 4 * a[i%100] + b[i%100];
c[i%100] = 4 * a[i%100] + b[i%100];
for(i=0;i<100;i++)
total += c[i];
PCM.pcm_c_stop();

printf("[c_example] PCM measurment stopped, compute result %u\n", total);

lcore_id = pcm_getcpu();
printf("C:%lu I:%lu, IPC:%3.2f\n",
PCM.pcm_c_get_cycles(lcore_id),
Expand Down
11 changes: 11 additions & 0 deletions cppcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

cppcheck $1 --force --enable=warning --inline-suppr -iPCM-Service_Win -j $2 2> cppcheck.out

if [ -s cppcheck.out ]
then
cat cppcheck.out
exit 1
fi

echo No issues found

4 changes: 2 additions & 2 deletions cpuasynchcounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class AsynchronCounterState {

friend void * UpdateCounters(void *);

// AsynchronCounterState(const& AsynchronCounterState); //unimplemeted
// const& AsynchronCounterState operator=(const& AsynchronCounterState); //unimplemented
AsynchronCounterState(const AsynchronCounterState &) = delete;
const AsynchronCounterState & operator = (const AsynchronCounterState &) = delete;

public:
AsynchronCounterState()
Expand Down
Loading

0 comments on commit 0f5076b

Please sign in to comment.