Skip to content

95 implement embree runner#96

Merged
qualand merged 27 commits intodevelopfrom
95-implement-embree-runner
Jan 28, 2026
Merged

95 implement embree runner#96
qualand merged 27 commits intodevelopfrom
95-implement-embree-runner

Conversation

@jmaack24
Copy link
Copy Markdown
Member

Implementation of EmbreeRunner to utilize Intel's Embree ray tracing library (sold separately...).

@jmaack24 jmaack24 self-assigned this Jan 13, 2026
@jmaack24 jmaack24 linked an issue Jan 13, 2026 that may be closed by this pull request
@jmaack24 jmaack24 marked this pull request as ready for review January 15, 2026 19:40
@jmaack24 jmaack24 requested a review from Copilot January 15, 2026 19:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 67 out of 68 changed files in this pull request and generated 8 comments.


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

Comment on lines +126 to +127
// increment position by tiny amount to get off the element if
// tracing to the same element
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

Fixed typo: 'increment' should start with capital 'I' to match comment style, and the comment should end with a period.

Suggested change
// increment position by tiny amount to get off the element if
// tracing to the same element
// Increment position by tiny amount to get off the element if
// tracing to the same element.

Copilot uses AI. Check for mistakes.
float (&min_coord_global)[3],
float (&max_coord_global)[3]);

} // namespace embree_helper
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

Namespace comment is incorrect. Should be '// namespace SolTrace::EmbreeRunner' to match the actual namespace declaration at line 8.

Suggested change
} // namespace embree_helper
} // namespace SolTrace::EmbreeRunner

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,90 @@
#include "find_element_hit.hpp"
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

Incorrect include file name. Should be 'find_element_hit_embree.hpp' instead of 'find_element_hit.hpp'.

Suggested change
#include "find_element_hit.hpp"
#include "find_element_hit_embree.hpp"

Copilot uses AI. Check for mistakes.
Comment on lines +669 to +671
TEST(Aperture, BoundingBox)
{
}
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

Empty test case should either be implemented or removed. The test name suggests it should test aperture bounding box functionality but has no implementation.

Copilot uses AI. Check for mistakes.
Comment on lines +124 to +125
assert(is_approx(x_minmax[0], -r, 1e-6));
assert(is_approx(x_minmax[1], r, 1e-6));
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

Using assert for input validation in production code. Consider using a proper error handling mechanism or documenting that these are debug-only checks. Asserts are typically disabled in release builds.

Suggested change
assert(is_approx(x_minmax[0], -r, 1e-6));
assert(is_approx(x_minmax[1], r, 1e-6));
if (!is_approx(x_minmax[0], -r, 1e-6))
throw std::invalid_argument("Cylinder::bounding_box: x_minmax[0] must be approximately -radius");
if (!is_approx(x_minmax[1], r, 1e-6))
throw std::invalid_argument("Cylinder::bounding_box: x_minmax[1] must be approximately +radius");

Copilot uses AI. Check for mistakes.
EXPECT_NE(rr->get_event(iidx), RayEvent::ABSORB);
EXPECT_NE(rr->get_event(iidx), RayEvent::EXIT);

if(rr->get_event(iidx) == RayEvent::ABSORB)
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

Missing space after 'if' keyword. Should be 'if (rr->get_event(iidx) == RayEvent::ABSORB)'.

Copilot uses AI. Check for mistakes.
this->number_of_elements += el->get_number_of_elements();
el->set_reference_element(this);
// Mark any added elements as virtual if needed
if(this->is_virtual())
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

Missing space after 'if' keyword. Should be 'if (this->is_virtual())'.

Suggested change
if(this->is_virtual())
if (this->is_virtual())

Copilot uses AI. Check for mistakes.
Comment thread coretrace/simulation_data/surface.cpp Outdated
Comment on lines +249 to +251
// TODO: Fix ? This is really only the top half of the cylinder
// Clyinder breaks the model since it is a mulit-valued fuction: each
// x values produces two z values Returning only the positive root
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

Multiple spelling errors: 'Clyinder' should be 'Cylinder', 'mulit-valued fuction' should be 'multi-valued function', and missing period after 'root'.

Suggested change
// TODO: Fix ? This is really only the top half of the cylinder
// Clyinder breaks the model since it is a mulit-valued fuction: each
// x values produces two z values Returning only the positive root
// TODO: Fix ? This is really only the top half of the cylinder.
// Cylinder breaks the model since it is a multi-valued function: each
// x value produces two z values. Returning only the positive root.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 67 out of 68 changed files in this pull request and generated no new comments.


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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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


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

Comment thread README.md

## Steps for Building SolTrace (work in progress)

SolTrace has been updated to use multiple ray tracing engines in addition to the prior implementation. Currently, there is no graphical user interface (it is underdevelopment).
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

The phrase "it is underdevelopment" should be "it is under development" (missing space).

Suggested change
SolTrace has been updated to use multiple ray tracing engines in addition to the prior implementation. Currently, there is no graphical user interface (it is underdevelopment).
SolTrace has been updated to use multiple ray tracing engines in addition to the prior implementation. Currently, there is no graphical user interface (it is under development).

Copilot uses AI. Check for mistakes.
Comment on lines +126 to +130
// Increment position by tiny amount to get off the element if
// tracing to the same element.
PosRayElement[0] = PosRayElement[0] + 1.0e-4 * CosRayElement[0];
PosRayElement[1] = PosRayElement[1] + 1.0e-4 * CosRayElement[1];
PosRayElement[2] = PosRayElement[2] + 1.0e-4 * CosRayElement[2];
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

In the comment on line 126, "Increment position by tiny amount to get off the element" - this hardcoded offset of 1.0e-4 could cause issues with very small or very large geometries. Consider making this epsilon value scale-dependent or configurable based on the element's characteristic dimensions.

Copilot uses AI. Check for mistakes.
Comment on lines +252 to +253
// TODO: Fix ? This is really only the top half of the cylinder.
// Cylinder breaks the model since it is a multi-valued function: each
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

The typo "Clyinder" should be "Cylinder" in the comment.

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/CI.yml
Comment on lines +75 to +99
- name: Install embree (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
$embreeVersion = "4.4.0"
$embreeUrl = "https://github.com/embree/embree/releases/download/v$embreeVersion/embree-$embreeVersion.x64.windows.zip"
$embreeZip = "$env:TEMP\embree.zip"
$embreeDir = "C:\embree"

Write-Host "Downloading Embree $embreeVersion..."
Invoke-WebRequest -Uri $embreeUrl -OutFile $embreeZip

Write-Host "Extracting Embree..."
Expand-Archive -Path $embreeZip -DestinationPath $embreeDir -Force

# $embreeRoot = Get-ChildItem -Path $embreeDir -Directory -Filter "embree*" | Select-Object -First 1
$embreeCMake = Join-Path $embreeDir "lib\cmake\embree-$embreeVersion"
$embreeLib = Join-Path $embreeDir "bin"

# Write-Host "Embree root: $($embreeRoot.FullName)"
Write-Host "Embree CMake: $embreeCMake"
Write-Host "Embree Lib: $embreeLib"

echo "embree_DIR=$embreeCMake" >> $env:GITHUB_ENV
echo "$embreeLib" >> $env:GITHUB_PATH
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

The Windows Embree installation script extracts to a directory path that includes the version number in the zip, but the code assumes a specific directory structure. The commented-out lines suggest there was an attempt to find the embree directory dynamically. This could break if Embree's directory structure changes between versions. Consider making the path detection more robust.

Copilot uses AI. Check for mistakes.
Comment on lines +353 to +360
// Expand bounding boxes slightly to account for float precision
const float expand = 1e-3f;
x_minmax[0] -= expand;
x_minmax[1] += expand;
y_minmax[0] -= expand;
y_minmax[1] += expand;
z_minmax[0] -= expand;
z_minmax[1] += expand;
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

The bounding box expansion with a hardcoded value of 1e-3f could be problematic for different scales. For very small geometries this could be too large, and for very large geometries it might not be sufficient. Consider making this relative to the bounding box dimensions or element scale.

Copilot uses AI. Check for mistakes.
@coveralls
Copy link
Copy Markdown

coveralls commented Jan 22, 2026

Pull Request Test Coverage Report for Build 21417800998

Details

  • 1022 of 1268 (80.6%) changed or added relevant lines in 23 files are covered.
  • 14 unchanged lines in 7 files lost coverage.
  • Overall coverage increased (+0.2%) to 88.052%

Changes Missing Coverage Covered Lines Changed/Added Lines %
coretrace/simulation_runner/native_runner/thread_manager.cpp 2 3 66.67%
coretrace/simulation_runner/native_runner/trace.cpp 8 9 88.89%
coretrace/simulation_data/surface.hpp 21 23 91.3%
coretrace/simulation_runner/native_runner/native_runner.cpp 16 18 88.89%
coretrace/simulation_runner/native_runner/sun_to_primary_stage.cpp 0 2 0.0%
coretrace/simulation_data/aperture.hpp 0 3 0.0%
coretrace/simulation_runner/embree_runner/embree_runner.cpp 36 40 90.0%
coretrace/simulation_data/utilities.hpp 7 12 58.33%
coretrace/simulation_data/surface.cpp 142 148 95.95%
coretrace/simulation_runner/native_runner/determine_interaction_type.cpp 17 26 65.38%
Files with Coverage Reduction New Missed Lines %
coretrace/simulation_data/aperture.hpp 1 74.19%
coretrace/simulation_runner/native_runner/native_runner.cpp 1 92.17%
coretrace/simulation_runner/native_runner/sphere_calculator.hpp 1 0.0%
coretrace/simulation_runner/native_runner/surface_intersection_calculator.hpp 1 50.0%
coretrace/simulation_runner/native_runner/trace.cpp 1 95.0%
coretrace/simulation_data/aperture.cpp 3 69.32%
coretrace/simulation_runner/native_runner/native_runner_types.cpp 6 93.84%
Totals Coverage Status
Change from base Build 21258149251: 0.2%
Covered Lines: 6721
Relevant Lines: 7633

💛 - Coveralls

…explicitly mention adding embree dll path to system path in install instructions
Copy link
Copy Markdown
Collaborator

@qualand qualand left a comment

Choose a reason for hiding this comment

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

Thanks for putting this together. Everything is working on my system. I did notice large sections of commented legacy code. Do we want to remove these in the future?

@jmaack24
Copy link
Copy Markdown
Member Author

Thanks for putting this together. Everything is working on my system. I did notice large sections of commented legacy code. Do we want to remove these in the future?

Do you remember where? I thought I removed most of the commented out code that didn't need to stick around. I can take a look and clean it up here.

@qualand
Copy link
Copy Markdown
Collaborator

qualand commented Jan 27, 2026

Thanks for putting this together. Everything is working on my system. I did notice large sections of commented legacy code. Do we want to remove these in the future?

Do you remember where? I thought I removed most of the commented out code that didn't need to stick around. I can take a look and clean it up here.

I think the main ones that sticked out to me are:
coretrace/simulation_runner/native_runner/determine_interaction_type.cpp
coretrace/simulation_runner/embree_runner/embree_runner.hpp (under private)
coretrace/simulation_runner/embree_runner/bbox_calculator.cpp

@jmaack24
Copy link
Copy Markdown
Member Author

Thanks for putting this together. Everything is working on my system. I did notice large sections of commented legacy code. Do we want to remove these in the future?

Do you remember where? I thought I removed most of the commented out code that didn't need to stick around. I can take a look and clean it up here.

I think the main ones that sticked out to me are: coretrace/simulation_runner/native_runner/determine_interaction_type.cpp coretrace/simulation_runner/embree_runner/embree_runner.hpp (under private) coretrace/simulation_runner/embree_runner/bbox_calculator.cpp

So the stuff in determine_interaction_type.cpp and bbox_calculator.cpp are code that may be needed/useful in the future when implementing other features. (E.g., the commented out sections of determine_interaction_type.cpp are for user defined transmissivity and reflectivity tables).

The code in embree_runner.hpp can be removed. You should see the commit for that in a moment or two.

Copy link
Copy Markdown
Collaborator

@taylorbrown75 taylorbrown75 left a comment

Choose a reason for hiding this comment

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

The embree runner works on my legacy GUI branch. It would be interesting to compare speed performance between embree and native and see how it compares with the legacy code. The embree code is about 33% faster than native with power tower optimizations on for the power-tower-surround_singlefacet test, which is slower than I expected, but that may be because the native runner is faster now thanks to the refactorization.

@qualand
Copy link
Copy Markdown
Collaborator

qualand commented Jan 28, 2026

The embree runner works on my legacy GUI branch. It would be interesting to compare speed performance between embree and native and see how it compares with the legacy code. The embree code is about 33% faster than native with power tower optimizations on for the power-tower-surround_singlefacet test, which is slower than I expected, but that may be because the native runner is faster now thanks to the refactorization.

Do we have a power tower surround multi-facet test? We should see a greater speed up with more elements in the problem geometry.

@qualand qualand merged commit a48ba85 into develop Jan 28, 2026
11 checks passed
@qualand qualand deleted the 95-implement-embree-runner branch January 28, 2026 15:55
@jmaack24
Copy link
Copy Markdown
Member Author

The embree runner works on my legacy GUI branch. It would be interesting to compare speed performance between embree and native and see how it compares with the legacy code. The embree code is about 33% faster than native with power tower optimizations on for the power-tower-surround_singlefacet test, which is slower than I expected, but that may be because the native runner is faster now thanks to the refactorization.

Do we have a power tower surround multi-facet test? We should see a greater speed up with more elements in the problem geometry.

Bothe the NativeRunner and EmbreeRunner ValidationTest2 runs the input file Power-tower-surround_singlefacet.stinput which has 6283 elements and traces 50k rays (this is the same test that Taylor is talking about). On my Mac I get the following times for a release build

  • Native Runner Power Tower OFF: 10782.5 ms
  • Native Runner Power Tower ON: 312.95 ms
  • Embree Runner: 87.7166 ms

So the EmbreeRunner is still ~120 times faster than NativeRunner with Power Tower OFF and ~3.5 times faster than NativeRunner with Power Tower ON. So at least on Mac with a release build, there is still a significant speedup for Embree.

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.

Implement Embree Runner

5 participants