TRLC Platform Library  1.0.0
Header-only C++ library for compile-time platform detection and abstraction
Cache-aligned

Checks if cache line alignment is supported/beneficial Determines whether cache line alignment provides performance benefits on the target architecture. Most modern architectures benefit from proper cache line alignment to avoid false sharing and optimize memory bandwidth.

Cache Line Alignment Benefits

Cache Line Sizes

Returns
true if cache line alignment provides performance benefits
Note
This function is constexpr and evaluates at compile time
See also
ArchitectureInfo::cache_line_size for actual cache line size
getArchitectureInfo() for comprehensive cache information

data structure

constexpr auto info = trlc::platform::getArchitectureInfo();
// Align to cache line boundary
alignas(info.cache_line_size) struct {
std::atomic<int> counter;
char padding[info.cache_line_size - sizeof(std::atomic<int>)];
} cache_aligned_counter;
}
static ArchitectureInfo getArchitectureInfo()
static bool supportsCacheLineAlignment()
Since
1.0.0