Path: blob/master/thirdparty/embree/common/sys/sysinfo.h
9912 views
// Copyright 2009-2021 Intel Corporation1// SPDX-License-Identifier: Apache-2.023#pragma once45#define CACHELINE_SIZE 6467#if !defined(PAGE_SIZE)8#define PAGE_SIZE 40969#endif1011#define PAGE_SIZE_2M (2*1024*1024)12#define PAGE_SIZE_4K (4*1024)1314#include "platform.h"1516/* define isa namespace and ISA bitvector */17#if defined (__AVX512VL__)18# define isa avx51219# define ISA AVX51220# define ISA_STR "AVX512"21#elif defined (__AVX2__)22# define isa avx223# define ISA AVX224# define ISA_STR "AVX2"25#elif defined(__AVXI__)26# define isa avxi27# define ISA AVXI28# define ISA_STR "AVXI"29#elif defined(__AVX__)30# define isa avx31# define ISA AVX32# define ISA_STR "AVX"33#elif defined (__SSE4_2__)34# define isa sse4235# define ISA SSE4236# define ISA_STR "SSE4.2"37//#elif defined (__SSE4_1__) // we demote this to SSE2, MacOSX code compiles with SSE41 by default with XCode 1138//# define isa sse4139//# define ISA SSE4140//# define ISA_STR "SSE4.1"41//#elif defined(__SSSE3__) // we demote this to SSE2, MacOSX code compiles with SSSE3 by default with ICC42//# define isa ssse343//# define ISA SSSE344//# define ISA_STR "SSSE3"45//#elif defined(__SSE3__) // we demote this to SSE2, MacOSX code compiles with SSE3 by default with clang46//# define isa sse347//# define ISA SSE348//# define ISA_STR "SSE3"49#elif defined(__SSE2__) || defined(__SSE3__) || defined(__SSSE3__)50# define isa sse251# define ISA SSE252# define ISA_STR "SSE2"53#elif defined(__SSE__)54# define isa sse55# define ISA SSE56# define ISA_STR "SSE"57#elif defined(__ARM_NEON)58// NOTE(LTE): Use sse2 for `isa` for the compatibility at the moment.59#define isa sse260#define ISA NEON61#define ISA_STR "NEON"62#else63#error Unknown ISA64#endif6566namespace embree67{68enum class CPU69{70XEON_ICE_LAKE,71CORE_ICE_LAKE,72CORE_TIGER_LAKE,73CORE_COMET_LAKE,74CORE_CANNON_LAKE,75CORE_KABY_LAKE,76XEON_SKY_LAKE,77CORE_SKY_LAKE,78XEON_PHI_KNIGHTS_MILL,79XEON_PHI_KNIGHTS_LANDING,80XEON_BROADWELL,81CORE_BROADWELL,82XEON_HASWELL,83CORE_HASWELL,84XEON_IVY_BRIDGE,85CORE_IVY_BRIDGE,86SANDY_BRIDGE,87NEHALEM,88CORE2,89CORE1,90ARM,91UNKNOWN,92};9394/*! get the full path to the running executable */95std::string getExecutableFileName();9697/*! return platform name */98std::string getPlatformName();99100/*! get the full name of the compiler */101std::string getCompilerName();102103/*! return the name of the CPU */104std::string getCPUVendor();105106/*! get microprocessor model */107CPU getCPUModel();108109/*! converts CPU model into string */110std::string stringOfCPUModel(CPU model);111112/*! CPU features */113static const int CPU_FEATURE_SSE = 1 << 0;114static const int CPU_FEATURE_SSE2 = 1 << 1;115static const int CPU_FEATURE_SSE3 = 1 << 2;116static const int CPU_FEATURE_SSSE3 = 1 << 3;117static const int CPU_FEATURE_SSE41 = 1 << 4;118static const int CPU_FEATURE_SSE42 = 1 << 5;119static const int CPU_FEATURE_POPCNT = 1 << 6;120static const int CPU_FEATURE_AVX = 1 << 7;121static const int CPU_FEATURE_F16C = 1 << 8;122static const int CPU_FEATURE_RDRAND = 1 << 9;123static const int CPU_FEATURE_AVX2 = 1 << 10;124static const int CPU_FEATURE_FMA3 = 1 << 11;125static const int CPU_FEATURE_LZCNT = 1 << 12;126static const int CPU_FEATURE_BMI1 = 1 << 13;127static const int CPU_FEATURE_BMI2 = 1 << 14;128static const int CPU_FEATURE_AVX512F = 1 << 16;129static const int CPU_FEATURE_AVX512DQ = 1 << 17;130static const int CPU_FEATURE_AVX512PF = 1 << 18;131static const int CPU_FEATURE_AVX512ER = 1 << 19;132static const int CPU_FEATURE_AVX512CD = 1 << 20;133static const int CPU_FEATURE_AVX512BW = 1 << 21;134static const int CPU_FEATURE_AVX512VL = 1 << 22;135static const int CPU_FEATURE_AVX512IFMA = 1 << 23;136static const int CPU_FEATURE_AVX512VBMI = 1 << 24;137static const int CPU_FEATURE_XMM_ENABLED = 1 << 25;138static const int CPU_FEATURE_YMM_ENABLED = 1 << 26;139static const int CPU_FEATURE_ZMM_ENABLED = 1 << 27;140static const int CPU_FEATURE_NEON = 1 << 28;141static const int CPU_FEATURE_NEON_2X = 1 << 29;142143/*! get CPU features */144int getCPUFeatures();145146/*! convert CPU features into a string */147std::string stringOfCPUFeatures(int features);148149/*! creates a string of all supported targets that are supported */150std::string supportedTargetList (int isa);151152/*! ISAs */153static const int SSE = CPU_FEATURE_SSE | CPU_FEATURE_XMM_ENABLED;154static const int SSE2 = SSE | CPU_FEATURE_SSE2;155static const int SSE3 = SSE2 | CPU_FEATURE_SSE3;156static const int SSSE3 = SSE3 | CPU_FEATURE_SSSE3;157static const int SSE41 = SSSE3 | CPU_FEATURE_SSE41;158static const int SSE42 = SSE41 | CPU_FEATURE_SSE42 | CPU_FEATURE_POPCNT;159static const int AVX = SSE42 | CPU_FEATURE_AVX | CPU_FEATURE_YMM_ENABLED;160static const int AVXI = AVX | CPU_FEATURE_F16C;161static const int AVX2 = AVXI | CPU_FEATURE_AVX2 | CPU_FEATURE_FMA3 | CPU_FEATURE_BMI1 | CPU_FEATURE_BMI2 | CPU_FEATURE_LZCNT;162static const int AVX512 = AVX2 | CPU_FEATURE_AVX512F | CPU_FEATURE_AVX512DQ | CPU_FEATURE_AVX512CD | CPU_FEATURE_AVX512BW | CPU_FEATURE_AVX512VL | CPU_FEATURE_ZMM_ENABLED;163static const int NEON = CPU_FEATURE_NEON | CPU_FEATURE_SSE | CPU_FEATURE_SSE2;164static const int NEON_2X = CPU_FEATURE_NEON_2X | AVX2;165166/*! converts ISA bitvector into a string */167std::string stringOfISA(int features);168169/*! return the number of logical threads of the system */170unsigned int getNumberOfLogicalThreads();171172/*! returns the size of the terminal window in characters */173int getTerminalWidth();174175/*! returns performance counter in seconds */176double getSeconds();177178/*! sleeps the specified number of seconds */179void sleepSeconds(double t);180181/*! returns virtual address space occupied by process */182size_t getVirtualMemoryBytes();183184/*! returns resident memory required by process */185size_t getResidentMemoryBytes();186}187188189