diff --git a/app/celer-g4/GlobalSetup.cc b/app/celer-g4/GlobalSetup.cc index 8cd2e2c77e..ceb65b87c7 100644 --- a/app/celer-g4/GlobalSetup.cc +++ b/app/celer-g4/GlobalSetup.cc @@ -133,6 +133,16 @@ void GlobalSetup::ReadInput(std::string const& filename) CELER_ASSERT(instream); nlohmann::json::parse(*instream).get_to(input_); + if (input_.cuda_stack_size != RunInput::unspecified) + { + options_->cuda_stack_size = input_.cuda_stack_size; + } + if (input_.cuda_heap_size != RunInput::unspecified) + { + options_->cuda_heap_size = input_.cuda_heap_size; + } + celeritas::environment().merge(input_.environ); + if constexpr (CELERITAS_CORE_GEO == CELERITAS_CORE_GEO_ORANGE) { static char const fi_hack_envname[] = "ORANGE_FORCE_INPUT"; @@ -179,8 +189,6 @@ void GlobalSetup::ReadInput(std::string const& filename) options_->sd.enabled = input_.sd_type != SensitiveDetectorType::none; options_->slot_diagnostic_prefix = input_.slot_diagnostic_prefix; - options_->cuda_stack_size = input_.cuda_stack_size; - options_->cuda_heap_size = input_.cuda_heap_size; options_->action_times = input_.action_times; options_->default_stream = input_.default_stream; options_->track_order = input_.track_order; diff --git a/app/celer-g4/RunInput.hh b/app/celer-g4/RunInput.hh index 98bf858872..18378d4ed1 100644 --- a/app/celer-g4/RunInput.hh +++ b/app/celer-g4/RunInput.hh @@ -12,10 +12,18 @@ #include "corecel/Types.hh" #include "corecel/cont/Array.hh" #include "corecel/sys/Device.hh" +#include "corecel/sys/Environment.hh" #include "celeritas/ext/GeantPhysicsOptions.hh" #include "celeritas/field/FieldDriverOptions.hh" #include "celeritas/phys/PrimaryGeneratorOptions.hh" +#ifdef _WIN32 +# include +# ifdef environ +# undef environ +# endif +#endif + namespace celeritas { namespace app @@ -54,8 +62,9 @@ struct RunInput static constexpr size_type unspecified{static_cast(-1)}; // Global environment - size_type cuda_stack_size{}; - size_type cuda_heap_size{}; + size_type cuda_stack_size{unspecified}; + size_type cuda_heap_size{unspecified}; + Environment environ; //!< Supplement existing env variables // Problem definition std::string geometry_file; //!< Path to GDML file diff --git a/app/celer-g4/RunInputIO.json.cc b/app/celer-g4/RunInputIO.json.cc index 3e05ce117a..00054f116d 100644 --- a/app/celer-g4/RunInputIO.json.cc +++ b/app/celer-g4/RunInputIO.json.cc @@ -12,6 +12,7 @@ #include "corecel/io/Logger.hh" #include "corecel/io/StringEnumMapper.hh" #include "corecel/sys/Environment.hh" +#include "corecel/sys/EnvironmentIO.json.hh" #include "celeritas/Types.hh" #include "celeritas/TypesIO.hh" #include "celeritas/ext/GeantPhysicsOptionsIO.json.hh" @@ -73,6 +74,10 @@ void from_json(nlohmann::json const& j, RunInput& v) // Check version (if available) check_format(j, "celer-g4"); + RI_LOAD_OPTION(cuda_heap_size); + RI_LOAD_OPTION(cuda_stack_size); + RI_LOAD_REQUIRED(environ); + RI_LOAD_REQUIRED(geometry_file); RI_LOAD_OPTION(event_file); @@ -172,6 +177,10 @@ void to_json(nlohmann::json& j, RunInput const& v) // Save version and format type save_format(j, "celer-g4"); + RI_SAVE_OPTION(cuda_stack_size); + RI_SAVE_OPTION(cuda_heap_size); + RI_SAVE(environ); + RI_SAVE(geometry_file); RI_SAVE_OPTION(event_file); @@ -184,8 +193,6 @@ void to_json(nlohmann::json& j, RunInput const& v) RI_SAVE_OPTION(max_steps); RI_SAVE(initializer_capacity); RI_SAVE(secondary_stack_factor); - RI_SAVE_OPTION(cuda_stack_size); - RI_SAVE_OPTION(cuda_heap_size); RI_SAVE(action_times); RI_SAVE(default_stream); RI_SAVE(auto_flush);