Extensions
Forms
2 (2 Legacy)
Data
Intel XED v2026.08.23

PTWRITE puts a value of the program’s choosing into the trace that Intel Processor Trace records. The trace is mostly control flow: which branches went which way, with timing. PTWRITE adds data at the points where the program asks for it, a loop counter, a request number or an argument, as a PTW packet whose payload is the 4 or 8 bytes of its operand. The packet carries no tag of its own: a decoder knows what a value means from where the PTWRITE that wrote it sits in the code.

Silent when nobody listens

PTWRITE emits a packet only while tracing is on and its filters let the current code through (TriggerEn, ContextEn and FilterEn in IA32_RTIT_STATUS) and the tool that set up the trace enabled PTW packets with PTWEn, bit 12 of IA32_RTIT_CTL. Otherwise it changes nothing. With FUPonPTW, bit 5, each PTW packet is followed by a FUP packet that gives the address of the PTWRITE. The operand is read either way: a memory operand still raises #PF on an unmapped page, or #AC where alignment checking is on, whether or not a trace is running. PTWRITE runs at any privilege level.

Sizes and bytes

  • ptwrite r/m32 writes 4 bytes; with REX.W, 8 bytes. A 66 prefix raises #UD instead of selecting 16 bits.
  • The encoding, F3 0F AE /4, sits beside the FS and GS base reads and writes, F3 0F AE /0 to /3 with a register operand (RDFSBASE and its kin); without F3, 0F AE /4 with a memory operand is XSAVE.

With -mptwrite, or an -march such as goldmont-plus, alderlake or sapphirerapids, GCC 14 and Clang 23 at -O2 compile _ptwrite32(x) to ptwrite edi and _ptwrite64(*p) to ptwrite QWORD PTR [rdi].

Where it runs

PTWRITE needs CPUID leaf 14H, the Processor Trace leaf, to report it in EBX bit 4, and raises #UD otherwise. Intel’s manual introduces it with the Goldmont Plus Atom cores. AMD’s manual defines no PTWRITE, and the Zen 5 guest that ran the probe reported leaf 14H as all zeros: all four recorded cases, with 32- and 64-bit register and memory operands, raised #UD.

In the optimization guide

What the optimization guide says about PTWRITE, a line per claim. Each links to the claim in the guide, with its sources and where they differ.

Silvermont to Goldmont Plus

Forms

Every encoding of PTWRITE that Intel XED knows, one row per XED instruction form (iform). How to read the notation.
InstructionEncodingRequires
PTWRITE r32/64 PTWRITE_GPRyF3 0F AE /4INTELPT + PTWRITE
PTWRITE m32/64 PTWRITE_MEMyF3 0F AE /4INTELPT + PTWRITE

Latency and throughput

What the scheduling models of LLVM 23.1.2 give for each form, not measurements: latency / reciprocal throughput in cycles, the ports under them. A row is a model, or models that agree; a dash, a form that its processors lack. Memory forms: latency from the address, ports without the load and store units. Which processors each model covers.
Modelr32
r64
m32
m64
Alder Lake, Sapphire Rapids100 / 2p0 p1 p5 p6 p11100 / 2p0 p1 p5 p6 p11

Operation

What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.

if not cpuid_leaf(0x14, 0)[1] >> 4 & 1:
    fault(UD)                    # CPUID: no PTWRITE
v = src.read()                   # 32 bits, or 64 with REX.W; read
                                 # whether it is traced or not
s = rtit_status                  # FilterEn, ContextEn, TriggerEn:
if s & 7 == 7 and rtit_ctl >> 12 & 1:
    ptw_packet(v, OSIZE, rtit_ctl >> 5 & 1)
                                 # PTWEn: a PTW packet, and with
                                 # FUPonPTW a FUP packet of the
                                 # instruction's address after it
# nothing else changes. With a 66 prefix, #UD

Run on AMD Zen 5 (EPYC 9645): 4 cases. Its cases ran where CPUID reported no PTWRITE, and every one raised an exception.

Operands

What each form reads and writes, as Intel XED records it: the operands of its syntax, in order, and the implicit ones that the syntax does not name. How to read.
OperandKindAction
PTWRITE r/m32/64
r/m32/64explicitread

Flags

None: XED records no flag that the forms test or change.

Intrinsics

The C intrinsics of Clang 23.1.2 that compile to PTWRITE, each with the form it compiles to and the Clang options it needs. The forms come from compiling every intrinsic and decoding the result with Intel XED; all intrinsics A–Z explains the method.

IntrinsicCompiles to
_ptwrite32 void _ptwrite32(unsigned int __value)

PTWRITE r32/64 Legacy -mptwrite

_ptwrite64 void _ptwrite64(unsigned long long __value)

PTWRITE r32/64 Legacy -mptwrite

CPUID and processors

Each form belongs to an XED ISA set. A form can be used when the processor reports every CPUID bit of one of its ISA set's alternatives.

CPUID requirements and processors of the XED ISA sets above. Alternatives are separated by “or”; processors follow XED’s chip model, whose AMD processors end with Zen 2, and the CPU data of this site for Zen 3 to Zen 6.
ISA setCPUIDProcessors
PTWRITE

INTELPT + PTWRITE
CPUID.(EAX=07H,ECX=0):EBX[25] INTELPT
CPUID.(EAX=14H,ECX=0):EBX[4] PTWRITE

Alder Lake, Arrow Lake, Panther Lake, Nova Lake, Sapphire Rapids, Emerald Rapids, Granite Rapids, Diamond Rapids, Goldmont Plus, Tremont, Snow Ridge, Sierra Forest, Clearwater Forest

Sources

  1. Intel XED v2026.08.23 (commit 0bcb6237345c): forms, encodings, operands, flags, exception classes, attributes, ISA sets, CPUID bits and chip model.
  2. Clang's x86 intrinsic headers, LLVM 23.1.2 (commit 85ac56026243): the intrinsics, their signatures and doc comments, and the Clang of that release, which compiled each of them.
  3. LLVM 23.1.2's x86 scheduling models (commit 85ac56026243): the latency, reciprocal throughput and ports of each form, as llvm-mca reports them.
  4. Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2B, page 4-500 (PTWRITE)
  5. Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3 (325384-093, September 2026)
  6. AMD64 Architecture Programmer's Manual, Volume 3: General-Purpose and System Instructions (24594, rev. 3.38, July 2026)

The tables are derived from Intel XED, Copyright Intel Corporation, licensed under the Apache License 2.0; x86-64.net converted and reformatted them. The intrinsics and their signatures come from Clang and the timings from LLVM's scheduling models, both part of the LLVM Project, licensed under the Apache License 2.0 with LLVM Exceptions. The text is our own.