I'm learning software prefetch instructions.
I want to add fence instructions to serialize prefetch instructions. But the meaning in the manual seems to be that prefetch is not affected by fence.
But it states that CPUID is the way to go. But I have been using CPUID to read processor information, how to use CPUID to serialize prefetch instructions?
A PREFETCHWT1 instruction is considered a hint to this speculative behavior. Because this speculative fetching can occur at any time and is not tied to instruction execution, a PREFETCHWT1 instruction is not ordered with respect to the fence instructions (MFENCE, SFENCE, and LFENCE) or locked memory references. A PREFETCHWT1 instruc- tion is also unordered with respect to CLFLUSH and CLFLUSHOPT instructions, other PREFETCHWT1 instructions, or any other general instruction. It is ordered with respect to serializing instructions such as CPUID, WRMSR, OUT, and MOV CR.
A comment on a previous question mentions: How to use CPUID as a serializing instruction?
#include <intrin.h> and use the __cpuid() function.
But the explanation on the Internet says that this is to read CPU information.
https://learn.microsoft.com/en-us/cpp/intrinsics/cpuid-cpuidex?view=msvc-170
Generates the cpuid instruction that is available on x86 and x64. This instruction queries the processor for information about supported features and the CPU type.
How to use CPUID for serialization?