Skip to content

Commit

Permalink
Add environ support to celer-g4
Browse files Browse the repository at this point in the history
  • Loading branch information
sethrj committed Oct 1, 2024
1 parent 86664d0 commit 818fc91
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
12 changes: 10 additions & 2 deletions app/celer-g4/GlobalSetup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down
13 changes: 11 additions & 2 deletions app/celer-g4/RunInput.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cstdlib>
# ifdef environ
# undef environ
# endif
#endif

namespace celeritas
{
namespace app
Expand Down Expand Up @@ -54,8 +62,9 @@ struct RunInput
static constexpr size_type unspecified{static_cast<size_type>(-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
Expand Down
11 changes: 9 additions & 2 deletions app/celer-g4/RunInputIO.json.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand All @@ -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);
Expand Down

0 comments on commit 818fc91

Please sign in to comment.