Skip to content

Commit

Permalink
Update GPU HCAL conditions framework (cms-sw#574)
Browse files Browse the repository at this point in the history
Remove duplicate GPU-related HCAL conditions records, and simplify the package dependencies moving the remaining ones to CondFormats/DataRecord.

Improve the handling of the GPU conditions payloads:
  - use cms::cuda::device::unique_ptr to automatically deallocate the memory;
  - use edm::propagate_const_array to ensure that the conditions data are not accidentally modified by client code;
  - use cms::cuda::copyAsync(...) to simplify the copy of the conditions to the device.
  • Loading branch information
fwyzard authored and mariadalfonso committed Nov 24, 2020
1 parent 47154d8 commit 924ea6b
Show file tree
Hide file tree
Showing 36 changed files with 301 additions and 570 deletions.
19 changes: 19 additions & 0 deletions CondFormats/DataRecord/interface/HcalCombinedRecordsGPU.h
@@ -0,0 +1,19 @@
#ifndef CondFormats_DataRecord_interface_HcalCombinedRecordsGPU_h
#define CondFormats_DataRecord_interface_HcalCombinedRecordsGPU_h

#include "CondFormats/DataRecord/interface/HcalPedestalWidthsRcd.h"
#include "CondFormats/DataRecord/interface/HcalPedestalsRcd.h"
#include "CondFormats/DataRecord/interface/HcalQIEDataRcd.h"
#include "CondFormats/DataRecord/interface/HcalQIETypesRcd.h"
#include "FWCore/Framework/interface/DependentRecordImplementation.h"

template <typename... Sources>
class HcalCombinedRecord : public edm::eventsetup::DependentRecordImplementation<HcalCombinedRecord<Sources...>,
edm::mpl::Vector<Sources...>> {};

using HcalConvertedPedestalsRcd = HcalCombinedRecord<HcalPedestalsRcd, HcalQIEDataRcd, HcalQIETypesRcd>;

using HcalConvertedPedestalWidthsRcd =
HcalCombinedRecord<HcalPedestalsRcd, HcalPedestalWidthsRcd, HcalQIEDataRcd, HcalQIETypesRcd>;

#endif // CondFormats_DataRecord_interface_HcalCombinedRecordsGPU_h
@@ -1,5 +1,5 @@
#include "CondFormats/DataRecord/interface/HcalCombinedRecordsGPU.h"
#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h"
#include "CondFormats/HcalObjects/interface/HcalCombinedRecordsGPU.h"

EVENTSETUP_RECORD_REG(HcalConvertedPedestalsRcd);
EVENTSETUP_RECORD_REG(HcalConvertedPedestalWidthsRcd);
9 changes: 4 additions & 5 deletions CondFormats/HcalObjects/BuildFile.xml
@@ -1,16 +1,15 @@
<ifrelease name="_UBSAN_">
<flags REM_CXXFLAGS="-fno-omit-frame-pointer -fsanitize=undefined"/>
</ifrelease>
<use name="boost_serialization"/>
<use name="CondFormats/Serialization"/>
<use name="DataFormats/DetId"/>
<use name="DataFormats/HcalDetId"/>
<use name="Geometry/CaloTopology"/>
<use name="FWCore/Utilities"/>
<use name="FWCore/MessageLogger"/>
<use name="CondFormats/Serialization"/>
<use name="FWCore/Utilities"/>
<use name="Geometry/CaloTopology"/>
<use name="HeterogeneousCore/CUDACore"/>
<use name="HeterogeneousCore/CUDAUtilities"/>
<use name="CondFormats/DataRecord"/>
<use name="boost_serialization"/>
<export>
<lib name="1"/>
</export>
13 changes: 0 additions & 13 deletions CondFormats/HcalObjects/interface/HcalCombinedRecord.h

This file was deleted.

20 changes: 0 additions & 20 deletions CondFormats/HcalObjects/interface/HcalCombinedRecordsGPU.h

This file was deleted.

@@ -1,10 +1,12 @@
#ifndef CondFormats_HcalObjects_interface_HcalConvertedPedestalWidthsGPU_h
#define CondFormats_HcalObjects_interface_HcalConvertedPedestalWidthsGPU_h

#include "CondFormats/HcalObjects/interface/HcalPedestals.h"
#include "CondFormats/HcalObjects/interface/HcalPedestalWidths.h"
#include "CondFormats/HcalObjects/interface/HcalPedestals.h"
#include "CondFormats/HcalObjects/interface/HcalQIEData.h"
#include "CondFormats/HcalObjects/interface/HcalQIETypes.h"
#include "FWCore/Utilities/interface/propagate_const_array.h"
#include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"

#ifndef __CUDACC__
#include "HeterogeneousCore/CUDAUtilities/interface/HostAllocator.h"
Expand All @@ -14,8 +16,7 @@
class HcalConvertedPedestalWidthsGPU {
public:
struct Product {
~Product();
float* values;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> values;
};

#ifndef __CUDACC__
Expand Down
5 changes: 3 additions & 2 deletions CondFormats/HcalObjects/interface/HcalConvertedPedestalsGPU.h
Expand Up @@ -4,6 +4,8 @@
#include "CondFormats/HcalObjects/interface/HcalPedestals.h"
#include "CondFormats/HcalObjects/interface/HcalQIEData.h"
#include "CondFormats/HcalObjects/interface/HcalQIETypes.h"
#include "FWCore/Utilities/interface/propagate_const_array.h"
#include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"

#ifndef __CUDACC__
#include "HeterogeneousCore/CUDAUtilities/interface/HostAllocator.h"
Expand All @@ -13,8 +15,7 @@
class HcalConvertedPedestalsGPU {
public:
struct Product {
~Product();
float* values;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> values;
};

#ifndef __CUDACC__
Expand Down
11 changes: 6 additions & 5 deletions CondFormats/HcalObjects/interface/HcalGainWidthsGPU.h
Expand Up @@ -2,6 +2,8 @@
#define CondFormats_HcalObjects_interface_HcalGainWidthsGPU_h

#include "CondFormats/HcalObjects/interface/HcalGainWidths.h"
#include "FWCore/Utilities/interface/propagate_const_array.h"
#include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"

#ifndef __CUDACC__
#include "HeterogeneousCore/CUDAUtilities/interface/HostAllocator.h"
Expand All @@ -11,11 +13,10 @@
class HcalGainWidthsGPU {
public:
struct Product {
~Product();
float *value0;
float *value1;
float *value2;
float *value3;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> value0;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> value1;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> value2;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> value3;
};

#ifndef __CUDACC__
Expand Down
5 changes: 3 additions & 2 deletions CondFormats/HcalObjects/interface/HcalGainsGPU.h
Expand Up @@ -2,6 +2,8 @@
#define CondFormats_HcalObjects_interface_HcalGainsGPU_h

#include "CondFormats/HcalObjects/interface/HcalGains.h"
#include "FWCore/Utilities/interface/propagate_const_array.h"
#include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"

#ifndef __CUDACC__
#include "HeterogeneousCore/CUDAUtilities/interface/HostAllocator.h"
Expand All @@ -11,8 +13,7 @@
class HcalGainsGPU {
public:
struct Product {
~Product();
float* values;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> values;
};

#ifndef __CUDACC__
Expand Down
5 changes: 3 additions & 2 deletions CondFormats/HcalObjects/interface/HcalLUTCorrsGPU.h
Expand Up @@ -2,6 +2,8 @@
#define CondFormats_HcalObjects_interface_HcalLUTCorrsGPU_h

#include "CondFormats/HcalObjects/interface/HcalLUTCorrs.h"
#include "FWCore/Utilities/interface/propagate_const_array.h"
#include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"

#ifndef __CUDACC__
#include "HeterogeneousCore/CUDAUtilities/interface/HostAllocator.h"
Expand All @@ -11,8 +13,7 @@
class HcalLUTCorrsGPU {
public:
struct Product {
~Product();
float* value;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> value;
};

#ifndef __CUDACC__
Expand Down
39 changes: 34 additions & 5 deletions CondFormats/HcalObjects/interface/HcalPedestalWidthsGPU.h
Expand Up @@ -2,6 +2,8 @@
#define CondFormats_HcalObjects_interface_HcalPedestalWidthsGPU_h

#include "CondFormats/HcalObjects/interface/HcalPedestalWidths.h"
#include "FWCore/Utilities/interface/propagate_const_array.h"
#include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"

#ifndef __CUDACC__
#include "HeterogeneousCore/CUDAUtilities/interface/HostAllocator.h"
Expand All @@ -11,9 +13,22 @@
class HcalPedestalWidthsGPU {
public:
struct Product {
~Product();
float *sigma00, *sigma01, *sigma02, *sigma03, *sigma10, *sigma11, *sigma12, *sigma13, *sigma20, *sigma21, *sigma22,
*sigma23, *sigma30, *sigma31, *sigma32, *sigma33;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> sigma00;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> sigma01;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> sigma02;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> sigma03;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> sigma10;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> sigma11;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> sigma12;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> sigma13;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> sigma20;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> sigma21;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> sigma22;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> sigma23;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> sigma30;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> sigma31;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> sigma32;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> sigma33;
};

#ifndef __CUDACC__
Expand All @@ -32,8 +47,22 @@ class HcalPedestalWidthsGPU {
private:
bool unitIsADC_;
uint64_t totalChannels_;
std::vector<float, cms::cuda::HostAllocator<float>> sigma00_, sigma01_, sigma02_, sigma03_, sigma10_, sigma11_,
sigma12_, sigma13_, sigma20_, sigma21_, sigma22_, sigma23_, sigma30_, sigma31_, sigma32_, sigma33_;
std::vector<float, cms::cuda::HostAllocator<float>> sigma00_;
std::vector<float, cms::cuda::HostAllocator<float>> sigma01_;
std::vector<float, cms::cuda::HostAllocator<float>> sigma02_;
std::vector<float, cms::cuda::HostAllocator<float>> sigma03_;
std::vector<float, cms::cuda::HostAllocator<float>> sigma10_;
std::vector<float, cms::cuda::HostAllocator<float>> sigma11_;
std::vector<float, cms::cuda::HostAllocator<float>> sigma12_;
std::vector<float, cms::cuda::HostAllocator<float>> sigma13_;
std::vector<float, cms::cuda::HostAllocator<float>> sigma20_;
std::vector<float, cms::cuda::HostAllocator<float>> sigma21_;
std::vector<float, cms::cuda::HostAllocator<float>> sigma22_;
std::vector<float, cms::cuda::HostAllocator<float>> sigma23_;
std::vector<float, cms::cuda::HostAllocator<float>> sigma30_;
std::vector<float, cms::cuda::HostAllocator<float>> sigma31_;
std::vector<float, cms::cuda::HostAllocator<float>> sigma32_;
std::vector<float, cms::cuda::HostAllocator<float>> sigma33_;

cms::cuda::ESProduct<Product> product_;
#endif
Expand Down
10 changes: 6 additions & 4 deletions CondFormats/HcalObjects/interface/HcalPedestalsGPU.h
Expand Up @@ -2,6 +2,8 @@
#define CondFormats_HcalObjects_interface_HcalPedestalsGPU_h

#include "CondFormats/HcalObjects/interface/HcalPedestals.h"
#include "FWCore/Utilities/interface/propagate_const_array.h"
#include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"

#ifndef __CUDACC__
#include "HeterogeneousCore/CUDAUtilities/interface/HostAllocator.h"
Expand All @@ -11,9 +13,8 @@
class HcalPedestalsGPU {
public:
struct Product {
~Product();
float *values;
float *widths;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> values;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> widths;
};

#ifndef __CUDACC__
Expand All @@ -35,7 +36,8 @@ class HcalPedestalsGPU {
bool unitIsADC_;
uint64_t totalChannels_;
uint32_t offsetForHashes_;
std::vector<float, cms::cuda::HostAllocator<float>> values_, widths_;
std::vector<float, cms::cuda::HostAllocator<float>> values_;
std::vector<float, cms::cuda::HostAllocator<float>> widths_;

cms::cuda::ESProduct<Product> product_;
#endif
Expand Down
7 changes: 4 additions & 3 deletions CondFormats/HcalObjects/interface/HcalQIECodersGPU.h
Expand Up @@ -2,6 +2,8 @@
#define CondFormats_HcalObjects_interface_HcalQIECodersGPU_h

#include "CondFormats/HcalObjects/interface/HcalQIEData.h"
#include "FWCore/Utilities/interface/propagate_const_array.h"
#include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"

#ifndef __CUDACC__
#include "HeterogeneousCore/CUDAUtilities/interface/HostAllocator.h"
Expand All @@ -13,9 +15,8 @@ class HcalQIECodersGPU {
static constexpr uint32_t numValuesPerChannel = 16;

struct Product {
~Product();
float *offsets;
float *slopes;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> offsets;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> slopes;
};

#ifndef __CUDACC__
Expand Down
5 changes: 3 additions & 2 deletions CondFormats/HcalObjects/interface/HcalQIETypesGPU.h
Expand Up @@ -2,6 +2,8 @@
#define CondFormats_HcalObjects_interface_HcalQIETypesGPU_h

#include "CondFormats/HcalObjects/interface/HcalQIETypes.h"
#include "FWCore/Utilities/interface/propagate_const_array.h"
#include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"

#ifndef __CUDACC__
#include "HeterogeneousCore/CUDAUtilities/interface/HostAllocator.h"
Expand All @@ -11,8 +13,7 @@
class HcalQIETypesGPU {
public:
struct Product {
~Product();
int* values;
edm::propagate_const_array<cms::cuda::device::unique_ptr<int[]>> values;
};

#ifndef __CUDACC__
Expand Down
7 changes: 5 additions & 2 deletions CondFormats/HcalObjects/interface/HcalRecoParamsGPU.h
@@ -1,6 +1,9 @@
#ifndef CondFormats_HcalObjects_interface_HcalRecoParamsGPU_h
#define CondFormats_HcalObjects_interface_HcalRecoParamsGPU_h

#include "FWCore/Utilities/interface/propagate_const_array.h"
#include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"

#ifndef __CUDACC__
#include "HeterogeneousCore/CUDAUtilities/interface/HostAllocator.h"
#include "HeterogeneousCore/CUDACore/interface/ESProduct.h"
Expand All @@ -11,8 +14,8 @@ class HcalRecoParams;
class HcalRecoParamsGPU {
public:
struct Product {
~Product();
uint32_t *param1, *param2;
edm::propagate_const_array<cms::cuda::device::unique_ptr<uint32_t[]>> param1;
edm::propagate_const_array<cms::cuda::device::unique_ptr<uint32_t[]>> param2;
};

#ifndef __CUDACC__
Expand Down
5 changes: 3 additions & 2 deletions CondFormats/HcalObjects/interface/HcalRespCorrsGPU.h
Expand Up @@ -2,6 +2,8 @@
#define CondFormats_HcalObjects_interface_HcalRespCorrsGPU_h

#include "CondFormats/HcalObjects/interface/HcalRespCorrs.h"
#include "FWCore/Utilities/interface/propagate_const_array.h"
#include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"

#ifndef __CUDACC__
#include "HeterogeneousCore/CUDAUtilities/interface/HostAllocator.h"
Expand All @@ -11,8 +13,7 @@
class HcalRespCorrsGPU {
public:
struct Product {
~Product();
float* values;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> values;
};

#ifndef __CUDACC__
Expand Down
15 changes: 9 additions & 6 deletions CondFormats/HcalObjects/interface/HcalSiPMCharacteristicsGPU.h
Expand Up @@ -2,6 +2,8 @@
#define CondFormats_HcalObjects_interface_HcalSiPMCharacteristicsGPU_h

#include "CondFormats/HcalObjects/interface/HcalSiPMCharacteristics.h"
#include "FWCore/Utilities/interface/propagate_const_array.h"
#include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"

#ifndef __CUDACC__
#include "HeterogeneousCore/CUDAUtilities/interface/HostAllocator.h"
Expand All @@ -11,12 +13,13 @@
class HcalSiPMCharacteristicsGPU {
public:
struct Product {
~Product();
int *pixels;
float *parLin1, *parLin2, *parLin3;
float *crossTalk;
int *auxi1;
float *auxi2;
edm::propagate_const_array<cms::cuda::device::unique_ptr<int[]>> pixels;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> parLin1;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> parLin2;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> parLin3;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> crossTalk;
edm::propagate_const_array<cms::cuda::device::unique_ptr<int[]>> auxi1;
edm::propagate_const_array<cms::cuda::device::unique_ptr<float[]>> auxi2;
};

#ifndef __CUDACC__
Expand Down

0 comments on commit 924ea6b

Please sign in to comment.