CMS 3D CMS Logo

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

Public Member Functions

 AlpakaTestOpaqueAdditionModule (edm::ParameterSet const &config)
 
void analyze (edm::StreamID, edm::Event const &event, edm::EventSetup const &setup) const override
 
 ~AlpakaTestOpaqueAdditionModule () override=default
 
- 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

const uint32_t size_
 

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 19 of file AlpakaTestOpaqueAdditionModule.cc.

Constructor & Destructor Documentation

◆ AlpakaTestOpaqueAdditionModule()

ALPAKA_ACCELERATOR_NAMESPACE::AlpakaTestOpaqueAdditionModule::AlpakaTestOpaqueAdditionModule ( edm::ParameterSet const &  config)
explicit

Definition at line 32 of file AlpakaTestOpaqueAdditionModule.cc.

33  : size_(config.getParameter<uint32_t>("size")) {}
Definition: config.py:1

◆ ~AlpakaTestOpaqueAdditionModule()

ALPAKA_ACCELERATOR_NAMESPACE::AlpakaTestOpaqueAdditionModule::~AlpakaTestOpaqueAdditionModule ( )
overridedefault

Member Function Documentation

◆ analyze()

void ALPAKA_ACCELERATOR_NAMESPACE::AlpakaTestOpaqueAdditionModule::analyze ( edm::StreamID  ,
edm::Event const &  event,
edm::EventSetup const &  setup 
) const
overridevirtual

Implements edm::global::EDAnalyzerBase.

Definition at line 47 of file AlpakaTestOpaqueAdditionModule.cc.

References cms::cuda::assert(), ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), gather_cfg::cout, geometryDiff::epsilon, mps_fire::i, ALPAKA_ACCELERATOR_NAMESPACE::test::opaque_add_vectors_f(), or, MillePedeFileConverter_cfg::out, and size_.

49  {
50  // require a valid Alpaka backend for running
52  if (not service or not service->enabled()) {
53  std::cout << "The " << ALPAKA_TYPE_ALIAS_NAME(AlpakaService)
54  << " is not available or disabled, the test will be skipped.\n";
55  return;
56  }
57 
58  // random number generator with a gaussian distribution
59  std::random_device rd{};
60  std::default_random_engine rand{rd()};
61  std::normal_distribution<float> dist{0., 1.};
62 
63  // tolerance
64  constexpr float epsilon = 0.000001;
65 
66  // allocate input and output host buffers
67  std::vector<float> in1(size_);
68  std::vector<float> in2(size_);
69  std::vector<float> out(size_);
70 
71  // fill the input buffers with random data, and the output buffer with zeros
72  for (uint32_t i = 0; i < size_; ++i) {
73  in1[i] = dist(rand);
74  in2[i] = dist(rand);
75  out[i] = 0.;
76  }
77 
78  // launch the 1-dimensional kernel for vector addition on the first available device
79  test::opaque_add_vectors_f(in1.data(), in2.data(), out.data(), size_);
80 
81  // check the results
82  for (uint32_t i = 0; i < size_; ++i) {
83  float sum = in1[i] + in2[i];
84  assert(out[i] < sum + epsilon);
85  assert(out[i] > sum - epsilon);
86  }
87 
88  std::cout << "All tests passed.\n";
89  }
assert(be >=bs)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
void opaque_add_vectors_f(const float *in1, const float *in2, float *out, uint32_t size)

◆ fillDescriptions()

void ALPAKA_ACCELERATOR_NAMESPACE::AlpakaTestOpaqueAdditionModule::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 35 of file AlpakaTestOpaqueAdditionModule.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), HLT_2024v14_cff::alpaka, and submitPVResolutionJobs::desc.

35  {
37  desc.add<uint32_t>("size", 1024 * 1024);
38 
39  // ignore the alpaka = cms.untracked.PSet(...) injected by the framework
41  alpaka.setAllowAnything();
42  desc.addUntracked<edm::ParameterSetDescription>("alpaka", alpaka);
43 
44  descriptions.addWithDefaultLabel(desc);
45  }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ size_

const uint32_t ALPAKA_ACCELERATOR_NAMESPACE::AlpakaTestOpaqueAdditionModule::size_
private

Definition at line 29 of file AlpakaTestOpaqueAdditionModule.cc.

Referenced by analyze().