Machine X64

This module contains useful routines for 64-bit x86 computer architecture machines.


prefetch :: (pointer: *void, $hint: Prefetch_Hint);

Prefetching is a method for speeding up fetch operations by beginning a fetch operation before the memory is needed.

The prefetch hint specifies where to prefetch the data to. The prefetch hints include T0, T1, T2, and NTA

  • T0 prefetches data into all levels of the cache hierarchy
  • T1 prefetches data into level 2 cache and higher
  • T2 prefetches data into level 3 cache and higher, or an implementation-specific choice.
  • NTA prefetches data into non-temporal cache structure and into a location close to the processor, minimizing cache pollution.

Here is an example use case for prefetching:

prefetch(, Prefetch_Hint.T0);

Memory Fence

mfence :: ();

This instruction does memory fencing. Memory fence performs a serializing operation on all load-from-memory and store-to-memory instructions that were issued prior the mfence instruction. This serializing operation guarantees that every load and store instruction that precedes in program order the mfence instruction is globally visible before any load or store instruction that follows the mfence instruction is globally visible.


pause :: ();

The PAUSE instruction will de-pipeline memory reads, so that the pipeline is not filled with speculative CMP instructions.