AVX 10.2 and APX support#592
Conversation
There was a problem hiding this comment.
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
inttoint64_tacross 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.
| else if (isa == "avx10.1") return AVX512; | ||
| else if (isa == "avx10.2") return APX; |
There was a problem hiding this comment.
this avx10.1/10.2 should get removed, we do not support a ISA config with that name, the isa config is named apx
| if (hasISA(features,AVX2)) v += "AVX2 "; | ||
| if (hasISA(features,AVX512)) v += "AVX512 "; | ||
|
|
||
| if (hasISA(features, CPU_FEATURE_APX)) v += "APX "; |
There was a problem hiding this comment.
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
| /* 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__) |
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
use _mm512_min_ps, thus no change needed for AVX10.2 here
| 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; |
There was a problem hiding this comment.
product not released yet, remove
| /* 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 */ |
There was a problem hiding this comment.
commend should be cpuid[eax=7,ecx=1].edx
| 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; | ||
| } |
There was a problem hiding this comment.
here we are missing to check if the CPU actually supports 512 bit vectors.
| if (hasISA(features,AVX2)) v += "AVX2 "; | ||
| if (hasISA(features,AVX512)) v += "AVX512 "; | ||
|
|
||
| if (hasISA(features, CPU_FEATURE_APX)) v += "APX "; |
There was a problem hiding this comment.
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
| else if (isa == "avx10.1") return AVX512; | ||
| else if (isa == "avx10.2") return APX; |
There was a problem hiding this comment.
this avx10.1/10.2 should get removed, we do not support a ISA config with that name, the isa config is named apx
Adding support for the AVX 10.2 and APX instruction sets