Compiler Flags Guidance for RTX Spark#

The choice of compiler flags is crucial for wide compatibility and best performance. This chapter provides an overview of best practices for compiling software for RTX Spark.

Visual Studio 2022 17.14 Changes#

Outlined atomics are enabled by default in the official release of Visual Studio 2022 17.14 and Visual Studio 2026 for native ARM64 builds, aligning behavior with ARM64EC. Without specifying /arch, the compiler defaults to armv8.0 and emits outlined atomic sequences. Specifying /arch:armv8.1 or higher restores inlined atomic behavior; this is controlled by /forceInterlockedFunctions, which is on by default for Armv8.0 and off for Armv8.1+.

Atomics Performance and Behavior#

ARM64EC uses outlined atomic helper functions to emulate x86_64-style atomic behavior, including compatibility with unaligned atomics. These helper functions can make ARM64EC code slightly larger than ARM64 code, but outlined atomics use function calls (BL/RET) and are now considered as fast as or faster than inlined LDXR/STXR/DMB sequences. Native ARM64 uses inline atomics (LDXR/STXR) when /arch:armv8.1 or higher is specified, which can crash if they are unaligned; ARM64EC avoids this through helper functions.

Native ARM64 still raises exceptions for unaligned atomics, unlike ARM64EC, which handles them gracefully. This remains a risk when porting from x86_64 to ARM64 without using ARM64EC.

Benchmarking and Performance Observations#

Benchmarks show that outlined atomics perform comparably to inlined ones. Notable speedups have been observed in Jolt Physics (approximately 10%) and Geekbench (approximately 1.5%) when using /arch:armv8.2 /feature:rcpc. Outlined atomics add minimal code-size overhead.

Compiler Flag Recommendations#

For a baseline configuration, use /arch:armv8.2 /feature:rcpc with MSVC or -march=armv8.2+rcpc with Clang. For maximum performance, use /arch:armv8.3 /feature:rcpc with MSVC or -mcpu=cortex-x925+crypto with Clang.

Strategic Guidance for Porting#

ARM64EC uses outlined atomics by design for compatibility. Native ARM64 benefits from outlined atomics for performance but lacks unaligned atomic safety. Raising the baseline to armv8.2+rcpc aligns with Windows 11 requirements. Avoid armv8.4 unless targeting newer devices such as Snapdragon X Elite.

Additional Considerations#

For General Matrix Multiplication (GEMM) workloads, use dot-product extensions when supported (+dotprod). Use IsProcessorFeaturePresent() for runtime checks. The /feature:lse, /feature:rcpc, and /feature:rcpc2 flags control atomic and memory-ordering behavior, while /Bd reveals predefined compiler macros for diagnostics.