Skip to content

Introduce VCL, SIMD wrappers, and Vectorized RasterizeSDF(Spheres)#2190

Open
Idclip wants to merge 12 commits into
AcademySoftwareFoundation:masterfrom
Idclip:vcl_simd
Open

Introduce VCL, SIMD wrappers, and Vectorized RasterizeSDF(Spheres)#2190
Idclip wants to merge 12 commits into
AcademySoftwareFoundation:masterfrom
Idclip:vcl_simd

Conversation

@Idclip
Copy link
Copy Markdown
Contributor

@Idclip Idclip commented Apr 8, 2026

This PR proposed to bring in Agner Fog's vectorclass (VCL) library as an internal but optional dependency on x86/x86_64 architecture. It then introduces some further infrastructure to improve/tidy our x86 intrinsic usage/ISA targeting, along with an additional wrapper header openvdb/simd/Simd.h which wraps the VCL Vec containers within a openvdb::simd namespace. This second level of wrapping exists to:

  • Abstract away the underlying SIMD container types should we want to use a different library in the future (e.g. std::simd)
  • Provide a namespace for transient selection of other architectures in the future (arm/neon, etc)
  • Allows us to implement a generic API for non-vectorized or non-x86 builds that instead work on Tuples of values, but allows algorithms to be written with a single implementation for both build types.

Note that the later point is crucial - this encourages us to write code that is more applicable to SIMD concepts, regardless of whether VCL/ISA targeting is in use. Many tools in VDB are inherently memory bound; that is, lots of data reading, little computation. Even when explicitly disabling compiler vectorization for specific x86 ISA's, there are notable performance improvements to be observed in many methods simply be restructuring inner loops to work on multiple components (i.e. many inner loops vs many outer loops).

Finally, to keep this PR small and primarily infrastructural, it contains one vectorized tool port, rasterizeSdf(SphereSettings), which demonstrates how to both migrate from AoS->SoA and port existing scalar code to a templated method for VCL, Tuple and scalar arithmetic types. This implementation works with and without VCL.

The following table demonstrates the observed speedups with all configurations:

  • Scalar - That is, no AoS->SoA, no VCL or Tuples with no ISA targetting, with SSE42 and with AVX
  • Array<2> - Tuples of 2 doubles with no ISA targetting, with SSE42 and with AVX
  • Array<4> - Tuples of 4 doubles with no ISA targetting, with SSE42 and with AVX
  • Intrinsics - Using VCL with SSE42 (2 x doubles) and with AVX (4 x doubles)
image

Note that this particular tool requires no discussion over determinism of horizontal reduction or Intel vs AMD instruction specs - that is, there are no horizontal accumulations and no reciprocal emissions for this case. We can deffer this discussion to a future PR.

I have working implementations of the following which, should this PR be accepted, I can further contribute:

  • PointRasterizeSDF.h rasterizeSdf(SmoothSpheres)
  • PointRasterizeSDF.h rasterizeSdf(Ellipsoids)
  • PointRasterizeTrilinear.h rasterizeTrilinear
  • PrincipalComponentAnalysis.h pca

Comment thread ext/THIRD-PARTY.md
Idclip added 2 commits April 15, 2026 09:10
…on checking - we don't currently need or use this

Signed-off-by: Nick Avramoussis <[email protected]>
@Idclip Idclip force-pushed the vcl_simd branch 2 times, most recently from 865effd to 741c1c5 Compare May 5, 2026 09:32
@Idclip Idclip force-pushed the vcl_simd branch 3 times, most recently from 22158c4 to bf7ffa7 Compare May 14, 2026 07:50
Idclip added 4 commits May 14, 2026 13:03
…essThan and cwiseGreaterThan

Signed-off-by: Nick Avramoussis <[email protected]>
…precation warning will not fire when used in std containers/system headers) and guarded by a define

Signed-off-by: Nick Avramoussis <[email protected]>
…rs that return Tuples of bools

Signed-off-by: Nick Avramoussis <[email protected]>
@Idclip Idclip force-pushed the vcl_simd branch 2 times, most recently from 2c1f5dd to 3735c0f Compare May 14, 2026 11:28
Signed-off-by: Nick Avramoussis <[email protected]>
Copy link
Copy Markdown
Contributor

@danrbailey danrbailey left a comment

Choose a reason for hiding this comment

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

Looks great, a few minor comments.

Comment thread pendingchanges/simd.txt Outdated
Comment thread pendingchanges/simd.txt Outdated
Comment thread openvdb/openvdb/math/Tuple.h Outdated
Comment thread openvdb/openvdb/math/Tuple.h
Comment thread CMakeLists.txt Outdated
Comment thread openvdb/openvdb/points/impl/PointRasterizeSDFImpl.h Outdated
Comment thread openvdb/openvdb/points/impl/PointRasterizeSDFImpl.h Outdated
Comment thread openvdb/openvdb/points/impl/PointRasterizeSDFImpl.h Outdated
Comment thread .github/workflows/weekly.yml Outdated
Comment thread openvdb/openvdb/simd/Simd.h Outdated
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.

2 participants