QuickCppLib 0.10
Eliminate all the tedious hassle when making state-of-the-art C++ 14 - 23 libraries!
Loading...
Searching...
No Matches
quickcpplib::_xxx::mem_flush_loads_stores Namespace Reference

Namespaces

namespace  detail

Enumerations

enum class  memory_flush { memory_flush_none , memory_flush_retain , memory_flush_evict }
 The kinds of cache line flushing which can be performed. More...

Functions

memory_flush mem_force_reload (const byte *data, size_t bytes, memory_flush kind=memory_flush_none, std::memory_order order=std::memory_order_acquire) noexcept
template<size_t N>
memory_flush mem_force_reload (const byte(&region)[N], memory_flush kind=memory_flush_none, std::memory_order order=std::memory_order_acquire) noexcept
memory_flush mem_flush_stores (const byte *data, size_t bytes, memory_flush kind=memory_flush_none, std::memory_order order=std::memory_order_release) noexcept
template<size_t N>
memory_flush mem_flush_stores (const byte(&region)[N], memory_flush kind=memory_flush_none, std::memory_order order=std::memory_order_release) noexcept

Variables

constexpr memory_flush memory_flush_none = memory_flush::memory_flush_none
 No memory flushing.
constexpr memory_flush memory_flush_retain = memory_flush::memory_flush_retain
 Flush modified cache line to memory, but retain as unmodified in cache.
constexpr memory_flush memory_flush_evict = memory_flush::memory_flush_evict
 Flush modified cache line to memory, and evict completely from all caches.

Enumeration Type Documentation

◆ memory_flush

The kinds of cache line flushing which can be performed.

Enumerator
memory_flush_none 

No memory flushing.

memory_flush_retain 

Flush modified cache line to memory, but retain as unmodified in cache.

memory_flush_evict 

Flush modified cache line to memory, and evict completely from all caches.

52 {
53 memory_flush_none, //!< No memory flushing.
54 memory_flush_retain, //!< Flush modified cache line to memory, but retain as unmodified in cache.
55 memory_flush_evict //!< Flush modified cache line to memory, and evict completely from all caches.
56 };
constexpr memory_flush memory_flush_retain
Flush modified cache line to memory, but retain as unmodified in cache.
Definition mem_flush_loads_stores.hpp:60
constexpr memory_flush memory_flush_evict
Flush modified cache line to memory, and evict completely from all caches.
Definition mem_flush_loads_stores.hpp:62
constexpr memory_flush memory_flush_none
No memory flushing.
Definition mem_flush_loads_stores.hpp:58

Function Documentation

◆ mem_force_reload() [1/2]

memory_flush quickcpplib::_xxx::mem_flush_loads_stores::mem_force_reload ( const byte * data,
size_t bytes,
memory_flush kind = memory_flush_none,
std::memory_order order = std::memory_order_acquire )
inlinenoexcept
270 {
271 memory_flush ret = kind;
272 // Ensure reload elimination does not occur on our region by calling a
273 // potentially unknown external function which forces the compiler to
274 // reload state after this call returns
276 if(memory_flush_evict == kind)
277 {
278 // TODO FIXME We assume a 64 byte cache line, which is bold.
279 void *_data = (void *) (((uintptr_t) data) & ~63);
280 size_t _bytes = ((uintptr_t) data + bytes + 63) - ((uintptr_t) _data);
281 _bytes &= ~63;
282 ret = detail::flush_impl()(_data, _bytes, kind);
283 }
284 // I really wish this would work on a region, not globally
285 atomic_thread_fence(order);
286 return ret;
287 }
flush_impl_type flush_impl() noexcept
Definition mem_flush_loads_stores.hpp:231
potentially_unknown_jump_ptr potentially_unknown_jump(potentially_unknown_jump_ptr set=nullptr)
Definition mem_flush_loads_stores.hpp:241
memory_flush
The kinds of cache line flushing which can be performed.
Definition mem_flush_loads_stores.hpp:52

◆ mem_force_reload() [2/2]

template<size_t N>
memory_flush quickcpplib::_xxx::mem_flush_loads_stores::mem_force_reload ( const byte(&) region[N],
memory_flush kind = memory_flush_none,
std::memory_order order = std::memory_order_acquire )
inlinenoexcept
295 {
296 return mem_force_reload(region, N, kind, order);
297 }
memory_flush mem_force_reload(const byte *data, size_t bytes, memory_flush kind=memory_flush_none, std::memory_order order=std::memory_order_acquire) noexcept
Definition mem_flush_loads_stores.hpp:268

◆ mem_flush_stores() [1/2]

memory_flush quickcpplib::_xxx::mem_flush_loads_stores::mem_flush_stores ( const byte * data,
size_t bytes,
memory_flush kind = memory_flush_none,
std::memory_order order = std::memory_order_release )
inlinenoexcept
318 {
319 // I really wish this would work on a region, not globally
320 atomic_thread_fence(order);
321 // Ensure dead store elimination does not occur on our region by calling a
322 // potentially unknown external function which forces the compiler to dump
323 // out all pending writes before this call
325 if(memory_flush_none != kind)
326 {
327 // TODO FIXME We assume a 64 byte cache line, which is bold.
328 void *_data = (void *) (((uintptr_t) data) & ~63);
329 size_t _bytes = ((uintptr_t) data + bytes + 63) - ((uintptr_t) _data);
330 _bytes &= ~63;
331 memory_flush ret = detail::flush_impl()(_data, _bytes, kind);
332 return ret;
333 }
334 return kind;
335 }

◆ mem_flush_stores() [2/2]

template<size_t N>
memory_flush quickcpplib::_xxx::mem_flush_loads_stores::mem_flush_stores ( const byte(&) region[N],
memory_flush kind = memory_flush_none,
std::memory_order order = std::memory_order_release )
inlinenoexcept
343 {
344 return mem_flush_stores(region, N, kind, order);
345 }
memory_flush mem_flush_stores(const byte *data, size_t bytes, memory_flush kind=memory_flush_none, std::memory_order order=std::memory_order_release) noexcept
Definition mem_flush_loads_stores.hpp:316

Variable Documentation

◆ memory_flush_none

memory_flush quickcpplib::_xxx::mem_flush_loads_stores::memory_flush_none = memory_flush::memory_flush_none
constexpr

No memory flushing.

◆ memory_flush_retain

memory_flush quickcpplib::_xxx::mem_flush_loads_stores::memory_flush_retain = memory_flush::memory_flush_retain
constexpr

Flush modified cache line to memory, but retain as unmodified in cache.

◆ memory_flush_evict

memory_flush quickcpplib::_xxx::mem_flush_loads_stores::memory_flush_evict = memory_flush::memory_flush_evict
constexpr

Flush modified cache line to memory, and evict completely from all caches.