Skip to content

Simd math and isa integration#1680

Open
marauder2k7 wants to merge 15 commits intoTorqueGameEngines:developmentfrom
marauder2k9-torque:SIMD-Math-and-ISA-integration
Open

Simd math and isa integration#1680
marauder2k7 wants to merge 15 commits intoTorqueGameEngines:developmentfrom
marauder2k9-torque:SIMD-Math-and-ISA-integration

Conversation

@marauder2k7
Copy link
Contributor

@marauder2k7 marauder2k7 commented Mar 4, 2026

Adds ISA backends to the math functions.

These implementations are protected by use of an object library type so it will only be seen by compatible archs. This may not be the best way to do this would require further investigation. There are some more functions that need to be implemented

TODO: Batch functions, get rid of mMath_C mMath_SSE mMath_ASM.

Future improvements could be to directly use the intrinsics with our public math types eg mPoint3 mPoint4 etc. This way we can avoid multiple load and store calls which are the heaviest functions in the simd pipelines.

The feature was request by Abbey after discovering that simd instructions were not be utilized in our backend math classes.

find avx2 and avx512
setup libraries for different simd isa's
add float4 functions for c sse2 and avx2 (placeholder file for neon to be implemented on mac)
fix mac build
mac implementation had _mm_div (x86 intrinsic)
note: 64bit only
working for both neon32 and neon64

Update math_backend.cpp

further sse simd additions

avx2 float3 added
added normalize_magnitude
added divide fast to float3 may copy to float4

move static spheremesh to drawSphere (initialize on first use) so platform has a chance to load the math backend

all float3 and float4 functions and isas

completed all options of float3 and float4 functions in isas and math_c
neon still to be done but that will be on mac.

Update math_backend.cpp

mac isa neon update

added float3
restructured the classes to look more like the final version of the x86 classes

linux required changes

Update build-macos-clang.yml

Update build-macos-clang.yml

Revert "Update build-macos-clang.yml"

This reverts commit 29dfc56.

Revert "Update build-macos-clang.yml"

This reverts commit 2abad2b.

Update CMakeLists.txt

fix macs stupid build

remove god awful rolling average from frame time tracker....

use intrinsic headers instead

each isa implementation now uses a header for that isa's intrinsic functions these are then used in the impl files. This will make it easier for matrix functions when those are implemented.

fixed comment saying 256 when it should be 512 for avx512

consolidated initializers for function tables

Update neon_intrinsics.h

fixes for some neon intrinsics no idea if this is the best way to do these but they work at least

v_cross is especially messy at the moment we basically just do it as a c math function need to look into getting this done correctly
most matrix functions are converted over, no benefit to converting over the project/ortho because they would be scalar anyway but may need to move them regardless.
removed some x86 intrinsic functions that were in the mat44_impl file
reinstated some mMath_C functions and mMathFn ptrs trying to diagnose an issue.
Had to come up with a different way to initialize the scalar table if the isa tables are not initialized yet. Mac did not like the static initialization.
Had to change neon over to using explicit masks for shifting, cross product was failing during bakes and matrix calculations
MSVC doesnt use __builtin_expect it is a GCC only flag
fix tests by adding an explicit inverse to function
copy 3rd row into dst it seems original was not touching this at all.
should use original matrix translation not the dst matrix
safety no longer needed due to safe initializers
missed convolve and convolveInverse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant