Skip to content

AVX 10.2 and APX support#592

Open
stefanatwork wants to merge 16 commits into
masterfrom
sw/avx10
Open

AVX 10.2 and APX support#592
stefanatwork wants to merge 16 commits into
masterfrom
sw/avx10

Conversation

@stefanatwork

@stefanatwork stefanatwork commented Mar 23, 2026

Copy link
Copy Markdown
Collaborator

Adding support for the AVX 10.2 and APX instruction sets

@stefanatwork stefanatwork added this to the 4.5 milestone Mar 23, 2026
@stefanatwork stefanatwork self-assigned this Mar 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends Embree’s ISA detection, build configuration, and runtime dispatch to add a new APX (and related AVX10.2) codepath, including updates to CPU feature bitmask width and AVX10.2-specific SIMD helper intrinsics.

Changes:

  • Widen CPU feature/ISA bitmasks and plumbing from int to int64_t across state/config/verify paths.
  • Add APX target support to CMake (flags, target library, config export) and extend runtime symbol-selection macros to include APX.
  • Extend CPU feature detection + SIMD helpers to recognize and use AVX10.2/APX-related capabilities.

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tutorials/verify/verify.h Switch ISA storage/params to int64_t for wider feature masks.
tutorials/verify/verify.cpp Use int64_t ISA masks and add APX to verify ISA list.
tutorials/common/tutorial/application.cpp Document apx in CLI help output.
kernels/common/state.h Update ISA-related APIs/fields to int64_t.
kernels/common/state.cpp Update ISA handling and add APX debug verification + AVX10 string parsing.
kernels/common/rtcore.cpp Extend geometry factory dispatch to include APX-capable symbol selection.
kernels/common/isa.h Add APX namespace and new ISA selection macro combinations (AVX512+APX, etc.).
kernels/common/device.cpp Print CPU features with int64_t and include APX in supported target list string.
kernels/CMakeLists.txt Add embree_apx static library target and integrate APX into file selection.
kernels/bvh/bvh8_factory.h Widen builder/intersector feature masks to int64_t.
kernels/bvh/bvh8_factory.cpp Use APX-aware selection macros for BVH8 intersectors.
kernels/bvh/bvh4_factory.h Widen builder/intersector feature masks to int64_t.
kernels/bvh/bvh4_factory.cpp Use APX-aware selection macros for BVH4 intersectors.
kernels/bvh/bvh_intersector1_bvh4.cpp Return int64_t from getISA() for wider ISA values.
common/sys/sysinfo.h Add APX/AVX10.* feature bits and widen ISA constants/APIs to int64_t.
common/sys/sysinfo.cpp Implement AVX10/APX CPUID + XCR0 detection and widen feature handling.
common/simd/vuint16_avx512.h Use AVX10.2 reductions when available; adjust multiply intrinsic.
common/simd/vllong8_avx512.h Use AVX10.2 reduction intrinsics when available.
common/simd/vfloat16_avx512.h Use AVX10.2 abs/minmax/reduce helpers when available.
common/simd/vdouble8_avx512.h Use AVX10.2 abs/minmax/reduce helpers when available.
common/simd/vboolf8_avx512.h Use AVX10.2 mask intrinsics where applicable.
common/simd/vboolf4_avx512.h Use AVX10.2 mask intrinsics where applicable.
common/simd/vboolf16_avx512.h Use AVX10.2 mask intrinsics where applicable.
common/simd/vboold8_avx512.h Use AVX10.2 mask intrinsics where applicable.
common/simd/vboold4_avx512.h Use AVX10.2 mask intrinsics where applicable.
common/cmake/msvc.cmake Add MSVC flags for APX target builds.
common/cmake/gnu.cmake Add GNU flags for APX target builds.
common/cmake/embree-config.cmake Export APX target setting and include APX targets for static builds.
common/cmake/dpcpp.cmake Add DPCPP flags for APX target builds.
common/cmake/clang.cmake Add Clang flags for APX target builds.
common/cmake/check_isa.cpp Extend ISA probe to detect/report APX.
CMakeLists.txt Add APX to max-ISA selection and enable APX build option/defines.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread common/cmake/check_isa.cpp Outdated
Comment thread kernels/common/state.cpp
Comment on lines +252 to +253
else if (isa == "avx10.1") return AVX512;
else if (isa == "avx10.2") return APX;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this avx10.1/10.2 should get removed, we do not support a ISA config with that name, the isa config is named apx

Comment thread common/sys/sysinfo.cpp
if (hasISA(features,AVX2)) v += "AVX2 ";
if (hasISA(features,AVX512)) v += "AVX512 ";

if (hasISA(features, CPU_FEATURE_APX)) v += "APX ";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this copilot comment is valid, this should return the list of ISAs that can get selected, and for APX target to be selected by Embree one need to have AVX10.2 set too

Comment thread common/sys/sysinfo.h
Comment on lines +18 to +24
/* Allow build system to override via -Disa=... -DISA=... on the command line */
#if !defined(isa)
#if defined(__APX_F__) && defined(__AVX10_2__)
# define isa apx
# define ISA APX
# define ISA_STR "APX"
#elif defined (__AVX512VL__)
Comment thread tutorials/common/tutorial/application.cpp
@stefanatwork stefanatwork changed the title [WIP] AVX 10.2 and APX support AVX 10.2 and APX support Jun 16, 2026
@stefanatwork stefanatwork requested a review from svenwoop June 16, 2026 14:43
stefanatwork and others added 2 commits June 18, 2026 10:45
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
__forceinline vdouble8 srl (const vdouble8& a, const unsigned int b) { return _mm512_castsi512_pd(_mm512_srli_epi64(_mm512_castpd_si512(a), b)); }

#if defined(__AVX10_2__)
// VMINMAXPD: imm8=0x00 -> min, suppress NaN; imm8=0x01 -> max, suppress NaN

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is inconsistent, why are we using here a different intrinsic than in AVX512 mode? should use _mm512_min_pd.

}

#if defined(__AVX10_2__)
// VMINMAXPS: imm8=0x00 -> min, suppress NaN; imm8=0x01 -> max, suppress NaN

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use _mm512_min_ps, thus no change needed for AVX10.2 here

Comment thread common/sys/sysinfo.cpp
uint32_t DisplayFamily_DisplayModel = (DisplayFamily << 8) + (DisplayModel << 0);

// Data from Intel® 64 and IA-32 Architectures, Volume 4, Chapter 2, Table 2-1 (CPUID Signature Values of DisplayFamily_DisplayModel)
if (DisplayFamily_DisplayModel == 0x1301) return CPU::DIAMOND_RAPIDS;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

product not released yet, remove

Comment thread common/sys/sysinfo.cpp
/* cpuid[eax=7,ecx=1].edx */
static const int CPU_FEATURE_BIT_APX = 1 << 21; // APX (Advanced Performance Extensions)

/* cpuid[eax=7,ecx=1].ecx */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commend should be cpuid[eax=7,ecx=1].edx

Comment thread common/sys/sysinfo.cpp
int avx10_version = cpuid_leaf_24_0[EBX] & 0xff;
if (avx10_version >= 1) cpu_features |= CPU_FEATURE_AVX10_1;
if (avx10_version >= 2) cpu_features |= CPU_FEATURE_AVX10_2;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here we are missing to check if the CPU actually supports 512 bit vectors.

Comment thread common/sys/sysinfo.cpp
if (hasISA(features,AVX2)) v += "AVX2 ";
if (hasISA(features,AVX512)) v += "AVX512 ";

if (hasISA(features, CPU_FEATURE_APX)) v += "APX ";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this copilot comment is valid, this should return the list of ISAs that can get selected, and for APX target to be selected by Embree one need to have AVX10.2 set too

Comment thread kernels/common/state.cpp
Comment on lines +252 to +253
else if (isa == "avx10.1") return AVX512;
else if (isa == "avx10.2") return APX;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this avx10.1/10.2 should get removed, we do not support a ISA config with that name, the isa config is named apx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants