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 noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
bool wantsStreamLuminosityBlocks () const noexcept final
 
bool wantsStreamRuns () const noexcept 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_
 
const edm::EDGetTokenT< portabletest::TestHostMultiCollection2tokenMulti2_
 
const edm::EDGetTokenT< portabletest::TestHostMultiCollection3tokenMulti3_
 

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 127 of file TestAlpakaAnalyzer.cc.

Constructor & Destructor Documentation

◆ TestAlpakaAnalyzer()

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

Definition at line 129 of file TestAlpakaAnalyzer.cc.

130  : source_{config.getParameter<edm::InputTag>("source")},
132  //tokenMulti_{consumes(source_)},
135  expectSize_{config.getParameter<int>("expectSize")},
136  expectXvalues_{config.getParameter<std::vector<double>>("expectXvalues")} {
137  if (std::string const& eb = config.getParameter<std::string>("expectBackend"); not eb.empty()) {
140  }
141  }
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_
const edm::EDGetTokenT< portabletest::TestHostMultiCollection2 > tokenMulti2_
edm::EDGetTokenT< unsigned short > backendToken_
Backend toBackend(std::string_view name)
Definition: Backend.cc:13
const std::vector< double > expectXvalues_
const edm::EDGetTokenT< portabletest::TestHostMultiCollection3 > tokenMulti3_
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 143 of file TestAlpakaAnalyzer.cc.

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

143  {
144  portabletest::TestHostCollection const& product = event.get(token_);
145  auto const& view = product.const_view();
146  auto& mview = product.view();
147  auto const& cmview = product.view();
148 
149  if (expectSize_ >= 0 and expectSize_ != view.metadata().size()) {
150  throw cms::Exception("Assert") << "Expected input collection size " << expectSize_ << ", got "
151  << view.metadata().size();
152  }
153 
154  {
155  edm::LogInfo msg("TestAlpakaAnalyzer");
156  msg << source_.encode() << ".size() = " << view.metadata().size() << '\n';
157  msg << " data @ " << product.buffer().data() << ",\n"
158  << " x @ " << view.metadata().addressOf_x() << " = " << Column(view.x(), view.metadata().size()) << ",\n"
159  << " y @ " << view.metadata().addressOf_y() << " = " << Column(view.y(), view.metadata().size()) << ",\n"
160  << " z @ " << view.metadata().addressOf_z() << " = " << Column(view.z(), view.metadata().size()) << ",\n"
161  << " id @ " << view.metadata().addressOf_id() << " = " << Column(view.id(), view.metadata().size())
162  << ",\n"
163  << " r @ " << view.metadata().addressOf_r() << " = " << view.r() << '\n'
164  << " flags @ " << view.metadata().addressOf_flags() << " = " << Column(view.flags(), view.metadata().size())
165  << ",\n"
166  << " m @ " << view.metadata().addressOf_m() << " = { ... {" << view[1].m()(1, Eigen::indexing::all)
167  << " } ... } \n";
168  msg << std::hex << " [y - x] = 0x"
169  << reinterpret_cast<intptr_t>(view.metadata().addressOf_y()) -
170  reinterpret_cast<intptr_t>(view.metadata().addressOf_x())
171  << " [z - y] = 0x"
172  << reinterpret_cast<intptr_t>(view.metadata().addressOf_z()) -
173  reinterpret_cast<intptr_t>(view.metadata().addressOf_y())
174  << " [id - z] = 0x"
175  << reinterpret_cast<intptr_t>(view.metadata().addressOf_id()) -
176  reinterpret_cast<intptr_t>(view.metadata().addressOf_z())
177  << " [r - id] = 0x"
178  << reinterpret_cast<intptr_t>(view.metadata().addressOf_r()) -
179  reinterpret_cast<intptr_t>(view.metadata().addressOf_id())
180  << " [flags - r] = 0x"
181  << reinterpret_cast<intptr_t>(view.metadata().addressOf_flags()) -
182  reinterpret_cast<intptr_t>(view.metadata().addressOf_r())
183  << " [m - flags] = 0x"
184  << reinterpret_cast<intptr_t>(view.metadata().addressOf_m()) -
185  reinterpret_cast<intptr_t>(view.metadata().addressOf_flags());
186  }
187 
188  checkViewAddresses(view);
189  checkViewAddresses(mview);
190  checkViewAddresses(cmview);
191 
192  const portabletest::Matrix matrix{{1, 2, 3, 4, 5, 6}, {2, 4, 6, 8, 10, 12}, {3, 6, 9, 12, 15, 18}};
193  const portabletest::Array flags{{6, 4, 2, 0}};
194  assert(view.r() == 1.);
195  for (int32_t i = 0; i < view.metadata().size(); ++i) {
196  auto vi = view[i];
197  if (not expectXvalues_.empty() and vi.x() != expectXvalues_[i % expectXvalues_.size()]) {
198  throw cms::Exception("Assert") << "Index " << i << " expected value "
199  << expectXvalues_[i % expectXvalues_.size()] << ", got " << vi.x();
200  }
201  assert(vi.y() == 0.);
202  assert(vi.z() == 0.);
203  assert(vi.id() == i);
204  assert(vi.flags() == flags);
205  assert(vi.m() == matrix * i);
206  }
207 
208  if (expectBackend_) {
209  auto backend = static_cast<cms::alpakatools::Backend>(event.get(backendToken_));
210  if (expectBackend_ != backend) {
211  throw cms::Exception("Assert") << "Expected input backend " << cms::alpakatools::toString(*expectBackend_)
212  << ", got " << cms::alpakatools::toString(backend);
213  }
214  }
215 
216  // portabletest::TestHostMultiCollection const& productMulti = event.get(tokenMulti_);
217  // auto const& viewMulti0 = productMulti.const_view<0>();
218  // auto& mviewMulti0 = productMulti.view<0>();
219  // auto const& cmviewMulti0 = productMulti.view<0>();
220  // auto const& viewMulti1 = productMulti.const_view<1>();
221  // auto& mviewMulti1 = productMulti.view<1>();
222  // auto const& cmviewMulti1 = productMulti.view<1>();
223 
224  portabletest::TestHostMultiCollection2 const& productMulti2 = event.get(tokenMulti2_);
225  auto const& viewMulti2_0 = productMulti2.const_view<0>();
226  auto& mviewMulti2_0 = productMulti2.view<0>();
227  auto const& cmviewMulti2_0 = productMulti2.view<0>();
228  auto const& viewMulti2_1 = productMulti2.const_view<1>();
229  auto& mviewMulti2_1 = productMulti2.view<1>();
230  auto const& cmviewMulti2_1 = productMulti2.view<1>();
231 
232  checkViewAddresses(viewMulti2_0);
233  checkViewAddresses(mviewMulti2_0);
234  checkViewAddresses(cmviewMulti2_0);
235  checkViewAddresses2(viewMulti2_1);
236  checkViewAddresses2(mviewMulti2_1);
237  checkViewAddresses2(cmviewMulti2_1);
238 
239  assert(viewMulti2_0.r() == 1.);
240  for (int32_t i = 0; i < viewMulti2_0.metadata().size(); ++i) {
241  auto vi = viewMulti2_0[i];
242  // std::stringstream s;
243  // s << "i=" << i << " x=" << vi.x() << " y=" << vi.y() << " z=" << vi.z() << " id=" << vi.id() << "'\nm=" << vi.m();
244  // std::cout << s.str() << std::endl;
245  if (not expectXvalues_.empty() and vi.x() != expectXvalues_[i % expectXvalues_.size()]) {
246  throw cms::Exception("Assert") << "Index " << i << " expected value "
247  << expectXvalues_[i % expectXvalues_.size()] << ", got " << vi.x();
248  }
249  //assert(vi.x() == 0.);
250  assert(vi.y() == 0.);
251  assert(vi.z() == 0.);
252  assert(vi.id() == i);
253  assert(vi.m() == matrix * i);
254  }
255  assert(viewMulti2_1.r2() == 2.);
256  for (int32_t i = 0; i < viewMulti2_1.metadata().size(); ++i) {
257  auto vi = viewMulti2_1[i];
258  if (not expectXvalues_.empty() and vi.x2() != expectXvalues_[i % expectXvalues_.size()]) {
259  throw cms::Exception("Assert") << "Index " << i << " expected value "
260  << expectXvalues_[i % expectXvalues_.size()] << ", got " << vi.x2();
261  }
262  assert(vi.y2() == 0.);
263  assert(vi.z2() == 0.);
264  assert(vi.id2() == i);
265  assert(vi.m2() == matrix * i);
266  }
267 
268  portabletest::TestHostMultiCollection3 const& productMulti3 = event.get(tokenMulti3_);
269  auto const& viewMulti3_0 = productMulti3.const_view<0>();
270  auto& mviewMulti3_0 = productMulti3.view<0>();
271  auto const& cmviewMulti3_0 = productMulti3.view<0>();
272  auto const& viewMulti3_1 = productMulti3.const_view<1>();
273  auto& mviewMulti3_1 = productMulti3.view<1>();
274  auto const& cmviewMulti3_1 = productMulti3.view<1>();
275  auto const& viewMulti3_2 = productMulti3.const_view<2>();
276  auto& mviewMulti3_2 = productMulti3.view<2>();
277  auto const& cmviewMulti3_2 = productMulti3.view<2>();
278 
279  checkViewAddresses(viewMulti3_0);
280  checkViewAddresses(mviewMulti3_0);
281  checkViewAddresses(cmviewMulti3_0);
282  checkViewAddresses2(viewMulti3_1);
283  checkViewAddresses2(mviewMulti3_1);
284  checkViewAddresses2(cmviewMulti3_1);
285  checkViewAddresses3(viewMulti3_2);
286  checkViewAddresses3(mviewMulti3_2);
287  checkViewAddresses3(cmviewMulti3_2);
288 
289  assert(viewMulti3_0.r() == 1.);
290  for (int32_t i = 0; i < viewMulti3_0.metadata().size(); ++i) {
291  auto vi = viewMulti3_0[i];
292  if (not expectXvalues_.empty() and vi.x() != expectXvalues_[i % expectXvalues_.size()]) {
293  throw cms::Exception("Assert") << "Index " << i << " expected value "
294  << expectXvalues_[i % expectXvalues_.size()] << ", got " << vi.x();
295  }
296  assert(vi.y() == 0.);
297  assert(vi.z() == 0.);
298  assert(vi.id() == i);
299  assert(vi.m() == matrix * i);
300  }
301  assert(viewMulti3_1.r2() == 2.);
302  for (int32_t i = 0; i < viewMulti3_1.metadata().size(); ++i) {
303  auto vi = viewMulti3_1[i];
304  if (not expectXvalues_.empty() and vi.x2() != expectXvalues_[i % expectXvalues_.size()]) {
305  throw cms::Exception("Assert") << "Index " << i << " expected value "
306  << expectXvalues_[i % expectXvalues_.size()] << ", got " << vi.x2();
307  }
308  assert(vi.y2() == 0.);
309  assert(vi.z2() == 0.);
310  assert(vi.id2() == i);
311  assert(vi.m2() == matrix * i);
312  }
313 
314  assert(viewMulti3_2.r3() == 3.);
315  for (int32_t i = 0; i < viewMulti3_2.metadata().size(); ++i) {
316  auto vi = viewMulti3_2[i];
317  if (not expectXvalues_.empty() and vi.x3() != expectXvalues_[i % expectXvalues_.size()]) {
318  throw cms::Exception("Assert") << "Index " << i << " expected value "
319  << expectXvalues_[i % expectXvalues_.size()] << ", got " << vi.x3();
320  }
321  assert(vi.y3() == 0.);
322  assert(vi.z3() == 0.);
323  assert(vi.id3() == i);
324  assert(vi.m3() == matrix * i);
325  }
326  }
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
const edm::EDGetTokenT< portabletest::TestHostMultiCollection2 > tokenMulti2_
edm::EDGetTokenT< unsigned short > backendToken_
const std::vector< double > expectXvalues_
tuple msg
Definition: mps_check.py:286
const edm::EDGetTokenT< portabletest::TestHostMultiCollection3 > tokenMulti3_
ConstView< Idx > const & const_view() const

◆ fillDescriptions()

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

Definition at line 328 of file TestAlpakaAnalyzer.cc.

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

328  {
330  desc.add<edm::InputTag>("source");
331  desc.add<int>("expectSize", -1)
332  ->setComment("Expected size of the input collection. Values < 0 mean the check is not performed. Default: -1");
333  desc.add<std::vector<double>>("expectXvalues", std::vector<double>(0.))
334  ->setComment(
335  "Expected values of the 'x' field in the input collection. Empty value means to not perform the check. If "
336  "input collection has more elements than this parameter, the parameter values are looped over. Default: "
337  "{0.}");
338  desc.add<std::string>("expectBackend", "")
339  ->setComment(
340  "Expected backend of the input collection. Empty value means to not perform the check. Default: empty "
341  "string");
342  descriptions.addWithDefaultLabel(desc);
343  }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ backendToken_

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

Definition at line 348 of file TestAlpakaAnalyzer.cc.

Referenced by analyze().

◆ expectBackend_

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

Definition at line 349 of file TestAlpakaAnalyzer.cc.

Referenced by analyze().

◆ expectSize_

const int TestAlpakaAnalyzer::expectSize_
private

Definition at line 353 of file TestAlpakaAnalyzer.cc.

Referenced by analyze().

◆ expectXvalues_

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

Definition at line 354 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 347 of file TestAlpakaAnalyzer.cc.

Referenced by analyze().

◆ tokenMulti2_

const edm::EDGetTokenT<portabletest::TestHostMultiCollection2> TestAlpakaAnalyzer::tokenMulti2_
private

Definition at line 351 of file TestAlpakaAnalyzer.cc.

Referenced by analyze().

◆ tokenMulti3_

const edm::EDGetTokenT<portabletest::TestHostMultiCollection3> TestAlpakaAnalyzer::tokenMulti3_
private

Definition at line 352 of file TestAlpakaAnalyzer.cc.

Referenced by analyze().