CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
TestAlpakaAnalyzer Class Reference
Inheritance diagram for TestAlpakaAnalyzer:
edm::global::EDAnalyzer<> edm::global::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (edm::StreamID sid, edm::Event const &event, edm::EventSetup const &) const override
 
 TestAlpakaAnalyzer (edm::ParameterSet const &config)
 
- Public Member Functions inherited from edm::global::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Attributes

edm::EDGetTokenT< unsigned short > backendToken_
 
std::optional< cms::alpakatools::BackendexpectBackend_
 
const int expectSize_
 
const std::vector< double > expectXvalues_
 
const edm::InputTag source_
 
const edm::EDGetTokenT< portabletest::TestHostCollectiontoken_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 83 of file TestAlpakaAnalyzer.cc.

Constructor & Destructor Documentation

◆ TestAlpakaAnalyzer()

TestAlpakaAnalyzer::TestAlpakaAnalyzer ( edm::ParameterSet const &  config)
inline

Definition at line 85 of file TestAlpakaAnalyzer.cc.

86  : source_{config.getParameter<edm::InputTag>("source")},
88  expectSize_{config.getParameter<int>("expectSize")},
89  expectXvalues_{config.getParameter<std::vector<double>>("expectXvalues")} {
90  if (std::string const& eb = config.getParameter<std::string>("expectBackend"); not eb.empty()) {
93  }
94  }
const edm::EDGetTokenT< portabletest::TestHostCollection > token_
std::optional< cms::alpakatools::Backend > expectBackend_
Definition: config.py:1
std::string const & label() const
Definition: InputTag.h:36
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::InputTag source_
edm::EDGetTokenT< unsigned short > backendToken_
Backend toBackend(std::string_view name)
Definition: Backend.cc:13
const std::vector< double > expectXvalues_
std::string const & process() const
Definition: InputTag.h:40

Member Function Documentation

◆ analyze()

void TestAlpakaAnalyzer::analyze ( edm::StreamID  sid,
edm::Event const &  event,
edm::EventSetup const &   
) const
inlineoverridevirtual

Implements edm::global::EDAnalyzerBase.

Definition at line 96 of file TestAlpakaAnalyzer.cc.

References python.cmstools::all(), cms::cuda::assert(), jetsAK4_CHS_cff::backend, backendToken_, PortableHostCollection< T >::buffer(), PortableHostCollection< T >::const_view(), edm::InputTag::encode(), Exception, expectBackend_, expectSize_, expectXvalues_, HLT_2023v12_cff::flags, mps_fire::i, makeMuonMisalignmentScenario::matrix, mps_check::msg, source_, token_, cms::alpakatools::toString(), and PortableHostCollection< T >::view().

96  {
97  portabletest::TestHostCollection const& product = event.get(token_);
98  auto const& view = product.const_view();
99  auto& mview = product.view();
100  auto const& cmview = product.view();
101 
102  if (expectSize_ >= 0 and expectSize_ != view.metadata().size()) {
103  throw cms::Exception("Assert") << "Expected input collection size " << expectSize_ << ", got "
104  << view.metadata().size();
105  }
106 
107  {
108  edm::LogInfo msg("TestAlpakaAnalyzer");
109  msg << source_.encode() << ".size() = " << view.metadata().size() << '\n';
110  msg << " data @ " << product.buffer().data() << ",\n"
111  << " x @ " << view.metadata().addressOf_x() << " = " << Column(view.x(), view.metadata().size()) << ",\n"
112  << " y @ " << view.metadata().addressOf_y() << " = " << Column(view.y(), view.metadata().size()) << ",\n"
113  << " z @ " << view.metadata().addressOf_z() << " = " << Column(view.z(), view.metadata().size()) << ",\n"
114  << " id @ " << view.metadata().addressOf_id() << " = " << Column(view.id(), view.metadata().size())
115  << ",\n"
116  << " r @ " << view.metadata().addressOf_r() << " = " << view.r() << '\n'
117  << " flags @ " << view.metadata().addressOf_flags() << " = " << Column(view.flags(), view.metadata().size())
118  << ",\n"
119  << " m @ " << view.metadata().addressOf_m() << " = { ... {" << view[1].m()(1, Eigen::indexing::all)
120  << " } ... } \n";
121  msg << std::hex << " [y - x] = 0x"
122  << reinterpret_cast<intptr_t>(view.metadata().addressOf_y()) -
123  reinterpret_cast<intptr_t>(view.metadata().addressOf_x())
124  << " [z - y] = 0x"
125  << reinterpret_cast<intptr_t>(view.metadata().addressOf_z()) -
126  reinterpret_cast<intptr_t>(view.metadata().addressOf_y())
127  << " [id - z] = 0x"
128  << reinterpret_cast<intptr_t>(view.metadata().addressOf_id()) -
129  reinterpret_cast<intptr_t>(view.metadata().addressOf_z())
130  << " [r - id] = 0x"
131  << reinterpret_cast<intptr_t>(view.metadata().addressOf_r()) -
132  reinterpret_cast<intptr_t>(view.metadata().addressOf_id())
133  << " [flags - r] = 0x"
134  << reinterpret_cast<intptr_t>(view.metadata().addressOf_flags()) -
135  reinterpret_cast<intptr_t>(view.metadata().addressOf_r())
136  << " [m - flags] = 0x"
137  << reinterpret_cast<intptr_t>(view.metadata().addressOf_m()) -
138  reinterpret_cast<intptr_t>(view.metadata().addressOf_flags());
139  }
140 
141  checkViewAddresses(view);
142  checkViewAddresses(mview);
143  checkViewAddresses(cmview);
144 
145  const portabletest::Matrix matrix{{1, 2, 3, 4, 5, 6}, {2, 4, 6, 8, 10, 12}, {3, 6, 9, 12, 15, 18}};
146  const portabletest::Array flags{{6, 4, 2, 0}};
147  assert(view.r() == 1.);
148  for (int32_t i = 0; i < view.metadata().size(); ++i) {
149  auto vi = view[i];
150  if (not expectXvalues_.empty() and vi.x() != expectXvalues_[i % expectXvalues_.size()]) {
151  throw cms::Exception("Assert") << "Index " << i << " expected value "
152  << expectXvalues_[i % expectXvalues_.size()] << ", got " << vi.x();
153  }
154  assert(vi.y() == 0.);
155  assert(vi.z() == 0.);
156  assert(vi.id() == i);
157  assert(vi.flags() == flags);
158  assert(vi.m() == matrix * i);
159  }
160 
161  if (expectBackend_) {
162  auto backend = static_cast<cms::alpakatools::Backend>(event.get(backendToken_));
163  if (expectBackend_ != backend) {
164  throw cms::Exception("Assert") << "Expected input backend " << cms::alpakatools::toString(*expectBackend_)
165  << ", got " << cms::alpakatools::toString(backend);
166  }
167  }
168  }
const edm::EDGetTokenT< portabletest::TestHostCollection > token_
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
std::string encode() const
Definition: InputTag.cc:159
Eigen::Matrix< double, 3, 6 > Matrix
Definition: TestSoA.h:19
std::optional< cms::alpakatools::Backend > expectBackend_
assert(be >=bs)
ConstView const & const_view() const
const edm::InputTag source_
std::string_view toString(Backend backend)
Definition: Backend.cc:24
edm::EDGetTokenT< unsigned short > backendToken_
const std::vector< double > expectXvalues_
tuple msg
Definition: mps_check.py:286

◆ fillDescriptions()

static void TestAlpakaAnalyzer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 170 of file TestAlpakaAnalyzer.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

170  {
172  desc.add<edm::InputTag>("source");
173  desc.add<int>("expectSize", -1)
174  ->setComment("Expected size of the input collection. Values < 0 mean the check is not performed. Default: -1");
175  desc.add<std::vector<double>>("expectXvalues", std::vector<double>(0.))
176  ->setComment(
177  "Expected values of the 'x' field in the input collection. Empty value means to not perform the check. If "
178  "input collection has more elements than this parameter, the parameter values are looped over. Default: "
179  "{0.}");
180  desc.add<std::string>("expectBackend", "")
181  ->setComment(
182  "Expected backend of the input collection. Empty value means to not perform the check. Default: empty "
183  "string");
184  descriptions.addWithDefaultLabel(desc);
185  }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ backendToken_

edm::EDGetTokenT<unsigned short> TestAlpakaAnalyzer::backendToken_
private

Definition at line 190 of file TestAlpakaAnalyzer.cc.

Referenced by analyze().

◆ expectBackend_

std::optional<cms::alpakatools::Backend> TestAlpakaAnalyzer::expectBackend_
private

Definition at line 191 of file TestAlpakaAnalyzer.cc.

Referenced by analyze().

◆ expectSize_

const int TestAlpakaAnalyzer::expectSize_
private

Definition at line 192 of file TestAlpakaAnalyzer.cc.

Referenced by analyze().

◆ expectXvalues_

const std::vector<double> TestAlpakaAnalyzer::expectXvalues_
private

Definition at line 193 of file TestAlpakaAnalyzer.cc.

Referenced by analyze().

◆ source_

const edm::InputTag TestAlpakaAnalyzer::source_
private

◆ token_

const edm::EDGetTokenT<portabletest::TestHostCollection> TestAlpakaAnalyzer::token_
private

Definition at line 189 of file TestAlpakaAnalyzer.cc.

Referenced by analyze().