forked from cms-patatrack/pixeltrack-standalone
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cudacompat] Run everything on CPU via cudacompat
- Loading branch information
Showing
25 changed files
with
508 additions
and
442 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "CUDADataFormats/SiPixelClustersSoA.h" | ||
|
||
SiPixelClustersSoA::SiPixelClustersSoA(size_t maxClusters) { | ||
moduleStart_d = std::make_unique<uint32_t[]>(maxClusters + 1); | ||
clusInModule_d = std::make_unique<uint32_t[]>(maxClusters); | ||
moduleId_d = std::make_unique<uint32_t[]>(maxClusters); | ||
clusModuleStart_d = std::make_unique<uint32_t[]>(maxClusters + 1); | ||
|
||
auto view = std::make_unique<DeviceConstView>(); | ||
view->moduleStart_ = moduleStart_d.get(); | ||
view->clusInModule_ = clusInModule_d.get(); | ||
view->moduleId_ = moduleId_d.get(); | ||
view->clusModuleStart_ = clusModuleStart_d.get(); | ||
|
||
view_d = std::move(view); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#ifndef CUDADataFormats_SiPixelCluster_interface_SiPixelClustersSoA_h | ||
#define CUDADataFormats_SiPixelCluster_interface_SiPixelClustersSoA_h | ||
|
||
#include "CUDACore/cudaCompat.h" | ||
#include "CUDADataFormats/SiPixelClustersCUDA.h" | ||
|
||
#include <memory> | ||
|
||
class SiPixelClustersSoA { | ||
public: | ||
SiPixelClustersSoA() = default; | ||
explicit SiPixelClustersSoA(size_t maxClusters); | ||
~SiPixelClustersSoA() = default; | ||
|
||
SiPixelClustersSoA(const SiPixelClustersSoA &) = delete; | ||
SiPixelClustersSoA &operator=(const SiPixelClustersSoA &) = delete; | ||
SiPixelClustersSoA(SiPixelClustersSoA &&) = default; | ||
SiPixelClustersSoA &operator=(SiPixelClustersSoA &&) = default; | ||
|
||
void setNClusters(uint32_t nClusters) { nClusters_h = nClusters; } | ||
|
||
uint32_t nClusters() const { return nClusters_h; } | ||
|
||
uint32_t *moduleStart() { return moduleStart_d.get(); } | ||
uint32_t *clusInModule() { return clusInModule_d.get(); } | ||
uint32_t *moduleId() { return moduleId_d.get(); } | ||
uint32_t *clusModuleStart() { return clusModuleStart_d.get(); } | ||
|
||
uint32_t const *moduleStart() const { return moduleStart_d.get(); } | ||
uint32_t const *clusInModule() const { return clusInModule_d.get(); } | ||
uint32_t const *moduleId() const { return moduleId_d.get(); } | ||
uint32_t const *clusModuleStart() const { return clusModuleStart_d.get(); } | ||
|
||
uint32_t const *c_moduleStart() const { return moduleStart_d.get(); } | ||
uint32_t const *c_clusInModule() const { return clusInModule_d.get(); } | ||
uint32_t const *c_moduleId() const { return moduleId_d.get(); } | ||
uint32_t const *c_clusModuleStart() const { return clusModuleStart_d.get(); } | ||
|
||
using DeviceConstView = SiPixelClustersCUDA::DeviceConstView; | ||
|
||
DeviceConstView *view() const { return view_d.get(); } | ||
|
||
private: | ||
std::unique_ptr<uint32_t[]> moduleStart_d; // index of the first pixel of each module | ||
std::unique_ptr<uint32_t[]> clusInModule_d; // number of clusters found in each module | ||
std::unique_ptr<uint32_t[]> moduleId_d; // module id of each module | ||
|
||
// originally from rechits | ||
std::unique_ptr<uint32_t[]> clusModuleStart_d; // index of the first cluster of each module | ||
|
||
std::unique_ptr<DeviceConstView> view_d; // "me" pointer | ||
|
||
uint32_t nClusters_h; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "CUDADataFormats/SiPixelDigiErrorsSoA.h" | ||
|
||
#include <cassert> | ||
#include <cstring> | ||
|
||
SiPixelDigiErrorsSoA::SiPixelDigiErrorsSoA(size_t maxFedWords, PixelFormatterErrors errors) | ||
: formatterErrors_h(std::move(errors)) { | ||
error_d = std::make_unique<cms::cuda::SimpleVector<PixelErrorCompact>>(); | ||
data_d = std::make_unique<PixelErrorCompact[]>(maxFedWords); | ||
|
||
std::memset(data_d.get(), 0x00, maxFedWords); | ||
|
||
error_d = std::make_unique<cms::cuda::SimpleVector<PixelErrorCompact>>(); | ||
cms::cuda::make_SimpleVector(error_d.get(), maxFedWords, data_d.get()); | ||
assert(error_d->empty()); | ||
assert(error_d->capacity() == static_cast<int>(maxFedWords)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef CUDADataFormats_SiPixelDigi_interface_SiPixelDigiErrorsSoA_h | ||
#define CUDADataFormats_SiPixelDigi_interface_SiPixelDigiErrorsSoA_h | ||
|
||
#include <memory> | ||
|
||
#include "CUDACore/SimpleVector.h" | ||
#include "DataFormats/PixelErrors.h" | ||
|
||
class SiPixelDigiErrorsSoA { | ||
public: | ||
SiPixelDigiErrorsSoA() = default; | ||
explicit SiPixelDigiErrorsSoA(size_t maxFedWords, PixelFormatterErrors errors); | ||
~SiPixelDigiErrorsSoA() = default; | ||
|
||
SiPixelDigiErrorsSoA(const SiPixelDigiErrorsSoA&) = delete; | ||
SiPixelDigiErrorsSoA& operator=(const SiPixelDigiErrorsSoA&) = delete; | ||
SiPixelDigiErrorsSoA(SiPixelDigiErrorsSoA&&) = default; | ||
SiPixelDigiErrorsSoA& operator=(SiPixelDigiErrorsSoA&&) = default; | ||
|
||
const PixelFormatterErrors& formatterErrors() const { return formatterErrors_h; } | ||
|
||
cms::cuda::SimpleVector<PixelErrorCompact>* error() { return error_d.get(); } | ||
cms::cuda::SimpleVector<PixelErrorCompact> const* error() const { return error_d.get(); } | ||
cms::cuda::SimpleVector<PixelErrorCompact> const* c_error() const { return error_d.get(); } | ||
|
||
private: | ||
std::unique_ptr<PixelErrorCompact[]> data_d; | ||
std::unique_ptr<cms::cuda::SimpleVector<PixelErrorCompact>> error_d; | ||
PixelFormatterErrors formatterErrors_h; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "CUDADataFormats/SiPixelDigisSoA.h" | ||
|
||
SiPixelDigisSoA::SiPixelDigisSoA(size_t maxFedWords) { | ||
xx_d = std::make_unique<uint16_t[]>(maxFedWords); | ||
yy_d = std::make_unique<uint16_t[]>(maxFedWords); | ||
adc_d = std::make_unique<uint16_t[]>(maxFedWords); | ||
moduleInd_d = std::make_unique<uint16_t[]>(maxFedWords); | ||
clus_d = std::make_unique<int32_t[]>(maxFedWords); | ||
|
||
pdigi_d = std::make_unique<uint32_t[]>(maxFedWords); | ||
rawIdArr_d = std::make_unique<uint32_t[]>(maxFedWords); | ||
|
||
auto view = std::make_unique<DeviceConstView>(); | ||
view->xx_ = xx_d.get(); | ||
view->yy_ = yy_d.get(); | ||
view->adc_ = adc_d.get(); | ||
view->moduleInd_ = moduleInd_d.get(); | ||
view->clus_ = clus_d.get(); | ||
|
||
view_d = std::move(view); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#ifndef CUDADataFormats_SiPixelDigi_interface_SiPixelDigisSoA_h | ||
#define CUDADataFormats_SiPixelDigi_interface_SiPixelDigisSoA_h | ||
|
||
#include "CUDACore/cudaCompat.h" | ||
#include "CUDADataFormats/SiPixelDigisCUDA.h" | ||
|
||
#include <memory> | ||
|
||
class SiPixelDigisSoA { | ||
public: | ||
SiPixelDigisSoA() = default; | ||
explicit SiPixelDigisSoA(size_t maxFedWords); | ||
~SiPixelDigisSoA() = default; | ||
|
||
SiPixelDigisSoA(const SiPixelDigisSoA &) = delete; | ||
SiPixelDigisSoA &operator=(const SiPixelDigisSoA &) = delete; | ||
SiPixelDigisSoA(SiPixelDigisSoA &&) = default; | ||
SiPixelDigisSoA &operator=(SiPixelDigisSoA &&) = default; | ||
|
||
void setNModulesDigis(uint32_t nModules, uint32_t nDigis) { | ||
nModules_h = nModules; | ||
nDigis_h = nDigis; | ||
} | ||
|
||
uint32_t nModules() const { return nModules_h; } | ||
uint32_t nDigis() const { return nDigis_h; } | ||
|
||
uint16_t *xx() { return xx_d.get(); } | ||
uint16_t *yy() { return yy_d.get(); } | ||
uint16_t *adc() { return adc_d.get(); } | ||
uint16_t *moduleInd() { return moduleInd_d.get(); } | ||
int32_t *clus() { return clus_d.get(); } | ||
uint32_t *pdigi() { return pdigi_d.get(); } | ||
uint32_t *rawIdArr() { return rawIdArr_d.get(); } | ||
|
||
uint16_t const *xx() const { return xx_d.get(); } | ||
uint16_t const *yy() const { return yy_d.get(); } | ||
uint16_t const *adc() const { return adc_d.get(); } | ||
uint16_t const *moduleInd() const { return moduleInd_d.get(); } | ||
int32_t const *clus() const { return clus_d.get(); } | ||
uint32_t const *pdigi() const { return pdigi_d.get(); } | ||
uint32_t const *rawIdArr() const { return rawIdArr_d.get(); } | ||
|
||
uint16_t const *c_xx() const { return xx_d.get(); } | ||
uint16_t const *c_yy() const { return yy_d.get(); } | ||
uint16_t const *c_adc() const { return adc_d.get(); } | ||
uint16_t const *c_moduleInd() const { return moduleInd_d.get(); } | ||
int32_t const *c_clus() const { return clus_d.get(); } | ||
uint32_t const *c_pdigi() const { return pdigi_d.get(); } | ||
uint32_t const *c_rawIdArr() const { return rawIdArr_d.get(); } | ||
|
||
using DeviceConstView = SiPixelDigisCUDA::DeviceConstView; | ||
|
||
const DeviceConstView *view() const { return view_d.get(); } | ||
|
||
private: | ||
// These are consumed by downstream device code | ||
std::unique_ptr<uint16_t[]> xx_d; // local coordinates of each pixel | ||
std::unique_ptr<uint16_t[]> yy_d; // | ||
std::unique_ptr<uint16_t[]> adc_d; // ADC of each pixel | ||
std::unique_ptr<uint16_t[]> moduleInd_d; // module id of each pixel | ||
std::unique_ptr<int32_t[]> clus_d; // cluster id of each pixel | ||
std::unique_ptr<DeviceConstView> view_d; // "me" pointer | ||
|
||
// These are for CPU output; should we (eventually) place them to a | ||
// separate product? | ||
std::unique_ptr<uint32_t[]> pdigi_d; | ||
std::unique_ptr<uint32_t[]> rawIdArr_d; | ||
|
||
uint32_t nModules_h = 0; | ||
uint32_t nDigis_h = 0; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "DataFormats/BeamSpotPOD.h" | ||
#include "Framework/EDProducer.h" | ||
#include "Framework/Event.h" | ||
#include "Framework/EventSetup.h" | ||
#include "Framework/PluginFactory.h" | ||
|
||
class BeamSpotToPOD : public edm::EDProducer { | ||
public: | ||
explicit BeamSpotToPOD(edm::ProductRegistry& reg); | ||
~BeamSpotToPOD() override = default; | ||
|
||
void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override; | ||
|
||
private: | ||
const edm::EDPutTokenT<BeamSpotPOD> bsPutToken_; | ||
}; | ||
|
||
BeamSpotToPOD::BeamSpotToPOD(edm::ProductRegistry& reg) : bsPutToken_{reg.produces<BeamSpotPOD>()} {} | ||
|
||
void BeamSpotToPOD::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { | ||
iEvent.emplace(bsPutToken_, iSetup.get<BeamSpotPOD>()); | ||
} | ||
|
||
DEFINE_FWK_MODULE(BeamSpotToPOD); |
Oops, something went wrong.