Use this guide for packet math, architecture backends, device annotations, CUDA/HIP/SYCL code, Tensor device execution, and the contrib/Eigen/GPU module. The repository-root AGENTS.md still applies.
Eigen's vectorization API is the Eigen::internal packet layer. packet_traits and unpacket_traits describe a packet type and its capabilities; p* operations such as pload, pstore, padd, and pmul provide the common interface used by evaluators.
Eigen/src/Core/GenericPacketMath.h. Shared vector implementations live under Eigen/src/Core/arch/Default/; backend specializations live in the relevant sibling directories under Eigen/src/Core/arch/.arch/AVX/ still require EIGEN_VECTORIZE_AVX2 or EIGEN_VECTORIZE_FMA, plus a fallback for narrower configurations. Consult Eigen/src/Core/util/ConfigureVectorization.h for the current feature macros.Has*), packet and half-packet types, alignment, masked access, casts, and cost metadata consistent with the implementation. A capability flag must not advertise an unavailable or semantically different operation.A missing specialization is not always a compile error. Some generic fallbacks in Eigen/src/Core/GenericPacketMath.h are the identity or a single-lane version of the real operation; the generic preverse, for example, returns its argument unchanged. A backend without the specialization then silently computes wrong results instead of failing to build. Before calling a p* operation from code that every backend instantiates, confirm that each backend reaching the call implements the operation. SYCL's packet operations are the usual gap. Keep a scalar fallback for backends that lack it.
The current source tree and test/CMakeLists.txt are authoritative for supported backends and configuration options; do not copy an architecture inventory into documentation.
For CUDA and HIP, EIGEN_DEVICE_FUNC supplies the host/device qualifiers required by functions reached from device code. Under SYCL device compilation it supplies the flattening and inlining attributes Eigen requires, but does not by itself decide whether a function is callable from the device. Preserve it on coefficient accessors, evaluators, functors, small helpers, constructors, and operators reached from device code.
Eigen/src/ and contrib/Eigen/src/ are not user include points.CUDA and HIP kernels can use fixed-size owning matrices, vectors, and arrays through public Eigen headers; see doc/UsingNVCC.dox. Dynamic owning Matrix and Array objects require allocation and are generally unsuitable inside kernels. Runtime dimensions still work: a Map over caller-managed device memory can use dynamic dimensions when every operation the expression reaches is device-callable.
CUDA/HIP compilation disables host SIMD. Move substantial host-side Eigen work to a normal .cpp translation unit. Use EIGEN_NO_CUDA or EIGEN_NO_HIP only when the corresponding compiler processes Eigen exclusively for host use. If device code requires a different dense index type, define EIGEN_DEFAULT_DENSE_INDEX_TYPE consistently wherever objects cross the host/device boundary.
contrib/Eigen/Tensor evaluates expressions through an explicit device. GpuDevice handles CUDA/HIP and SyclDevice handles SYCL; Tensor GPU kernels remain part of the Tensor implementation. Device-resident storage is normally supplied through TensorMap, and the destination selects execution with out.device(device) = expression.
Host-side runtime calls in the device go through EIGEN_GPU_RUNTIME_CHECK in Eigen/src/Core/util/GpuRuntime.h. Kernel launches use LAUNCH_GPU_KERNEL in contrib/Eigen/src/Tensor/TensorDeviceGpu.h, which forwards to internal::gpu_launch in GpuRuntime.h. If only a gpu_assert inspects a stored result, release builds never check it. Before changing memory, synchronization, or callback semantics, consult contrib/Eigen/src/Tensor/README.md and the nearby device implementation.
contrib/Eigen/GPUThis module is a host-side wrapper around NVIDIA libraries, and code selects it explicitly by using the Eigen::gpu types. gpu::DeviceMatrix is not a MatrixBase expression. Each supported expression maps to a CUDA library operation, not to Core coefficient evaluation or packet fusion. Define EIGEN_USE_GPU before including <contrib/Eigen/GPU>, and consult contrib/Eigen/src/GPU/README.md. Its tests under contrib/test/GPU/ are intentionally host-compiled .cpp files.
GPU work in this module runs asynchronously, so refactors that would be harmless elsewhere can break it.
packetmath, the generic packet tests, and special_packetmath; exercise every locally available affected backend.gpu_basic or gpu_example target with the available CUDA/HIP compiler.contrib/Eigen/GPU changes: run the focused target under contrib/test/GPU/ and any affected library integration target enabled by the local toolkit.Performance-sensitive packet or GPU changes require a representative benchmark under identical compiler flags, device state, and workload conditions. Correctness tests are not performance evidence.