Skip to content

Commit 306614e

Browse files
authored
Merge pull request #249 from intel-innersource/sync-opcm-2022-08-01
Sync opcm 2022 08 01
2 parents f230124 + e02f12f commit 306614e

File tree

12 files changed

+78
-25
lines changed

12 files changed

+78
-25
lines changed

.cirrus.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
freebsd_instance:
2-
image_family: freebsd-12-1
2+
image_family: freebsd-13-1
33

44
task:
5-
install_script: pkg install -y gmake cmake
5+
name: compilation (FreeBSD)
6+
install_script: pkg install -y gmake cmake git
67
script:
8+
- cd src
9+
- git clone https://github.com/simdjson/simdjson.git
10+
- cd ..
711
- cmake -B build -DCMAKE_INSTALL_PREFIX=.
812
- cd build && gmake install
13+
14+
task:
15+
name: clang-scan (FreeBSD)
16+
install_script: pkg install -y gmake cmake git devel/llvm llvm
17+
script:
18+
- cd src
19+
- git clone https://github.com/simdjson/simdjson.git
20+
- cd ..
21+
- scan-build cmake -B build -DCMAKE_INSTALL_PREFIX=.
22+
- cd build
23+
- scan-build --exclude src/simdjson --status-bugs gmake -j
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Mac OS X scan-build
2+
3+
on:
4+
push:
5+
branches: [ macos-scan-build ]
6+
pull_request:
7+
branches: [ macos-scan-build ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: macos-11
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: cmake
17+
run: |
18+
rm -rf ${{ github.workspace }}/build
19+
/usr/local/opt/llvm/bin/scan-build cmake -B ${{ github.workspace }}/build -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}
20+
- name: make
21+
run: |
22+
cd ${{ github.workspace }}/build
23+
/usr/local/opt/llvm/bin/scan-build --exclude src/simdjson --status-bugs make -j

.github/workflows/macosx_build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
build:
1111

12-
runs-on: macos-10.15
12+
runs-on: macos-11
1313

1414
steps:
1515
- uses: actions/checkout@v2

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ Downloading Pre-Compiled PCM Tools
8383

8484
- Linux:
8585
* openSUSE: `sudo zypper install pcm`
86+
* RHEL8.5 or later: `sudo dnf install pcm`
8687
* Fedora: `sudo yum install pcm`
8788
* RPMs and DEBs with the *latest* PCM version for RHEL/SLE/Ubuntu/Debian/openSUSE/etc distributions (binary and source) are available [here](https://software.opensuse.org/download/package?package=pcm&project=home%3Aopcm)
8889
- Windows: download PCM binaries as [appveyor build service](https://ci.appveyor.com/project/opcm/pcm/history) artifacts and required Visual C++ Redistributable from [www.microsoft.com](https://www.microsoft.com/en-us/download/details.aspx?id=48145). Additional drivers are needed, see [WINDOWS_HOWTO.md](doc/WINDOWS_HOWTO.md).

examples/c_example.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,16 @@ int main(int argc, const char *argv[])
107107
printf("[c_example] PCM measurement stopped, compute result %u\n", total);
108108

109109
lcore_id = pcm_getcpu();
110-
printf("C:%lu I:%lu, IPC:%3.2f\n",
111-
PCM.pcm_c_get_cycles(lcore_id),
112-
PCM.pcm_c_get_instr(lcore_id),
110+
printf("C:%llu I:%llu, IPC:%3.2f\n",
111+
(unsigned long long)PCM.pcm_c_get_cycles(lcore_id),
112+
(unsigned long long)PCM.pcm_c_get_instr(lcore_id),
113113
(double)PCM.pcm_c_get_instr(lcore_id)/PCM.pcm_c_get_cycles(lcore_id));
114-
printf("CPU%d E0: %lu, E1: %lu, E2: %lu, E3: %lu\n",
114+
printf("CPU%d E0: %llu, E1: %llu, E2: %llu, E3: %llu\n",
115115
lcore_id,
116-
PCM.pcm_c_get_core_event(lcore_id,0),
117-
PCM.pcm_c_get_core_event(lcore_id,1),
118-
PCM.pcm_c_get_core_event(lcore_id,2),
119-
PCM.pcm_c_get_core_event(lcore_id,3));
116+
(unsigned long long)PCM.pcm_c_get_core_event(lcore_id,0),
117+
(unsigned long long)PCM.pcm_c_get_core_event(lcore_id,1),
118+
(unsigned long long)PCM.pcm_c_get_core_event(lcore_id,2),
119+
(unsigned long long)PCM.pcm_c_get_core_event(lcore_id,3));
120120

121121
return 0;
122122
}

src/MacMSRDriver/PcmMsr/PcmMsr.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,11 @@ void* PcmMsrDriverClassName::mapMemory (uint32_t address, UInt8 **virtual_addres
249249

250250
IOMemoryMap *memory_map = NULL;
251251
IOMemoryDescriptor *memory_descriptor = NULL;
252-
252+
#ifndef __clang_analyzer__ // address a false-positive
253253
memory_descriptor = IOMemoryDescriptor::withPhysicalAddress(address,
254254
4096,
255255
kIODirectionInOut);
256+
#endif
256257
if (memory_descriptor) {
257258
IOReturn ioErr = memory_descriptor->prepare(kIODirectionInOut);
258259
if (ioErr == kIOReturnSuccess) {
@@ -268,9 +269,12 @@ void* PcmMsrDriverClassName::mapMemory (uint32_t address, UInt8 **virtual_addres
268269
}
269270
}
270271
else {
271-
memory_descriptor->release();
272272
IOLog("%s[%p]::%s() -- IOMemoryDescriptor::prepare() failure\n", getName(), this, __FUNCTION__);
273273
}
274+
if (!memory_map)
275+
{
276+
memory_descriptor->release();
277+
}
274278
} else {
275279
IOLog("%s[%p]::%s() -- IOMemoryDescriptor::withPhysicalAddress() failure\n", getName(), this, __FUNCTION__);
276280
}
@@ -288,7 +292,9 @@ void PcmMsrDriverClassName::unmapMemory (void *memory_map)
288292

289293
if (m_map) {
290294
m_map->getMemoryDescriptor()->complete();
295+
#ifndef __clang_analyzer__ // address a false-positive
291296
m_map->getMemoryDescriptor()->release();
297+
#endif
292298
m_map->unmap();
293299
m_map->release();
294300
}

src/MacMSRDriver/PcmMsr/PcmMsr.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ class PcmMsrDriverClassName : public IOService
1010
OSDeclareDefaultStructors(com_intel_driver_PcmMsr)
1111
public:
1212
// IOService methods
13-
virtual bool start(IOService* provider);
13+
virtual bool start(IOService* provider) override;
1414

1515
virtual IOReturn writeMSR(pcm_msr_data_t* data);
1616
virtual IOReturn readMSR(pcm_msr_data_t* idata,pcm_msr_data_t* odata);
1717
virtual IOReturn buildTopology(topologyEntry* odata, uint32_t input_num_cores);
18-
virtual bool init(OSDictionary *dict);
19-
virtual void free(void);
20-
virtual bool handleOpen(IOService* forClient, IOOptionBits opts, void* args);
21-
virtual bool handleIsOpen(const IOService* forClient) const;
22-
virtual void handleClose(IOService* forClient, IOOptionBits opts);
18+
virtual bool init(OSDictionary *dict) override;
19+
virtual void free(void) override;
20+
virtual bool handleOpen(IOService* forClient, IOOptionBits opts, void* args) override;
21+
virtual bool handleIsOpen(const IOService* forClient) const override;
22+
virtual void handleClose(IOService* forClient, IOOptionBits opts) override;
2323

2424
virtual uint32_t getNumCores();
2525

src/cpucounters.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,8 @@ bool PCM::discoverSystemTopology()
10251025
return false;
10261026
}
10271027

1028+
(void) coreMaskWidth; // to supress warnings on MacOS (unused vars)
1029+
10281030
uint32 l2CacheMaskShift = 0;
10291031
#ifdef PCM_DEBUG_TOPOLOGY
10301032
uint32 threadsSharingL2;
@@ -1045,13 +1047,15 @@ bool PCM::discoverSystemTopology()
10451047
<< " [the most significant bit = " << l2CacheMaskShift << "]\n";
10461048
#endif
10471049

1050+
#ifndef __APPLE__
10481051
auto populateEntry = [&smtMaskWidth, &coreMaskWidth, &l2CacheMaskShift](TopologyEntry & entry, const int apic_id)
10491052
{
10501053
entry.thread_id = smtMaskWidth ? extract_bits_ui(apic_id, 0, smtMaskWidth - 1) : 0;
10511054
entry.core_id = (smtMaskWidth + coreMaskWidth) ? extract_bits_ui(apic_id, smtMaskWidth, smtMaskWidth + coreMaskWidth - 1) : 0;
10521055
entry.socket = extract_bits_ui(apic_id, smtMaskWidth + coreMaskWidth, 31);
10531056
entry.tile_id = extract_bits_ui(apic_id, l2CacheMaskShift, 31);
10541057
};
1058+
#endif
10551059

10561060
auto populateHybridEntry = [this](TopologyEntry& entry, int core) -> bool
10571061
{
@@ -7467,7 +7471,7 @@ void ServerPCICFGUncore::cleanupMemTest(const ServerPCICFGUncore::MemTestParam &
74677471
munmap(b, memBufferBlockSize);
74687472
#elif defined(_MSC_VER)
74697473
VirtualFree(b, memBufferBlockSize, MEM_RELEASE);
7470-
#elif defined(__FreeBSD__)
7474+
#elif defined(__FreeBSD__) || defined(__APPLE__)
74717475
(void) b; // avoid the unused variable warning
74727476
(void) memBufferBlockSize; // avoid the unused variable warning
74737477
#else

src/mmio.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,9 @@ OwnMMIORange::~OwnMMIORange()
160160

161161
#include "PCIDriverInterface.h"
162162

163-
MMIORange::MMIORange(uint64 physical_address, uint64 size_, bool readonly_) :
163+
MMIORange::MMIORange(uint64 physical_address, uint64 size_, bool) :
164164
mmapAddr(NULL),
165-
size(size_),
166-
readonly(readonly_)
165+
size(size_)
167166
{
168167
if (size > 4096)
169168
{

src/mmio.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,14 @@ class MMIORange
134134

135135
class MMIORange
136136
{
137+
#ifndef __APPLE__
137138
int32 fd;
139+
#endif
138140
char * mmapAddr;
139141
const uint64 size;
142+
#ifndef __APPLE__
140143
const bool readonly;
144+
#endif
141145
public:
142146
MMIORange(uint64 baseAddr_, uint64 size_, bool readonly_ = true);
143147
uint32 read32(uint64 offset);

0 commit comments

Comments
 (0)