Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create CUDA streams when integrating with Geant4 #805

Merged
merged 1 commit into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions app/celer-g4/GlobalSetup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ GlobalSetup::GlobalSetup()
cmd.SetGuidance("Set the shared dynamic CUDA heap size (bytes)");
options_->cuda_heap_size = 0;
}
{
auto& cmd = messenger_->DeclareProperty("defaultStream",
options_->default_stream);
cmd.SetGuidance("Launch all kernels on the default stream");
options_->default_stream = false;
}
{
messenger_->DeclareMethod("magFieldZ",
&GlobalSetup::SetMagFieldZTesla,
Expand Down
2 changes: 2 additions & 0 deletions src/accel/SetupOptions.hh
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ struct SetupOptions
//! \name CUDA options
size_type cuda_stack_size{};
size_type cuda_heap_size{};
//! Launch all kernels on the default stream
bool default_stream{false};
//!@}

//!@{
Expand Down
7 changes: 7 additions & 0 deletions src/accel/SharedParams.cc
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,13 @@ void SharedParams::initialize_core(SetupOptions const& options)
}();
}

// Allocate device streams, or use the default stream if there is only one.
if (celeritas::device() && !options.default_stream
&& params.max_streams > 1)
{
celeritas::device().create_streams(params.max_streams);
}

// Construct along-step action
params.action_reg->insert([&params, &options, &imported] {
AlongStepFactoryInput asfi;
Expand Down