proxygen
|
#include <CacheLocality.h>
Public Member Functions | |
template<> | |
const CacheLocality & | system () |
template<> | |
const CacheLocality & | system () |
Static Public Member Functions | |
template<template< typename > class Atom = std::atomic> | |
static const CacheLocality & | system () |
cache index *static CacheLocality | readFromSysfs () |
static CacheLocality | uniform (size_t numCpus) |
Public Attributes | |
size_t | numCpus |
std::vector< size_t > | numCachesByLevel |
std::vector< size_t > | localityIndexByCpu |
Definition at line 60 of file CacheLocality.h.
|
static |
Reads CacheLocality information from a tree structured like the sysfs filesystem. The provided function will be evaluated for each sysfs file that needs to be queried. The function should return a string containing the first line of the file (not including the newline), or an empty string if the file does not exist. The function will be called with paths of the form /sys/devices/system/cpu/cpu Reads CacheLocality information from the real sysfs filesystem. Throws an exception if no cache information can be loaded.
Definition at line 181 of file CacheLocality.cpp.
References getline(), name, and string.
Referenced by folly::getSystemLocalityInfo().
const CacheLocality& folly::CacheLocality::system | ( | ) |
Definition at line 50 of file CacheLocalityBenchmark.cpp.
const CacheLocality& folly::CacheLocality::system | ( | ) |
Definition at line 54 of file CacheLocalityBenchmark.cpp.
|
static |
Returns the best CacheLocality information available for the current system, cached for fast access. This will be loaded from sysfs if possible, otherwise it will be correct in the number of CPUs but not in their sharing structure.
If you are into yo dawgs, this is a shared cache of the local locality of the shared caches.
The template parameter here is used to allow injection of a repeatable CacheLocality structure during testing. Rather than inject the type of the CacheLocality provider into every data type that transitively uses it, all components select between the default sysfs implementation and a deterministic implementation by keying off the type of the underlying atomic. See DeterministicScheduler.
Referenced by folly::detail::DigestBuilder< DigestT >::DigestBuilder(), and folly::detail::MemoryIdler::flushLocalMallocCaches().
|
static |
Returns a usable (but probably not reflective of reality) CacheLocality structure with the specified number of cpus and a single cache level that associates one cpu per cache.
Definition at line 190 of file CacheLocality.cpp.
References localityIndexByCpu, numCachesByLevel, and numCpus.
Referenced by folly::CacheLocality::system< test::DeterministicAtomic >(), folly::getSystemLocalityInfo(), and TEST().
std::vector<size_t> folly::CacheLocality::localityIndexByCpu |
A map from cpu (from sched_getcpu or getcpu) to an index in the range 0..numCpus-1, where neighboring locality indices are more likely to share caches then indices far away. All of the members of a particular cache level be contiguous in their locality index. For example, if numCpus is 32 and numCachesByLevel.back() is 2, then cpus with a locality index < 16 will share one last-level cache and cpus with a locality index >= 16 will share the other.
Definition at line 80 of file CacheLocality.h.
Referenced by uniform().
std::vector<size_t> folly::CacheLocality::numCachesByLevel |
Holds the number of caches present at each cache level (0 is the closest to the cpu). This is the number of AccessSpreader stripes needed to avoid cross-cache communication at the specified layer. numCachesByLevel.front() is the number of L1 caches and numCachesByLevel.back() is the number of last-level caches.
Definition at line 71 of file CacheLocality.h.
Referenced by folly::parseLeadingNumber(), and uniform().
size_t folly::CacheLocality::numCpus |
1 more than the maximum value that can be returned from sched_getcpu or getcpu. This is the number of hardware thread contexts provided by the processors
Definition at line 64 of file CacheLocality.h.
Referenced by uniform().