File indexing completed on 2026-01-10 10:05:47
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <memory>
0010
0011 #include "corecel/Macros.hh"
0012 #include "corecel/data/AuxInterface.hh"
0013 #include "corecel/data/Collection.hh"
0014 #include "celeritas/global/ActionInterface.hh"
0015
0016 #include "GeneratorTraits.hh"
0017 #include "../GeneratorData.hh"
0018
0019 namespace celeritas
0020 {
0021 namespace optical
0022 {
0023 class MaterialParams;
0024 }
0025
0026 namespace detail
0027 {
0028
0029
0030
0031
0032 template<GeneratorType G>
0033 class OffloadAction final : public CoreStepActionInterface
0034 {
0035 public:
0036
0037
0038 using TraitsT = OffloadTraits<G>;
0039 using SPConstParams = std::shared_ptr<typename TraitsT::Params const>;
0040 using SPConstMaterial = std::shared_ptr<optical::MaterialParams const>;
0041
0042
0043
0044 struct Input
0045 {
0046 AuxId step_id;
0047 AuxId gen_id;
0048 AuxId optical_id;
0049 SPConstMaterial material;
0050 SPConstParams shared;
0051
0052 explicit operator bool() const
0053 {
0054 return step_id && gen_id && optical_id && material && shared;
0055 }
0056 };
0057
0058 public:
0059
0060 static std::shared_ptr<OffloadAction>
0061 make_and_insert(CoreParams const&, Input&&);
0062
0063
0064 OffloadAction(ActionId action_id, Input&&);
0065
0066
0067
0068
0069
0070 ActionId action_id() const final { return action_id_; }
0071
0072 std::string_view label() const final { return TraitsT::label; }
0073
0074 std::string_view description() const final { return TraitsT::description; }
0075
0076
0077
0078
0079
0080
0081 StepActionOrder order() const final { return StepActionOrder::user_post; }
0082
0083 void step(CoreParams const&, CoreStateHost&) const final;
0084
0085 void step(CoreParams const&, CoreStateDevice&) const final;
0086
0087
0088
0089
0090
0091 SPConstParams const& params() const { return data_.shared; }
0092
0093 private:
0094
0095
0096 using Executor = typename TraitsT::Executor;
0097
0098
0099
0100 ActionId action_id_;
0101 Input data_;
0102
0103
0104
0105 template<MemSpace M>
0106 void step_impl(CoreParams const&, CoreState<M>&) const;
0107
0108 void offload(CoreParams const&, CoreStateHost&) const;
0109 void offload(CoreParams const&, CoreStateDevice&) const;
0110 };
0111
0112
0113
0114
0115
0116 extern template class OffloadAction<GeneratorType::cherenkov>;
0117 extern template class OffloadAction<GeneratorType::scintillation>;
0118
0119
0120 }
0121 }