Skip to content

Conversation

@nicholasbl
Copy link

@nicholasbl nicholasbl commented Jan 24, 2026

This hefty PR strips out the custom linear algebra library and replaces it with GLM, a fairly popular and high performance library. This is the first step toward using quaternions instead of a vector and rotation for user-facing simulation_data classes, as discussed with @qualand (Bill).

Aside from allowing some more traditional syntax, GLM improves the performance by around 10% on my machines, and opens the door to using AVX instructions explicitly for additional gains. However: debug builds perform slower, in some cases twice as slow due to the indirection GLM needs to provide platform specific optimizations.

This is a draft as the Optix test is crashing, but I'm not yet sure if it's my fault or not.

Changes:

  • Add in the cmake package manager CPM to make pulling in 3rd party libraries easier (wrapping FetchContent)
  • Move json library to CPM, and add in GLM
  • Replace all uses of Vector3d and Matrix3d with glm::dvec3 and glm::dmat3, and optimize usage

Notes:

  • Note that GLM vectors do have a [] operator, but it is more efficient to use .x, .y, .z accessors
  • GLM allows more idiomatic expressions
    • add_vector has been removed. These expressions can be made using normal syntax: variable = a * v + b * y
    • matrix * matrix and matrix * vector expressions can now be made using normal syntax
  • More optimizations can be made to make better use of SIMD
  • A small change was made to the Rectangle aperture to make is_in faster; this could be done for all apertures

@nicholasbl
Copy link
Author

nicholasbl commented Jan 24, 2026

@jmaack24 Bill suggested I ping you on this PR. This is a pretty large PR, so please let me know if I've messed something up.

@nicholasbl
Copy link
Author

A few tests failing here that didn't fail on my hardware. Looks like the debug ones are duration; that's expected due to the slow performance of GLM in debug mode. The release ones are failing from uninitialization, which I thought I had fixed, but I'll get that fixed up soon enough.

@coveralls
Copy link

coveralls commented Jan 24, 2026

Pull Request Test Coverage Report for Build 21333449051

Details

  • 646 of 683 (94.58%) changed or added relevant lines in 30 files are covered.
  • 72 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-1.3%) to 86.518%

Changes Missing Coverage Covered Lines Changed/Added Lines %
coretrace/simulation_data/sun.hpp 4 5 80.0%
coretrace/simulation_data/cst_templates/heliostat.cpp 35 37 94.59%
coretrace/simulation_data/json_helpers.hpp 2 4 50.0%
coretrace/simulation_data/aperture.cpp 18 21 85.71%
coretrace/simulation_runner/native_runner/tracing_errors.cpp 29 32 90.63%
coretrace/simulation_data/vector_utility.hpp 0 4 0.0%
coretrace/simulation_runner/native_runner/generate_ray.cpp 13 17 76.47%
coretrace/simulation_data/element.hpp 6 11 54.55%
coretrace/simulation_data/matvec.cpp 36 42 85.71%
coretrace/simulation_runner/native_runner/trace.cpp 79 86 91.86%
Files with Coverage Reduction New Missed Lines %
coretrace/simulation_runner/native_runner/tracing_errors.cpp 2 77.33%
coretrace/simulation_data/matvec.cpp 70 32.14%
Totals Coverage Status
Change from base Build 21258149251: -1.3%
Covered Lines: 5878
Relevant Lines: 6794

💛 - Coveralls

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