Na 25 jaar kwam de vader naar de bruiloft van zijn dochter — maar hij werd weggestuurd… En even later barstte iedereen in tranen uit.

Een oude man aarzelde bij de ingang van een chique restaurant in Amsterdam. Zijn pak was netjes gestreken maar duidelijk versleten alsof hij het jaren geleden voor het laatst had gedragen en het nu weer uit de kast had gehaald. Zijn grijze haar lag dun over zijn hoofd, alsof het niet meer zeker wist hoe het moest liggen. Hij keek naar zijn reflectie in het getinte glas, streek zijn das glad, haalde diep adem en liep naar binnen.

Meteen botste hij tegen een beveiliger. De man keek hem aan alsof hij een spook uit het verleden was.

“Wie bent u?” bromde hij. “Denkt u dat dit een gaarkeuken is?”

“Ik ben hier voor een bruiloft,” antwoordde de oude man zacht. “Mijn dochter trouwt vandaag…” Een bittere glimlach speelde om zijn lippen.

De beveiliger fronste, sprak iets in zijn portofoon en keek hem wantrouwend aan. De oude man probeerde door de glazen wanden naar de zaal te gluren, maar zag niets de ceremonie vond duidelijk dieper in het restaurant plaats

Even later kwamen twee mannen in pakken naar hem toe. Zonder iets te zeggen namen ze hem bij zijn armen en brachten hem naar een dienstkamer.

“Wat doet u hier?” Een vrouw duwde hem weg alsof hij een ongedierte was. “Ga weg! U hoort hier niet!”

“Sorry… ik wilde alleen mijn dochter zien…”

Het bleken de ouders van de bruidegom te zijn. Ze konden zich niet voorstellen dat deze man familie van de bruid was.

“Wij zijn hier bekend,” zei de vrouw kil, terwijl ze haar dure jas gladstreek. “En wie bent u?”

“Goede vraag,” merkte de man op.

“Maar overbodig,” snauwde ze. “Kijk om u# cpuinfo2
Get processor info in C++ in a cross-platform way.

[![Build Status](https://travis-ci.org/kthohr/cpuinfo2.svg?branch=master)](https://travis-ci.org/kthohr/cpuinfo2)

## Description

*cpuinfo2* (pronounced “cpuinfo squared”) is a C++ library that retrieves processor information in a cross-platform way. Information can be retrieved about:
– the vendor (Intel, AMD, …)
– cpu features (SSE, AVX, …)
– cache sizes (L1, L2, L3)
– …

*cpuinfo2* is loosely based on the original [cpuinfo](https://github.com/pytorch/cpuinfo) library (developed by Marat Dukhan (Facebook) and contributors).

## Installation

### From Source
*cpuinfo2* is a header-only library and has no dependencies.

To use it in your project, simply download the source code and add the following to your compiler flags:

“`
-I /path/to/cpuinfo2/include
“`

## Example Usage

*cpuinfo2* is designed to be easy to use.

“`cpp
#include “cpuinfo2.hpp”

int main()
{

// object to hold processor information
cpuinfo2::processor proc;

// check if an instruction set is available
bool has_sse42 = proc.has_extension(cpuinfo2::sse42);
bool has_avx2 = proc.has_extension(cpuinfo2::avx2);

// get the vendor name
std::string vendor_name = proc.get_vendor_name();

// get cache sizes (in bytes)
std::size_t l1_cache = proc.get_cache_size(cpuinfo2::l1_cache);
std::size_t l2_cache = proc.get_cache_size(cpuinfo2::l2_cache);
std::size_t l3_cache = proc.get_cache_size(cpuinfo2::l3_cache);

return 0;
}
“`

### Features

*cpuinfo2* can detect the following instruction sets:

| Instruction Set | Description |
|—————–|————-|
| `sse` | Streaming SIMD Extensions |
| `sse2` | Streaming SIMD Extensions 2 |
| `sse3` | Streaming SIMD Extensions 3 |
| `ssse3` | Supplemental Streaming SIMD Extensions 3 |
| `sse41` | Streaming SIMD Extensions 4.1 |
| `sse42` | Streaming SIMD Extensions 4.2 |
| `avx` | Advanced Vector Extensions |
| `avx2` | Advanced Vector Extensions 2 |
| `avx512f` | AVX-512 Foundation |
| `avx512pf` | AVX-512 Prefetch |
| `avx512er` | AVX-512 Exponential and Reciprocal |
| `avx512cd` | AVX-512 Conflict Detection |
| `avx512vl` | AVX-512 Vector Length Extensions |
| `avx512bw` | AVX-512 Byte and Word |
| `avx512dq` | AVX-512 Doubleword and Quadword |
| `avx512ifma` | AVX-512 Integer Fused Multiply-Add |
| `avx512vbmi` | AVX-512 Vector Byte Manipulation Instructions |
| `fma` | Fused Multiply-Add |
| `aes` | AES instructions |
| `pclmulqdq` | Carry-less multiplication |
| `rdrand` | Random number generation |
| `rdseed` | Random seed generation |
| `sha` | SHA instructions |
| `adx` | Multi-Precision Add-Carry Instruction Extensions |
| `mmx` | MultiMedia Extensions |
| `cmpxchg16b` | Compare and exchange 16 bytes |
| `abm` | Advanced Bit Manipulation |
| `f16c` | 16-bit floating-point conversion |
| `movbe` | Move Big Endian |
| `xsave` | XSAVE instructions |
| `osxsave` | OS-enabled XSAVE instructions |
| `cx8` | Compare and exchange 8 bytes |
| `cx16` | Compare and exchange 16 bytes |
| `clflush` | Cache line flush |
| `clflushopt` | Optimized cache line flush |
| `clwb` | Cache line write back |
| `mwaitx` | Monitor wait extension |
| `pku` | Protection keys for user-mode pages |
| `ospke` | OS-enabled protection keys |
| `sse4a` | SSE4a instructions |
| `fma4` | Fused Multiply-Add 4 |
| `tbm` | Trailing Bit Manipulation |
| `xop` | XOP instructions |
| `lwp` | Lightweight Profiling |
| `prefetchw` | Prefetch data for writing |
| `fsgsbase` | FS/GS base access |
| `bmi` | Bit Manipulation Instructions |
| `bmi2` | Bit Manipulation Instructions 2 |
| `lzcnt` | Leading Zero Count |
| `popcnt` | Population Count |
| `rtm` | Restricted Transactional Memory |
| `hle` | Hardware Lock Elision |
| `erms` | Enhanced REP MOVSB/STOSB |
| `invpcid` | Invalidate Process-Context Identifier |
| `mpx` | Memory Protection Extensions |
| `sgx` | Software Guard Extensions |
| `cx16` | Compare and exchange 16 bytes |
| `erms` | Enhanced REP MOVSB/STOSB |
| `fpu` | Floating Point Unit |

### Cache Sizes

*cpuinfo2* can detect the following cache sizes:

| Cache Level | Description |
|————-|————-|
| `l1_cache` | Level 1 cache |
| `l2_cache` | Level 2 cache |
| `l3_cache` | Level 3 cache |

## Performance

*cpuinfo2* is designed to be fast. The library is header-only and has no dependencies.

## License

*cpuinfo2* is distributed under the **MIT License**.

## Author

Keith O’Hara

## References

– [cpuinfo](https://github.com/pytorch/cpuinfo)
– [cpu_features](https://github.com/google/cpu_features)

Rate article