Skip to content

Commit

Permalink
Merge branch 'develop' into use-infix-evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
esseivaju committed Jan 10, 2025
2 parents a30c55d + 96d4e58 commit 05f8541
Show file tree
Hide file tree
Showing 92 changed files with 661 additions and 494 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build-spack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ jobs:
${{
( (matrix.special == 'minimal')
|| (matrix.special == 'float')
|| (matrix.geometry == 'geant4')
|| !matrix.geant
) && '1' || ''
}}
Expand Down
2 changes: 1 addition & 1 deletion app/celer-g4/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ if(NOT CELERITAS_USE_HepMC3 OR NOT CELERITAS_USE_Geant4)
set(_props DISABLED true)
endif()
if(CELERITAS_CORE_GEO STREQUAL "Geant4")
# FIXME: geant4 navigator doesn't work at scale, nor through accel
# FIXME: geant4 navigator doesn't work with field navigator
set(_props DISABLED true)
endif()
if(CELERITAS_REAL_TYPE STREQUAL "float")
Expand Down
1 change: 1 addition & 0 deletions app/celer-g4/TimerOutput.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class TimerOutput final : public OutputInterface

//!@{
//! \name Output interface

//! Category of data to write
Category category() const final { return Category::result; }
//! Key for the entry inside the category.
Expand Down
1 change: 1 addition & 0 deletions src/accel/GeantSimpleCalo.hh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class GeantSimpleCalo final : public OutputInterface

//!@{
//! \name Output interface

//! Category of data to write
Category category() const final { return Category::result; }
// Key for the entry inside the category
Expand Down
1 change: 1 addition & 0 deletions src/accel/GeantStepDiagnostic.hh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class GeantStepDiagnostic final : public OutputInterface

//!@{
//! \name Output interface

//! Category of data to write
Category category() const final { return Category::result; }
//! Key for the entry inside the category.
Expand Down
26 changes: 15 additions & 11 deletions src/accel/LocalTransporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,6 @@ LocalTransporter::LocalTransporter(SetupOptions const& options,
}
}

if (CELERITAS_CORE_GEO == CELERITAS_CORE_GEO_GEANT4)
{
/*!
* \todo Add support for Geant4 navigation wrapper, which requires
* calling \c state.ref().geometry.reset() on the local transporter
* thread due to thread-allocated navigator data.
*/
CELER_NOT_IMPLEMENTED(
"offloading when using Celeritas Geant4 navigation wrapper");
}

// Create hit processor on the local thread so that it's deallocated when
// this object is destroyed
StreamId stream_id{static_cast<size_type>(thread_id)};
Expand All @@ -168,6 +157,8 @@ LocalTransporter::LocalTransporter(SetupOptions const& options,

// Save state for reductions at the end
params.set_state(stream_id.get(), step_->sp_state());

CELER_ENSURE(*this);
}

//---------------------------------------------------------------------------//
Expand Down Expand Up @@ -311,6 +302,19 @@ void LocalTransporter::Finalize()
<< "offloaded tracks (" << buffer_.size()
<< " in buffer) were not flushed");

if constexpr (CELERITAS_CORE_GEO == CELERITAS_CORE_GEO_GEANT4)
{
// Geant4 navigation states *MUST* be deallocated on the thread in
// which they're allocated
auto state = std::dynamic_pointer_cast<CoreState<MemSpace::host>>(
step_->sp_state());
CELER_ASSERT(state);
#if CELERITAS_CORE_GEO == CELERITAS_CORE_GEO_GEANT4
CELER_LOG_LOCAL(debug) << "Deallocating navigation states";
state->ref().geometry.reset();
#endif
}

// Reset all data
CELER_LOG_LOCAL(debug) << "Resetting local transporter";
*this = {};
Expand Down
8 changes: 8 additions & 0 deletions src/accel/SetupOptions.hh
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ struct SetupOptions

//!@{
//! \name I/O

//! GDML filename (optional: defaults to exporting existing Geant4)
std::string geometry_file;
//! Filename for JSON diagnostic output
Expand All @@ -143,6 +144,7 @@ struct SetupOptions

//!@{
//! \name Celeritas stepper options

//! Number of track "slots" to be transported simultaneously
size_type max_num_tracks{};
//! Maximum number of events in use (DEPRECATED: remove in v0.6)
Expand All @@ -161,6 +163,7 @@ struct SetupOptions

//!@{
//! \name Track reordering options

TrackOrder track_order{Device::num_devices() ? TrackOrder::init_charge
: TrackOrder::none};
//!@}
Expand All @@ -170,11 +173,13 @@ struct SetupOptions

//!@{
//! \name Stepping actions

AlongStepFactory make_along_step;
//!@}

//!@{
//! \name Field options

size_type max_field_substeps{100};
//!@}

Expand All @@ -183,12 +188,14 @@ struct SetupOptions

//!@{
//! \name Physics options

//! Do not use Celeritas physics for the given Geant4 process names
VecString ignore_processes;
//!@}

//!@{
//! \name CUDA options

//! Per-thread stack size (may be needed for VecGeom) [B]
size_type cuda_stack_size{};
//! Dynamic heap size (may be needed for VecGeom) [B]
Expand All @@ -201,6 +208,7 @@ struct SetupOptions

//!@{
//! \name Diagnostic setup

//! Filename base for slot diagnostics
std::string slot_diagnostic_prefix;
//!@}
Expand Down
8 changes: 4 additions & 4 deletions src/accel/SetupOptionsMessenger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ struct UICommandTraits;
template<>
struct UICommandTraits<std::string>
{
static inline constexpr char type_info = 's';
static constexpr char type_info = 's';
static std::string const& to_string(G4String const& v) { return v; }
static std::string from_string(G4String const& v) { return v; }
};

template<>
struct UICommandTraits<bool>
{
static inline constexpr char type_info = 'b';
static constexpr char type_info = 'b';
static G4String to_string(bool v)
{
return G4UIcommand::ConvertToString(v);
Expand All @@ -50,7 +50,7 @@ struct UICommandTraits<bool>
template<class T>
struct UICommandTraits<T, std::enable_if_t<std::is_integral_v<T>>>
{
static inline constexpr char type_info = 'i';
static constexpr char type_info = 'i';
static std::string to_string(T v) { return std::to_string(v); }
static long from_string(G4String const& v)
{
Expand All @@ -69,7 +69,7 @@ struct UICommandTraits<T, std::enable_if_t<std::is_integral_v<T>>>
template<>
struct UICommandTraits<double>
{
static inline constexpr char type_info = 'd';
static constexpr char type_info = 'd';
static G4String to_string(double v)
{
return G4UIcommand::ConvertToString(v);
Expand Down
6 changes: 4 additions & 2 deletions src/accel/detail/HitManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ HitManager::HitManager(SPConstGeo geo,
}
}

// Hit processors *must* be allocated on the thread they're used because of
// geant4 thread-local SDs. There must be one per thread.
// Hit processors MUST be allocated on the thread they're used because of
// geant4 thread-local SDs. They MUST also be DEallocated on the same
// thread they're created due to Geant4 thread-local allocators.
// There must be one hit processor per thread.
processor_weakptrs_.resize(num_streams);
processors_.resize(num_streams);

Expand Down
2 changes: 2 additions & 0 deletions src/celeritas/ext/GeantOpticalPhysicsOptions.hh
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ struct GeantOpticalPhysicsOptions
{
//!@{
//! \name Optical photon creation physics

//! Cherenkov radiation options
CherenkovPhysicsOptions cherenkov;
//! Scintillation options
Expand All @@ -136,6 +137,7 @@ struct GeantOpticalPhysicsOptions

//!@{
//! \name Optical photon physics

//! Enable wavelength shifting and select a time profile
WLSTimeProfileSelection wavelength_shifting{WLSTimeProfileSelection::delta};
//! Enable second wavelength shifting type and select a time profile (TODO:
Expand Down
5 changes: 5 additions & 0 deletions src/celeritas/ext/GeantPhysicsOptions.hh
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ struct GeantPhysicsOptions

//!@{
//! \name Gamma physics

//! Enable Compton scattering
bool compton_scattering{true};
//! Enable the photoelectric effect
Expand All @@ -113,6 +114,7 @@ struct GeantPhysicsOptions

//!@{
//! \name Electron and positron physics

//! Enable discrete Coulomb
bool coulomb_scattering{false};
//! Enable e- and e+ ionization
Expand All @@ -132,6 +134,7 @@ struct GeantPhysicsOptions

//!@{
//! \name Physics options

//! Number of log-spaced bins per factor of 10 in energy
int em_bins_per_decade{7};
//! Enable universal energy fluctuations
Expand All @@ -144,6 +147,7 @@ struct GeantPhysicsOptions

//!@{
//! \name Cutoff options

//! Lowest energy of any EM physics process
MevEnergy min_energy{0.1 * 1e-3}; // 0.1 keV
//! Highest energy of any EM physics process
Expand All @@ -160,6 +164,7 @@ struct GeantPhysicsOptions

//!@{
//! \name Multiple scattering configuration

//! E-/e+ range factor for MSC models
double msc_range_factor{0.04};
//! Safety factor for MSC models
Expand Down
6 changes: 3 additions & 3 deletions src/celeritas/field/FieldDriverOptions.hh
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ struct FieldDriverOptions
short int max_substeps = 10;

//! Initial step tolerance
static constexpr inline real_type initial_step_tol = 1e-6;
static constexpr real_type initial_step_tol = 1e-6;

//! Chord distance fudge factor
static constexpr inline real_type dchord_tol = 1e-5 * units::millimeter;
static constexpr real_type dchord_tol = 1e-5 * units::millimeter;

//! Lowest allowable scaling factor when searching for a chord
static constexpr inline real_type min_chord_shrink = 0.5;
static constexpr real_type min_chord_shrink = 0.5;

//! Whether all data are assigned and valid
explicit CELER_FUNCTION operator bool() const
Expand Down
1 change: 1 addition & 0 deletions src/celeritas/global/KernelContextException.hh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class KernelContextException : public RichContextException

//!@{
//! \name Track accessors

//! Kernel thread ID
ThreadId thread() const { return thread_; }
//! Track slot ID
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/io/ImportElement.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct ImportIsotope
struct ImportElement
{
//!@{
//! \name type aliases
//! \name Type aliases
using IsotopeIndex = unsigned int;
using IsotopeFrac = std::pair<IsotopeIndex, double>;
using VecIsotopeFrac = std::vector<IsotopeFrac>;
Expand Down
4 changes: 1 addition & 3 deletions src/celeritas/io/ImportMaterial.hh
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ struct ImportPhysMaterial
using MapIntCutoff = std::map<PdgInt, ImportProductionCut>;
//!@}

#ifndef SWIG
static inline constexpr Index unspecified = -1;
#endif
static constexpr Index unspecified = -1;

Index geo_material_id{}; //!< Index in geo_materials list
Index optical_material_id{unspecified}; //!< Optional index in optical mat
Expand Down
4 changes: 1 addition & 3 deletions src/celeritas/io/ImportVolume.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ struct ImportVolume
using Index = unsigned int;
//!@}

#ifndef SWIG
static inline constexpr Index unspecified = -1;
#endif
static constexpr Index unspecified = -1;

Index geo_material_id{unspecified}; //!< Material defined by geometry
Index region_id{unspecified}; //!< Optional region associated
Expand Down
3 changes: 3 additions & 0 deletions src/celeritas/mat/MaterialParams.hh
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class MaterialParams final : public ParamsDataInterface<MaterialParamsData>

//!@{
//! \name Material metadata

//! Number of materials
MaterialId::size_type num_materials() const { return mat_labels_.size(); }

Expand All @@ -127,6 +128,7 @@ class MaterialParams final : public ParamsDataInterface<MaterialParamsData>

//!@{
//! \name Element metadata

//! Number of distinct elements definitions
ElementId::size_type num_elements() const { return el_labels_.size(); }

Expand All @@ -142,6 +144,7 @@ class MaterialParams final : public ParamsDataInterface<MaterialParamsData>

//!@{
//! \name Isotope metadata

//! Number of distinct isotope definitions
IsotopeId::size_type num_isotopes() const { return isot_labels_.size(); }

Expand Down
1 change: 1 addition & 0 deletions src/celeritas/optical/CoreParams.hh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class CoreParams final : public ParamsDataInterface<CoreParamsData>

//!@{
//! \name Data interface

//! Access data on the host
HostRef const& host_ref() const final { return host_ref_; }
//! Access data on the device
Expand Down
2 changes: 2 additions & 0 deletions src/celeritas/optical/detail/OffloadParams.hh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class OffloadParams final : public AuxParamsInterface,

//!@{
//! \name Aux interface

//! Short name for the action
std::string_view label() const final { return "optical-offload"; }
//! Index of this class instance in its registry
Expand All @@ -40,6 +41,7 @@ class OffloadParams final : public AuxParamsInterface,

//!@{
//! \name Data interface

//! Access data on host
HostRef const& host_ref() const final { return data_.host_ref(); }
//! Access data on device
Expand Down
3 changes: 3 additions & 0 deletions src/celeritas/optical/detail/OpticalLaunchAction.hh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class OpticalLaunchAction : public AuxParamsInterface,

//!@{
//! \name Aux/action metadata interface

//! Short name for the action
std::string_view label() const final { return "optical-offload-launch"; }
// Name of the action (for user output)
Expand All @@ -86,6 +87,7 @@ class OpticalLaunchAction : public AuxParamsInterface,

//!@{
//! \name Aux interface

//! Index of this class instance in its registry
AuxId aux_id() const final { return aux_id_; }
// Build optical core state data for a stream
Expand All @@ -94,6 +96,7 @@ class OpticalLaunchAction : public AuxParamsInterface,

//!@{
//! \name Action interface

//! ID of the model
ActionId action_id() const final { return action_id_; }
//! Dependency ordering of the action
Expand Down
Loading

0 comments on commit 05f8541

Please sign in to comment.