Skip to content

Commit 5e92c50

Browse files
authored
Merge pull request #370 from opcm/opcm-push-2022-02-28
Opcm push 2022 02 28
2 parents c66ab78 + dbca762 commit 5e92c50

31 files changed

+1633
-693
lines changed

.bdsignore.all

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.bdsignore.all
22
Makefile
3-
license.txt
43
Doxyfile
54
LICENSE
65
README

.github/workflows/ci-cpack.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: CPack check
2+
3+
on:
4+
push:
5+
branches: [ '**' ]
6+
pull_request:
7+
branches: [ '**' ]
8+
9+
jobs:
10+
job-build1:
11+
runs-on: ci-gcc9
12+
if: ${{ github.repository != 'opcm/pcm' }}
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Preparation
17+
run: |
18+
cd ${{ github.workspace }}/src
19+
git clone https://github.com/simdjson/simdjson.git
20+
cd ..
21+
- name: Configure CMake
22+
run: |
23+
cmake --version
24+
rm -rf ${{ github.workspace }}/build
25+
cmake -B ${{ github.workspace }}/build -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/build
26+
- name: Build and Install
27+
run: |
28+
g++ --version
29+
cd ${{ github.workspace }}/build
30+
make -j$(nproc)
31+
- name: CPack
32+
run: |
33+
cd ${{ github.workspace }}/build
34+
cpack
35+
36+
job-build2:
37+
runs-on: ci-test
38+
if: ${{ github.repository != 'opcm/pcm' }}
39+
40+
steps:
41+
- uses: actions/checkout@v2
42+
- name: Preparation
43+
run: |
44+
cd ${{ github.workspace }}/src
45+
git clone https://github.com/simdjson/simdjson.git
46+
cd ..
47+
- name: Configure CMake
48+
run: |
49+
cmake --version
50+
rm -rf ${{ github.workspace }}/build
51+
cmake -B ${{ github.workspace }}/build -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/build
52+
- name: Build and Install
53+
run: |
54+
g++ --version
55+
cd ${{ github.workspace }}/build
56+
make -j$(nproc)
57+
- name: CPack
58+
run: |
59+
cd ${{ github.workspace }}/build
60+
cpack

.github/workflows/ci-kw-linux-report.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ jobs:
1212
- uses: actions/checkout@v2
1313
- name: kw
1414
run: |
15+
cd src
1516
git clone https://github.com/simdjson/simdjson.git
16-
ci-kw-linux.sh "echo No Preparation for make" "make -j"
17+
cd ..
18+
mkdir build
19+
cd build
20+
cmake ..
21+
ci-kw-linux.sh "echo No Preparation" "make -j"
1722
1823
- name: kw-report
1924
run: |

.github/workflows/ci-kw-windows-report.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ jobs:
1616

1717
- name: kw
1818
run: |
19+
cd ${{github.workspace}}\src
1920
git clone https://github.com/simdjson/simdjson.git
20-
c:\pcm\ci-kw-windows.ps1 'echo No_preparation_for_msbuild' 'msbuild pcm-all.sln /p:Configuration=Release,Platform=x64 /t:Clean,Build /m'
21+
cd ..
22+
mkdir build
23+
cd build
24+
cmake ..
25+
c:\pcm\ci-kw-windows.ps1 'echo No_preparation' 'cmake --build . -j'
2126
2227
- name: kw-report
2328
run: |
@@ -31,7 +36,7 @@ jobs:
3136

3237
- name: kw-msr-driver
3338
run: |
34-
chdir WinMSRDriver
39+
chdir ${{github.workspace}}\src\WinMSRDriver
3540
c:\pcm\ci-kw-windows.ps1 'echo No_preparation_for_msbuild' 'msbuild MSR.vcxproj /p:Configuration=Release,Platform=x64 /t:Clean,Build /m'
3641
3742
- name: kw-report-msr-driver

.github/workflows/ci-test.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,26 @@ jobs:
4040
name: test-log-${{ github.sha }}
4141
path: test-log.txt
4242

43+
- name: upload-artifact
44+
uses: actions/upload-artifact@v2
45+
with:
46+
name: test-log-raw-tr-wo_ext-${{ github.sha }}
47+
path: build/bin/raw_tr_wo_ext.csv
48+
49+
- name: upload-artifact
50+
uses: actions/upload-artifact@v2
51+
with:
52+
name: test-log-raw-tr-wi_ext-${{ github.sha }}
53+
path: build/bin/raw_tr_wi_ext.csv
54+
55+
- name: upload-artifact
56+
uses: actions/upload-artifact@v2
57+
with:
58+
name: pcm-csv-${{ github.sha }}
59+
path: build/bin/pcm.csv
60+
61+
- name: upload-artifact
62+
uses: actions/upload-artifact@v2
63+
with:
64+
name: test-log-raw-tr-wi_ext-single_header-${{ github.sha }}
65+
path: build/bin/raw_tr_wi_ext_single_header.csv

.github/workflows/ci-windows.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,8 @@ jobs:
3434
run: |
3535
chdir ${{github.workspace}}\src\WinMSRDriver
3636
msbuild MSR.vcxproj /p:Configuration=Release,Platform=x64 /t:Clean,Build /m
37+
- name: upload-artifact
38+
uses: actions/upload-artifact@v2
39+
with:
40+
name: PCMforWindows
41+
path: build/bin/**/*

CMakeLists.txt

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,14 @@ if(UNIX) # APPLE, LINUX, FREE_BSD
6161

6262
endif(UNIX)
6363

64+
#######################
65+
# Install
66+
#######################
67+
6468
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
6569
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
6670

67-
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) # default is /usr/local
71+
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr") # default is "/usr/local", pcm default is "/usr"
6872
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "..." FORCE)
6973
else()
7074
set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/usr" CACHE PATH "..." FORCE)
@@ -75,3 +79,60 @@ add_subdirectory(examples)
7579
add_subdirectory(tests)
7680

7781
message(STATUS "Install directory: ${CMAKE_INSTALL_PREFIX}")
82+
83+
#######################
84+
# CPack (only UNIX)
85+
#######################
86+
if(UNIX)
87+
if(EXISTS "/etc/debian_version") # for Debian family
88+
set(CPACK_GENERATOR "DEB")
89+
message(STATUS "CPACK_GENERATOR is DEB")
90+
elseif(EXISTS "/etc/redhat-release") # for RHEL, Fedora, CentOs
91+
set(CPACK_GENERATOR "RPM")
92+
message(STATUS "CPACK_GENERATOR is RPM")
93+
else()
94+
if(EXISTS "/etc/os-release")
95+
file(READ "/etc/os-release" OS_PARAMS)
96+
string(REGEX MATCH "suse" OUT ${OS_PARAMS}) # for Suse-like systems
97+
if(OUT STREQUAL "suse")
98+
set(CPACK_GENERATOR "RPM")
99+
message(STATUS "CPACK_GENERATOR is RPM")
100+
else()
101+
set(CPACK_GENERATOR "TXZ")
102+
set(CPACK_SET_DESTDIR ON)
103+
message(STATUS "CPACK_GENERATOR is TXZ")
104+
endif()
105+
else()
106+
set(CPACK_GENERATOR "TXZ")
107+
set(CPACK_SET_DESTDIR ON)
108+
message(STATUS "CPACK_GENERATOR is TXZ")
109+
endif()
110+
endif()
111+
112+
set(CPACK_PACKAGE_CONTACT "intel <[email protected]>")
113+
set(CPACK_PACKAGE_NAME "pcm")
114+
set(CPACK_PACKAGE_VERSION "0000")
115+
116+
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Processor Counter Monitor (PCM)")
117+
set(CPACK_PACKAGE_DESCRIPTION "\
118+
Processor Counter Monitor (PCM) is an application programming\n\
119+
interface (API) and a set of tools based on the API to monitor\n\
120+
performance and energy metrics of Intel(r) Core(tm), Xeon(r), Atom(tm)\n\
121+
and Xeon Phi(tm) processors. PCM works on Linux, Windows, Mac OS X,\n\
122+
FreeBSD and DragonFlyBSD operating systems.")
123+
set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION})
124+
125+
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
126+
set(CPACK_RPM_PACKAGE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
127+
128+
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX})
129+
set(CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
130+
131+
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
132+
set(CPACK_RPM_PACKAGE_RELOCATABLE TRUE)
133+
134+
set(CPACK_DEB_COMPONENT_INSTALL ON)
135+
set(CPACK_RPM_COMPONENT_INSTALL ON)
136+
137+
include (CPack)
138+
endif(UNIX)

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,17 @@ Custom compilation options
111111
--------------------------------------------------------------------------------
112112
The list of custom compilation options is located [here](doc/CUSTOM-COMPILE-OPTIONS.md)
113113

114+
--------------------------------------------------------------------------------
115+
Packaging
116+
--------------------------------------------------------------------------------
117+
Packaging with CPack is supported on Debian and Redhat/SUSE system families.
118+
To create DEB of RPM package need to call cpack after building in build folder:
119+
```
120+
cd build
121+
cpack
122+
```
123+
This creates package:
124+
- "pcm-VERSION-Linux.deb" on Debian family systems;
125+
- "pcm-VERSION-Linux.rpm" on Redhat/SUSE-family systems.
126+
Packages contain pcm-\* binaries and required for usage opCode-\* files.
114127

doc/license.txt

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,27 @@ This notice belongs to the code originating from "Intel Performance Counter Moni
22

33
Copyright (c) 2009-2016, Intel Corporation
44
All rights reserved.
5-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6-
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7-
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8-
* Neither the name of Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
* Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
* Neither the name of Intel Corporation nor the names of its
15+
contributors may be used to endorse or promote products derived from
16+
this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
928

10-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

examples/c_example.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ int main(int argc, const char *argv[])
4343
int i,a[100],b[100],c[100];
4444
uint32_t total = 0;
4545
int lcore_id;
46+
int numEvents = argc - 1;
4647

4748
/* Seed for predictable rand() results */
4849
srand(0);
@@ -80,22 +81,17 @@ int main(int argc, const char *argv[])
8081
PCM.pcm_c_get_cycles == NULL || PCM.pcm_c_get_instr == NULL ||
8182
PCM.pcm_c_build_core_event == NULL || PCM.pcm_c_get_core_event == NULL)
8283
return -1;
83-
switch(argc-1)
84-
{
85-
case 4:
86-
PCM.pcm_c_build_core_event(3,argv[3]);
87-
case 3:
88-
PCM.pcm_c_build_core_event(2,argv[2]);
89-
case 2:
90-
PCM.pcm_c_build_core_event(1,argv[2]);
91-
case 1:
92-
PCM.pcm_c_build_core_event(0,argv[1]);
93-
case 0:
94-
break;
95-
default:
96-
printf("Number of arguments are too many! exit...\n");
97-
return -2;
98-
}
84+
85+
if (numEvents > 4)
86+
{
87+
printf("Number of arguments are too many! exit...\n");
88+
return -2;
89+
}
90+
91+
for (int i = 0; i < numEvents; ++i)
92+
{
93+
PCM.pcm_c_build_core_event(i, argv[i+1]);
94+
}
9995

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

0 commit comments

Comments
 (0)