Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
e59fc3b
Initial run at adding flat circle to OptixRunner
jmaack24 Mar 27, 2026
fa3b64c
Add intersection function to pipeline manager map
jmaack24 Mar 27, 2026
1aab1e1
Compile fixes
jmaack24 Mar 30, 2026
5758108
Initial run at implementation of flat hexagon for optix runner
jmaack24 Mar 30, 2026
4fe91f9
Initial run at basic test for flat hexagon intersection in optix runner
jmaack24 Mar 30, 2026
a390dcd
Fixes for optix runner hexagon flat
jmaack24 Mar 30, 2026
bbda461
Initial implementation of flat annulus for optix runner
jmaack24 Mar 31, 2026
1c21007
Initial implementation of test for optix runner annulus flat
jmaack24 Mar 31, 2026
f820fe5
Fixes for flat annulus in optix runner
jmaack24 Mar 31, 2026
aa722ba
Hack fixes for legacy build
jmaack24 Apr 16, 2026
6c0c77e
Changes to simdriver for scaling workflow
jmaack24 Apr 16, 2026
b8ca9d0
Set recommended hardware flags for embree; fix an unecessary copy in …
jmaack24 Apr 22, 2026
977d5b8
Merge branch '116-support-all-geometries---gpu-runner' into 111-batch…
jmaack24 May 8, 2026
9001288
OptixRunner compile error fixes
jmaack24 May 8, 2026
5015eca
Fix badly merged things
jmaack24 May 8, 2026
248d4cc
Add timing optix run function
jmaack24 May 8, 2026
f22ea2e
Change host side buffer to page-locked memory; integrate hit data int…
jmaack24 May 12, 2026
8db1a6a
Update host side launch params
jmaack24 May 12, 2026
75cb2b7
Rework the loop in the SolTraceSystem::get_buffer_results function lo…
jmaack24 May 12, 2026
7ebc479
Add nsight profiling markers on CPU side
jmaack24 May 12, 2026
2f4738a
Add verbose flag to simdriver
jmaack24 May 13, 2026
7802ff9
Better method to set verbose flag
jmaack24 May 13, 2026
6ce9bb7
Fix linking error
jmaack24 May 13, 2026
cda9a89
Add more timing information to the OptixRunner
jmaack24 May 13, 2026
8a3946e
Initialize curand states only once per call to OptixRunner::run_simul…
jmaack24 May 13, 2026
2e3ae6b
Rearrange memory allocation so it is done once at the beginning of th…
jmaack24 May 13, 2026
ff1b7ab
Move post tracing ray filtering to device
jmaack24 May 14, 2026
efc7e59
Add timers for ray filtering; fix compiler warning
jmaack24 May 14, 2026
5e75261
Use page locked/pinned memory for device to host copies
jmaack24 May 14, 2026
9f0bcd1
Revert page locked memory host memory as it hurt performance
jmaack24 May 14, 2026
a117555
Add manual batch sizing to optix runner
jmaack24 May 14, 2026
a66795f
Add optix runner batching size tests
jmaack24 May 14, 2026
139896b
Fix batch size test
jmaack24 May 15, 2026
1e9b4cc
Fix ctest extra lines printing
jmaack24 May 15, 2026
e088c17
Remove profiling flags
jmaack24 May 15, 2026
df68332
Add automatic batch sizing based on available GPU memory
jmaack24 May 18, 2026
ea4dd5f
Change hit flag buffer from 32-bit to 8-bit
jmaack24 May 18, 2026
2226b24
Remove dead includes in files; update batch size test
jmaack24 May 18, 2026
6571356
Add post simulation calls for number of rays launched and number of r…
jmaack24 May 18, 2026
365d619
Merge branch 'develop' into 111-batch-running-features---gpu-runner
jmaack24 May 19, 2026
41c613d
Make geometry intersection testing for optix runner more robust
jmaack24 May 19, 2026
e99b9d9
Fix dumb errors
jmaack24 May 19, 2026
6808cd6
Another dumb error...
jmaack24 May 19, 2026
e1cddd7
Fix hexagon aperture mistake
jmaack24 May 19, 2026
8b2d78f
Address copilot review comments
jmaack24 May 19, 2026
4e7247a
Add option to enable/disable OptixRunner ray trimming; added test for…
jmaack24 May 19, 2026
08f6f8c
Fix some memory leaks in optix runner
jmaack24 May 19, 2026
ae78f0f
Make automatic batch sizing more stable on multiple run calls
jmaack24 May 19, 2026
1529f5b
Remove outdated todos
jmaack24 May 19, 2026
aa686a3
Move to 64-bit unsigned integers for global ray ids; more copilot rev…
jmaack24 May 20, 2026
e609f99
Limit max trace depth to 255 using 8-bit unsigned integer
jmaack24 May 20, 2026
ebb1e50
Add ray generation tests for optix runner
jmaack24 May 20, 2026
b347a6e
Fix halton generation method; add warning for exceeding 32-bit uint m…
jmaack24 May 26, 2026
bfdec00
Make max trace depth a user accesible parameter at the optix runner l…
jmaack24 May 26, 2026
df0f560
Add tests for user setting max trace depth
jmaack24 May 26, 2026
3cc88e7
Add test checking that max trace depth is observed during tracing
jmaack24 May 26, 2026
663e142
Add count of rays terminated due to max depth
jmaack24 May 26, 2026
1b53f8a
Add test for counting depth terminated rays; expose trace terminated …
jmaack24 May 26, 2026
5f06f16
Attempt to fix occasional post compile optix runner seg fault; relax …
jmaack24 May 26, 2026
5a63384
Address copilot comments
jmaack24 May 27, 2026
874f4dd
One last copilot comment fix
jmaack24 May 27, 2026
dac334b
Fix macro conflict on windows
taylorbrown75 May 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion coretrace/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ set(CORETRACE_SRC
treemesh.cpp
types.cpp
vshot.cpp

simdata_bridge.cpp
)

Expand Down
238 changes: 180 additions & 58 deletions coretrace/simdriver/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,26 @@
* @file main.cpp
* @brief Command-line driver for SolTrace ray tracing.
*
* Reads a JSON file to configure SimulationData, runs the ray tracer,
* Reads a JSON or .stinput file to configure SimulationData, runs the ray tracer,
* and writes the ray interaction records to a CSV file.
*
* Usage:
* simdriver <input.json> <output.csv> [options]
* simdriver <input.json|input.stinput> [<output.csv>] [options]
*
* Options:
* --threads <n> Number of parallel threads (default: 1)
* --rays <n> Override the number of rays from the JSON file
* --no-output Skip result retrieval and CSV output (output file not
* required when this flag is set)
* --no-csv Retrieve results but skip writing the CSV file (output
* file argument not required when this flag is set)
* --embree Use the Embree runner (only available if built with
* SOLTRACE_BUILD_EMBREE_SUPPORT=ON; falls back to native
* runner with a warning if Embree support is absent)
* --optix Use the OptiX runner (only available if built with
* SOLTRACE_BUILD_OPTIX_SUPPORT=ON; falls back to native
* runner with a warning if OptiX support is absent)
* --verbose Enable verbose logging in the OptiX runner
*/

#include <cstdlib>
Expand Down Expand Up @@ -47,11 +52,15 @@ using SolTrace::Runner::RunnerStatus;
static void print_usage(const char *prog)
{
std::cerr
<< "Usage: " << prog << " <input.json> <output.csv> [options]\n"
<< "Usage: " << prog << " <input.json|input.stinput> [<output.csv>] [options]\n"
<< "\n"
<< "Options:\n"
<< " --threads <n> Number of threads (default: 1)\n"
<< " --rays <n> Override number of rays specified in the JSON file\n"
<< " --no-output Skip result retrieval and CSV output\n"
<< " (output file argument not required with this flag)\n"
<< " --no-csv Retrieve results but skip writing the CSV file\n"
<< " (output file argument not required with this flag)\n"
#ifdef SOLTRACE_EMBREE_SUPPORT
<< " --embree Use Embree runner instead of the native runner\n"
<< " (requires SOLTRACE_BUILD_EMBREE_SUPPORT=ON at build time)\n"
Expand All @@ -60,26 +69,54 @@ static void print_usage(const char *prog)
<< " --optix Use OptiX runner instead of the native runner\n"
<< " (requires SOLTRACE_BUILD_OPTIX_SUPPORT=ON at build time)\n"
#endif
<< " --verbose Enable verbose logging in the OptiX runner\n"
;
}

int main(int argc, char *argv[])
{
if (argc < 3)
if (argc < 2)
{
print_usage(argv[0]);
return EXIT_FAILURE;
}

// Pre-scan for --no-output and --no-csv so we know whether output_file is required
bool skip_output = false;
bool skip_csv = false;
for (int i = 2; i < argc; ++i)
{
const std::string a = argv[i];
if (a == "--no-output") skip_output = true;
else if (a == "--no-csv") skip_csv = true;
}

const bool file_optional = skip_output || skip_csv;

const std::string input_file = argv[1];
const std::string output_file = argv[2];

// argv[2], if present and not a flag (does not start with --), is treated as
// the output file path. This allows the user to supply an output path even
// when --no-output or --no-csv is also present without it being mis-parsed
// as an unknown option.
const bool has_output_arg = (argc >= 3) && (std::string(argv[2]).rfind("--", 0) != 0);
const std::string output_file = has_output_arg ? argv[2] : "";
const int opts_start = has_output_arg ? 3 : 2;

if (!file_optional && !has_output_arg)
{
std::cerr << "Error: output file is required unless --no-output or --no-csv is specified\n";
print_usage(argv[0]);
return EXIT_FAILURE;
}

int num_threads = 1;
long long num_rays_override = -1; // -1 means use what the JSON specifies
bool use_embree = false;
bool use_optix = false;
bool verbose = false;

for (int i = 3; i < argc; ++i)
for (int i = opts_start; i < argc; ++i)
{
const std::string arg = argv[i];
if (arg == "--threads")
Expand Down Expand Up @@ -126,6 +163,10 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
}
}
else if (arg == "--no-output" || arg == "--no-csv")
{
// already handled in pre-scan; skip here
}
else if (arg == "--embree")
{
use_embree = true;
Expand All @@ -134,6 +175,10 @@ int main(int argc, char *argv[])
{
use_optix = true;
}
else if (arg == "--verbose")
{
verbose = true;
}
else
{
std::cerr << "Error: unknown option '" << arg << "'\n";
Expand All @@ -143,23 +188,55 @@ int main(int argc, char *argv[])
}

// -------------------------------------------------------------------------
// Load simulation data from JSON
// Load simulation data from JSON or .stinput file
// -------------------------------------------------------------------------
SimulationData simData;
try
{
// Determine format by extension
auto ends_with = [](const std::string &s, const std::string &suffix)
{
return s.size() >= suffix.size() &&
s.compare(s.size() - suffix.size(), suffix.size(), suffix) == 0;
};
const bool is_stinput = ends_with(input_file, ".stinput");
const bool is_json = ends_with(input_file, ".json");

if (!is_stinput && !is_json)
{
std::cerr << "Error: unrecognised input file extension (expected .json or .stinput): "
<< input_file << "\n";
return EXIT_FAILURE;
}

std::cout << "Loading simulation data from: " << input_file << "...\n";
auto t_load_start = std::chrono::steady_clock::now();
simData.import_json_file(input_file);

if (is_json)
{
try
{
simData.import_json_file(input_file);
}
catch (const std::exception &e)
{
std::cerr << "Error loading JSON file: " << e.what() << "\n";
return EXIT_FAILURE;
}
}
else // .stinput
{
if (!simData.import_from_file(input_file))
{
std::cerr << "Error loading .stinput file: " << input_file << "\n";
return EXIT_FAILURE;
}
}

auto t_load_end = std::chrono::steady_clock::now();
std::cout << " Loaded in "
<< std::chrono::duration<double>(t_load_end - t_load_start).count()
<< " s\n";
}
catch (const std::exception &e)
{
std::cerr << "Error loading JSON file: " << e.what() << "\n";
return EXIT_FAILURE;
<< " s\n"
<< " Elements loaded: " << simData.get_number_of_elements() << "\n";
}

// Override ray count if the user requested it
Expand Down Expand Up @@ -217,24 +294,33 @@ int main(int argc, char *argv[])
std::cout << " Completed in "
<< std::chrono::duration<double>(t_run_end - t_run_start).count()
<< " s\n";
std::cout << " Rays launched: " << runner.get_number_rays_launched() << "\n";
std::cout << " Rays traced: " << runner.get_number_rays_traced() << "\n";

std::cout << "Retrieving results...\n";
auto t_report_start = std::chrono::steady_clock::now();
sts = runner.report_simulation(&result, 0);
auto t_report_end = std::chrono::steady_clock::now();
if (sts != RunnerStatus::SUCCESS)
if (!skip_output)
{
std::cerr << "Error: failed to collect simulation results\n";
return EXIT_FAILURE;
std::cout << "Retrieving results...\n";
auto t_report_start = std::chrono::steady_clock::now();
sts = runner.report_simulation(&result, 0);
auto t_report_end = std::chrono::steady_clock::now();
if (sts != RunnerStatus::SUCCESS)
{
std::cerr << "Error: failed to collect simulation results\n";
return EXIT_FAILURE;
}
std::cout << " Retrieved in "
<< std::chrono::duration<double>(t_report_end - t_report_start).count()
<< " s\n";
}
else
{
std::cout << "Skipping result retrieval (--no-output).\n";
}
std::cout << " Retrieved in "
<< std::chrono::duration<double>(t_report_end - t_report_start).count()
<< " s\n";
}
else
#endif
#ifdef SOLTRACE_OPTIX_SUPPORT
if (use_optix)
if (use_optix)
{
OptixRunner runner;

Expand All @@ -245,6 +331,8 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
}

runner.set_verbose(verbose);

std::cout << "Using OptiX runner\n";

std::cout << "Setting up simulation...\n";
Expand Down Expand Up @@ -272,19 +360,33 @@ int main(int argc, char *argv[])
std::cout << " Completed in "
<< std::chrono::duration<double>(t_run_end - t_run_start).count()
<< " s\n";
std::cout << " Rays launched: " << runner.get_number_rays_launched() << "\n";
std::cout << " Rays traced: " << runner.get_number_rays_traced() << "\n";

std::cout << "Retrieving results...\n";
auto t_report_start = std::chrono::steady_clock::now();
sts = runner.report_simulation(&result, 0);
auto t_report_end = std::chrono::steady_clock::now();
if (sts != RunnerStatus::SUCCESS)
if (!skip_output)
{
std::cerr << "Error: failed to collect simulation results\n";
return EXIT_FAILURE;
std::cout << "Retrieving results...\n";
auto t_report_start = std::chrono::steady_clock::now();
sts = runner.report_simulation(&result, 0);
auto t_report_end = std::chrono::steady_clock::now();
if (sts != RunnerStatus::SUCCESS)
{
std::cerr << "Error: failed to collect simulation results\n";
return EXIT_FAILURE;
}
std::cout << " Retrieved in "
<< std::chrono::duration<double>(t_report_end - t_report_start).count()
<< " s\n";
}
else
{
std::cout << "Skipping result retrieval (--no-output).\n";
}

if (!verbose)
{
runner.print_timing();
}
std::cout << " Retrieved in "
<< std::chrono::duration<double>(t_report_end - t_report_start).count()
<< " s\n";
}
else
#endif
Expand Down Expand Up @@ -341,39 +443,59 @@ int main(int argc, char *argv[])
std::cout << " Completed in "
<< std::chrono::duration<double>(t_run_end - t_run_start).count()
<< " s\n";
std::cout << " Rays launched: " << runner.get_number_rays_launched() << "\n";
std::cout << " Rays traced: " << runner.get_number_rays_traced() << "\n";

std::cout << "Retrieving results...\n";
auto t_report_start = std::chrono::steady_clock::now();
sts = runner.report_simulation(&result, 0);
auto t_report_end = std::chrono::steady_clock::now();
if (sts != RunnerStatus::SUCCESS)
if (!skip_output)
{
std::cerr << "Error: failed to collect simulation results\n";
return EXIT_FAILURE;
std::cout << "Retrieving results...\n";
auto t_report_start = std::chrono::steady_clock::now();
sts = runner.report_simulation(&result, 0);
auto t_report_end = std::chrono::steady_clock::now();
if (sts != RunnerStatus::SUCCESS)
{
std::cerr << "Error: failed to collect simulation results\n";
return EXIT_FAILURE;
}
std::cout << " Retrieved in "
<< std::chrono::duration<double>(t_report_end - t_report_start).count()
<< " s\n";
}
else
{
std::cout << "Skipping result retrieval (--no-output).\n";
}
std::cout << " Retrieved in "
<< std::chrono::duration<double>(t_report_end - t_report_start).count()
<< " s\n";
}

// -------------------------------------------------------------------------
// Write results to CSV
// -------------------------------------------------------------------------
std::cout << "Writing " << result.get_number_of_records()
<< " ray records to: " << output_file << "...\n";
try
if (!skip_output && !skip_csv)
{
auto t_write_start = std::chrono::steady_clock::now();
result.write_csv_file(output_file);
auto t_write_end = std::chrono::steady_clock::now();
std::cout << " Written in "
<< std::chrono::duration<double>(t_write_end - t_write_start).count()
<< " s\n";
std::cout << "Writing " << result.get_number_of_records()
<< " ray records to: " << output_file << "...\n";
try
{
auto t_write_start = std::chrono::steady_clock::now();
result.write_csv_file(output_file);
auto t_write_end = std::chrono::steady_clock::now();
std::cout << " Written in "
<< std::chrono::duration<double>(t_write_end - t_write_start).count()
<< " s\n";
}
catch (const std::exception &e)
{
std::cerr << "Error writing CSV file: " << e.what() << "\n";
return EXIT_FAILURE;
}
}
catch (const std::exception &e)
else if (skip_csv)
{
std::cerr << "Error writing CSV file: " << e.what() << "\n";
return EXIT_FAILURE;
std::cout << "Skipping CSV output (--no-csv).\n";
}
else
{
std::cout << "Skipping CSV output (--no-output).\n";
}

std::cout << "Done.\n";
Expand Down
6 changes: 3 additions & 3 deletions coretrace/simulation_data/simulation_parameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ struct SimulationParameters
// TODO: Figure out how to store time...
DateTime sim_dt;

bool include_sun_shape_errors;
bool include_optical_errors;

std::uint_fast64_t number_of_rays;
std::uint_fast64_t max_number_of_rays;
double tolerance;
Expand All @@ -33,6 +30,9 @@ struct SimulationParameters

int seed;

bool include_sun_shape_errors;
bool include_optical_errors;

SimulationParameters() : number_of_rays(10000),
max_number_of_rays(1000000),
tolerance(0.0),
Expand Down
Loading
Loading