Simd Library Documentation.

Home | Release Notes | Download | Documentation | Issues | GitHub

Functions with information about library. More...

Functions

SIMD_API const char * SimdVersion (void)
 Gets version of Simd Library. More...
 
SIMD_API const char * SimdCpuDesc (SimdCpuDescType type)
 Gets a text description of the CPU. More...
 
SIMD_API uint64_t SimdCpuInfo (SimdCpuInfoType type)
 Gets information about CPU and Simd Library. More...
 
SIMD_API const char * SimdPerformanceStatistic (void)
 Gets internal performance statistics of Simd Library. More...
 
SIMD_INLINE void PrintInfo (std::ostream &os)
 Prints information about Simd Library and CPU. More...
 

Detailed Description

Functions with information about library.

Function Documentation

◆ SimdVersion()

const char * SimdVersion ( void  )

Gets version of Simd Library.

Returns a pointer to a null-terminated, statically allocated string that encodes the library version. The format of the string is:

major.minor.release[.branch-sha]

where major, minor and release are numeric components taken from the library's version file, and the optional branch and sha suffix identify the Git branch name and short commit hash at build time (e.g. "7.1.161.main-a1b2c3d"). When version information is not available at build time the function returns "unknown".

The returned pointer is valid for the lifetime of the process and must not be freed.

Using example:

#include "Simd/SimdLib.h"
#include <iostream>

int main()
{
    std::cout << "Simd Library version: " << SimdVersion() << std::endl;
    return 0;
}
Returns
a pointer to a static null-terminated string with the version of Simd Library.

◆ SimdCpuDesc()

const char * SimdCpuDesc ( SimdCpuDescType  type)

Gets a text description of the CPU.

Returns a pointer to a null-terminated string whose content depends on the requested SimdCpuDescType:

  • SimdCpuDescModel — the CPU brand/model name string (e.g. "Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz"). On x86 it is read from the CPUID brand-string leaves; on Linux/ARM it is obtained via lscpu. An empty string is returned on platforms where the model name is not available (Apple, Android).

The returned pointer is valid for the lifetime of the process and must not be freed. For an unknown or unsupported type value the function returns NULL.

Note
See enumeration SimdCpuDescType for the full list of supported types.

Using example:

#include "Simd/SimdLib.h"
#include <iostream>

int main()
{
    std::cout << "CPU model: " << SimdCpuDesc(SimdCpuDescModel) << std::endl;
    return 0;
}
Parameters
[in]type- a type of required description. See SimdCpuDescType.
Returns
a pointer to a static null-terminated string with the requested CPU description, or NULL if type is not supported.

◆ SimdCpuInfo()

uint64_t SimdCpuInfo ( SimdCpuInfoType  type)

Gets information about CPU and Simd Library.

Depending on the requested SimdCpuInfoType, the function returns one of the following kinds of values:

  • CPU topology: number of sockets, physical cores, or logical threads.
  • Cache / RAM sizes in bytes (L1 data cache, L2 cache, L3 cache, physical RAM).
  • SIMD extension availability: 1 if the extension is supported and enabled by the library, 0 otherwise. The extensions covered are SSE4.1 (and below), AVX2 (and FMA/AVX), AVX-512BW (and AVX-512F), AVX-512VNNI, AMX-BF16 (and AMX-INT8/AVX-512VBMI/AVX-512FP16), NEON, SVE, and HVX.
  • SVE vector width in bytes (SimdCpuInfoSveSize).
  • Current CPU core frequency in Hz (SimdCpuInfoCurrentFrequency); returns 0 if unavailable on the platform.
Note
See enumeration SimdCpuInfoType.

Using example:

#include "Simd/SimdLib.h"
#include <iostream>

int main()
{
    std::cout << "Sockets: " << SimdCpuInfo(SimdCpuInfoSockets) << std::endl;
    std::cout << "Cores: " << SimdCpuInfo(SimdCpuInfoCores) << std::endl;
    std::cout << "Threads: " << SimdCpuInfo(SimdCpuInfoThreads) << std::endl;
    std::cout << "L1D Cache: " << SimdCpuInfo(SimdCpuInfoCacheL1) / 1024  << " KB" << std::endl;
    std::cout << "L2 Cache: " << SimdCpuInfo(SimdCpuInfoCacheL2) / 1024  << " KB" << std::endl;
    std::cout << "L3 Cache: " << SimdCpuInfo(SimdCpuInfoCacheL3) / 1024  << " KB" << std::endl;
    std::cout << "RAM: " << SimdCpuInfo(SimdCpuInfoRam) / 1024 / 1024 << " MB" << std::endl;
    std::cout << "SSE4.1: " << (SimdCpuInfo(SimdCpuInfoSse41) ? "Yes" : "No") << std::endl;
    std::cout << "AVX2: " << (SimdCpuInfo(SimdCpuInfoAvx2) ? "Yes" : "No") << std::endl;
    std::cout << "AVX-512BW: " << (SimdCpuInfo(SimdCpuInfoAvx512bw) ? "Yes" : "No") << std::endl;
    std::cout << "AVX-512VNNI: " << (SimdCpuInfo(SimdCpuInfoAvx512vnni) ? "Yes" : "No") << std::endl;
    std::cout << "AMX-BF16: " << (SimdCpuInfo(SimdCpuInfoAmxBf16) ? "Yes" : "No") << std::endl;
    std::cout << "ARM-NEON: " << (SimdCpuInfo(SimdCpuInfoNeon) ? "Yes" : "No") << std::endl;
    std::cout << "ARM-SVE: " << (SimdCpuInfo(SimdCpuInfoSve) ? "Yes" : "No") << std::endl;
    std::cout << "ARM-SVE size: " << SimdCpuInfo(SimdCpuInfoSveSize) * 8 << " bits" << std::endl;
    std::cout << "HVX: " << (SimdCpuInfo(SimdCpuInfoHvx) ? "Yes" : "No") << std::endl;
    std::cout << "Current frequency: " << SimdCpuInfo(SimdCpuInfoCurrentFrequency) / 1000000 << " MHz" << std::endl;
    return 0;
}
Parameters
[in]type- a type of required information.
Returns
a value whose meaning depends on type: a count (topology), size in bytes (cache/RAM), 1 or 0 (SIMD availability), size in bytes (SVE vector width), or frequency in Hz (current CPU frequency).

◆ SimdPerformanceStatistic()

const char * SimdPerformanceStatistic ( void  )

Gets internal performance statistics of Simd Library.

Note
Simd Library have to be build with defined SIMD_PERFORMANCE_STATISTIC macro.
Returns
string with internal performance statistics of Simd Library.

◆ PrintInfo()

void PrintInfo ( std::ostream &  os)

Prints information about Simd Library and CPU.

Parameters
[in,out]os- output stream.