Skip to content

Commit

Permalink
Replace PortableCollection with PortableObject.
Browse files Browse the repository at this point in the history
  • Loading branch information
thomreis committed Dec 16, 2024
1 parent a3010a9 commit 5e09bb4
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 44 deletions.
16 changes: 16 additions & 0 deletions CondFormats/EcalObjects/interface/EcalRecHitParameters.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef CondFormats_EcalObjects_EcalRecHitParameters_h
#define CondFormats_EcalObjects_EcalRecHitParameters_h

#include <bitset>
#include <array>

constexpr size_t kNEcalChannelStatusCodes = 16; // The HW supports 16 channel status codes
using RecoFlagBitsArray =
std::array<uint32_t, kNEcalChannelStatusCodes>; // associate recoFlagBits to all channel status codes

struct EcalRecHitParameters {
RecoFlagBitsArray recoFlagBits;
std::bitset<kNEcalChannelStatusCodes> channelStatusCodesToBeExcluded;
};

#endif
8 changes: 3 additions & 5 deletions CondFormats/EcalObjects/interface/EcalRecHitParametersHost.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#ifndef CondFormats_EcalObjects_interface_EcalRecHitParametersHost_h
#define CondFormats_EcalObjects_interface_EcalRecHitParametersHost_h

#include "CondFormats/EcalObjects/interface/EcalRecHitParametersSoA.h"
#include "DataFormats/Portable/interface/PortableHostCollection.h"
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
#include "HeterogeneousCore/AlpakaInterface/interface/memory.h"
#include "CondFormats/EcalObjects/interface/EcalRecHitParameters.h"
#include "DataFormats/Portable/interface/PortableHostObject.h"

using EcalRecHitParametersHost = PortableHostCollection<EcalRecHitParametersSoA>;
using EcalRecHitParametersHost = PortableHostObject<EcalRecHitParameters>;

#endif
21 changes: 0 additions & 21 deletions CondFormats/EcalObjects/interface/EcalRecHitParametersSoA.h

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#ifndef CondFormats_EcalObjects_interface_alpaka_EcalRecHitParametersDevice_h
#define CondFormats_EcalObjects_interface_alpaka_EcalRecHitParametersDevice_h

#include "CondFormats/EcalObjects/interface/EcalRecHitParameters.h"
#include "CondFormats/EcalObjects/interface/EcalRecHitParametersHost.h"
#include "CondFormats/EcalObjects/interface/EcalRecHitParametersSoA.h"
#include "DataFormats/Portable/interface/alpaka/PortableCollection.h"
#include "DataFormats/Portable/interface/alpaka/PortableObject.h"
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
#include "HeterogeneousCore/AlpakaInterface/interface/memory.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE {

using ::EcalRecHitParametersHost;
using EcalRecHitParametersDevice = PortableCollection<EcalRecHitParametersSoA>;
using EcalRecHitParametersDevice = PortableObject<EcalRecHitParameters>;

} // namespace ALPAKA_ACCELERATOR_NAMESPACE

ASSERT_DEVICE_MATCHES_HOST_COLLECTION(EcalRecHitParametersDevice, EcalRecHitParametersHost);

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::rechit {
ebRecHits.view(),
eeRecHits.view(),
conditionsDev.const_view(),
parametersDev.const_view(),
parametersDev.const_data(),
eventTime,
configParams);
} else {
Expand All @@ -54,7 +54,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::rechit {
ebUncalibRecHits->const_view(),
ebRecHits.view(),
conditionsDev.const_view(),
parametersDev.const_view(),
parametersDev.const_data(),
eventTime,
configParams);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "CondFormats/EcalObjects/interface/EcalChannelStatusCode.h"
#include "CondFormats/EcalObjects/interface/EcalRecHitParametersSoA.h"
#include "CondFormats/EcalObjects/interface/EcalRecHitParameters.h"
#include "CondFormats/EcalObjects/interface/alpaka/EcalRecHitParametersDevice.h"

#include "DataFormats/EcalRecHit/interface/EcalRecHit.h"

#include "HeterogeneousCore/AlpakaCore/interface/alpaka/ESGetToken.h"
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/ESProducer.h"
#include "HeterogeneousCore/AlpakaCore/interface/alpaka/ModuleFactory.h"
Expand Down Expand Up @@ -81,13 +83,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {

std::unique_ptr<EcalRecHitParametersHost> EcalRecHitParametersESProducer::produce(
JobConfigurationGPURecord const& iRecord) {
size_t const sizeone = 1;
auto product = std::make_unique<EcalRecHitParametersHost>(sizeone, cms::alpakatools::host());
auto view = product->view();
auto product = std::make_unique<EcalRecHitParametersHost>(cms::alpakatools::host());
auto value = product->value();

std::memcpy(view.recoFlagBits().data(), recoFlagBitsArray_.data(), sizeof(uint32_t) * recoFlagBitsArray_.size());
std::memcpy(value.recoFlagBits.data(), recoFlagBitsArray_.data(), sizeof(uint32_t) * recoFlagBitsArray_.size());

view.channelStatusCodesToBeExcluded() = channelStatusCodesToBeExcluded_;
value.channelStatusCodesToBeExcluded = channelStatusCodesToBeExcluded_;

return product;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::rechit {
uint32_t* flagBits,
uint32_t* extra,
EcalRecHitConditionsDevice::ConstView conditionsDev,
EcalRecHitParametersDevice::ConstView parametersDev,
EcalRecHitParametersDevice::Product const* parametersDev,
// time, used for time dependent corrections
edm::TimeValue_t const& eventTime,
// configuration
Expand Down Expand Up @@ -160,14 +160,14 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::rechit {

auto const dbChStatus = static_cast<EcalChannelStatusCode::Code>(conditionsDev.channelStatus()[hashedId] &
EcalChannelStatusCode::chStatusMask);
auto const& exclChStatCodes = parametersDev.channelStatusCodesToBeExcluded();
auto const& exclChStatCodes = parametersDev->channelStatusCodesToBeExcluded;
if (exclChStatCodes[dbChStatus]) {
// skip the channel if the channel status bit is set and should be excluded
return;
}

// Take our association map of dbChStatuses-> recHit flagbits and return the appropriate flagbit word
auto const& recoFlagBits = parametersDev.recoFlagBits()[dbChStatus];
auto const& recoFlagBits = parametersDev->recoFlagBits[dbChStatus];
flagBits[inputCh] = recoFlagBits;

if ((flagmask & recoFlagBits) && killDeadChannels) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "CondFormats/EcalObjects/interface/alpaka/EcalRecHitParametersDevice.h"
#include "DataFormats/EcalRecHit/interface/alpaka/EcalRecHitDeviceCollection.h"
#include "DataFormats/EcalRecHit/interface/alpaka/EcalUncalibratedRecHitDeviceCollection.h"
#include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
#include "DataFormats/EcalRecHit/interface/EcalUncalibratedRecHit.h"
#include "DataFormats/Provenance/interface/Timestamp.h"

Expand Down Expand Up @@ -41,7 +42,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::rechit {
uint32_t* flagBits,
uint32_t* extra,
EcalRecHitConditionsDevice::ConstView conditionsDev,
EcalRecHitParametersDevice::ConstView parametersDev,
EcalRecHitParametersDevice::Product const* parametersDev,
// time, used for time dependent corrections
edm::TimeValue_t const& eventTime,
// configuration
Expand All @@ -60,7 +61,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::rechit {
EcalUncalibratedRecHitDeviceCollection::ConstView uncalibRecHits,
EcalRecHitDeviceCollection::View recHits,
EcalRecHitConditionsDevice::ConstView conditionsDev,
EcalRecHitParametersDevice::ConstView parametersDev,
EcalRecHitParametersDevice::Product const* parametersDev,
// time, used for time dependent corrections
edm::TimeValue_t const& eventTime,
ConfigurationParameters const& configParams) const {
Expand Down Expand Up @@ -109,7 +110,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::rechit {
EcalRecHitDeviceCollection::View ebRecHits,
EcalRecHitDeviceCollection::View eeRecHits,
EcalRecHitConditionsDevice::ConstView conditionsDev,
EcalRecHitParametersDevice::ConstView parametersDev,
EcalRecHitParametersDevice::Product const* parametersDev,
// time, used for time dependent corrections
edm::TimeValue_t const& eventTime,
ConfigurationParameters const& configParams) const {
Expand Down

0 comments on commit 5e09bb4

Please sign in to comment.