CMS 3D CMS Logo

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

Public Member Functions

void analyze (edm::StreamID, edm::Event const &event, edm::EventSetup const &setup) const override
 
 ROCmTestKernelAdditionModule (edm::ParameterSet const &config)
 
 ~ROCmTestKernelAdditionModule () override=default
 
- 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices 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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
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 21 of file ROCmTestKernelAdditionModule.cc.

Constructor & Destructor Documentation

◆ ROCmTestKernelAdditionModule()

ROCmTestKernelAdditionModule::ROCmTestKernelAdditionModule ( edm::ParameterSet const &  config)
explicit

Definition at line 34 of file ROCmTestKernelAdditionModule.cc.

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

◆ ~ROCmTestKernelAdditionModule()

ROCmTestKernelAdditionModule::~ROCmTestKernelAdditionModule ( )
overridedefault

Member Function Documentation

◆ analyze()

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

Implements edm::global::EDAnalyzerBase.

Definition at line 43 of file ROCmTestKernelAdditionModule.cc.

References cms::cuda::assert(), gather_cfg::cout, geometryDiff::epsilon, dqmMemoryStats::float, hipCheck, mps_fire::i, or, size_, and HeterogeneousCoreROCmTestKernelPlugins::wrapper_add_vectors_f().

43  {
44  // require ROCm for running
46  if (not rocm or not rocm->enabled()) {
47  std::cout << "The ROCmService is not available or disabled, the test will be skipped.\n";
48  return;
49  }
50 
51  // random number generator with a gaussian distribution
52  std::random_device rd{};
53  std::default_random_engine rand{rd()};
54  std::normal_distribution<float> dist{0., 1.};
55 
56  // tolerance
57  constexpr float epsilon = 0.000001;
58 
59  // allocate input and output host buffers
60  std::vector<float> in1_h(size_);
61  std::vector<float> in2_h(size_);
62  std::vector<float> out_h(size_);
63 
64  // fill the input buffers with random data, and the output buffer with zeros
65  for (size_t i = 0; i < size_; ++i) {
66  in1_h[i] = dist(rand);
67  in2_h[i] = dist(rand);
68  out_h[i] = 0.;
69  }
70 
71  // allocate input and output buffers on the device
72  float* in1_d;
73  float* in2_d;
74  float* out_d;
75  hipCheck(hipMalloc(&in1_d, size_ * sizeof(float)));
76  hipCheck(hipMalloc(&in2_d, size_ * sizeof(float)));
77  hipCheck(hipMalloc(&out_d, size_ * sizeof(float)));
78 
79  // copy the input data to the device
80  hipCheck(hipMemcpy(in1_d, in1_h.data(), size_ * sizeof(float), hipMemcpyHostToDevice));
81  hipCheck(hipMemcpy(in2_d, in2_h.data(), size_ * sizeof(float), hipMemcpyHostToDevice));
82 
83  // fill the output buffer with zeros
84  hipCheck(hipMemset(out_d, 0, size_ * sizeof(float)));
85 
86  // launch the 1-dimensional kernel for vector addition
88 
89  // copy the results from the device to the host
90  hipCheck(hipMemcpy(out_h.data(), out_d, size_ * sizeof(float), hipMemcpyDeviceToHost));
91 
92  // wait for all the operations to complete
93  hipCheck(hipDeviceSynchronize());
94 
95  // check the results
96  for (size_t i = 0; i < size_; ++i) {
97  float sum = in1_h[i] + in2_h[i];
98  assert(out_h[i] < sum + epsilon);
99  assert(out_h[i] > sum - epsilon);
100  }
101 
102  std::cout << "All tests passed.\n";
103 }
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 wrapper_add_vectors_f(const float *__restrict__ in1, const float *__restrict__ in2, float *__restrict__ out, size_t size)
#define hipCheck(ARG,...)
Definition: hipCheck.h:52

◆ fillDescriptions()

void ROCmTestKernelAdditionModule::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 37 of file ROCmTestKernelAdditionModule.cc.

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

37  {
39  desc.add<uint32_t>("size", 1024 * 1024);
40  descriptions.addWithDefaultLabel(desc);
41 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ size_

const uint32_t ROCmTestKernelAdditionModule::size_
private

Definition at line 31 of file ROCmTestKernelAdditionModule.cc.

Referenced by analyze().