Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Remove global variables #401

Merged
merged 24 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions SDL/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,6 @@ namespace SDL {

const unsigned int size_superbins = 45000;

// Temporary fix for endcap buffer allocation.
const unsigned int endcap_size = 9104;

// Temporary fix for module buffer allocation.
const unsigned int modules_size = 26401;
const unsigned int pix_tot = 1795336;

//defining the constant host device variables right up here
ALPAKA_STATIC_ACC_MEM_GLOBAL const float miniMulsPtScaleBarrel[6] = {0.0052, 0.0038, 0.0034, 0.0034, 0.0032, 0.0034};
ALPAKA_STATIC_ACC_MEM_GLOBAL const float miniMulsPtScaleEndcap[5] = {0.006, 0.006, 0.006, 0.006, 0.006};
Expand Down
42 changes: 21 additions & 21 deletions SDL/EndcapGeometry.cc
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
#include "EndcapGeometry.h"

SDL::EndcapGeometry<SDL::Dev>::EndcapGeometry(SDL::Dev const& devAccIn, unsigned int sizef)
: geoMapDetId_buf(allocBufWrapper<unsigned int>(devAccIn, sizef)),
geoMapPhi_buf(allocBufWrapper<float>(devAccIn, sizef)) {}

SDL::EndcapGeometry<SDL::Dev>::EndcapGeometry(SDL::Dev const& devAccIn,
SDL::QueueAcc& queue,
std::string filename,
unsigned int sizef)
: geoMapDetId_buf(allocBufWrapper<unsigned int>(devAccIn, sizef)),
geoMapPhi_buf(allocBufWrapper<float>(devAccIn, sizef)) {
load(queue, filename);
SDL::EndcapGeometryHost<SDL::Dev> const& endcapGeometryIn)
: geoMapDetId_buf(allocBufWrapper<unsigned int>(devAccIn, endcapGeometryIn.centroid_phis_.size())),
geoMapPhi_buf(allocBufWrapper<float>(devAccIn, endcapGeometryIn.centroid_phis_.size())) {
dxdy_slope_ = endcapGeometryIn.dxdy_slope_;
centroid_phis_ = endcapGeometryIn.centroid_phis_;
fillGeoMapArraysExplicit(queue);
}

void SDL::EndcapGeometry<SDL::Dev>::load(SDL::QueueAcc& queue, std::string filename) {
void SDL::EndcapGeometryHost<SDL::Dev>::load(std::string filename) {
dxdy_slope_.clear();
centroid_phis_.clear();

Expand Down Expand Up @@ -41,21 +38,11 @@ void SDL::EndcapGeometry<SDL::Dev>::load(SDL::QueueAcc& queue, std::string filen
}
}
}

fillGeoMapArraysExplicit(queue);
}

void SDL::EndcapGeometry<SDL::Dev>::fillGeoMapArraysExplicit(SDL::QueueAcc& queue) {
unsigned int phi_size = centroid_phis_.size();

// Temporary check for endcap initialization.
if (phi_size != endcap_size) {
std::cerr << "\nError: phi_size and endcap_size are not equal.\n";
std::cerr << "phi_size: " << phi_size << ", endcap_size: " << endcap_size << "\n";
std::cerr << "Please change endcap_size in Constants.h to make it equal to phi_size.\n";
throw std::runtime_error("Mismatched sizes");
}

// Allocate buffers on host
SDL::DevHost const& devHost = cms::alpakatools::host();
auto mapPhi_host_buf = allocBufWrapper<float>(devHost, phi_size);
Expand All @@ -82,4 +69,17 @@ void SDL::EndcapGeometry<SDL::Dev>::fillGeoMapArraysExplicit(SDL::QueueAcc& queu
alpaka::wait(queue);
}

float SDL::EndcapGeometry<SDL::Dev>::getdxdy_slope(unsigned int detid) { return dxdy_slope_[detid]; }
float SDL::EndcapGeometry<SDL::Dev>::getdxdy_slope(unsigned int detid) const {
if (dxdy_slope_.find(detid) != dxdy_slope_.end()) {
return dxdy_slope_.at(detid);
} else {
return 0;
}
}
float SDL::EndcapGeometryHost<SDL::Dev>::getdxdy_slope(unsigned int detid) const {
if (dxdy_slope_.find(detid) != dxdy_slope_.end()) {
return dxdy_slope_.at(detid);
} else {
return 0;
}
}
31 changes: 24 additions & 7 deletions SDL/EndcapGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,30 @@
#include "HeterogeneousCore/AlpakaInterface/interface/host.h"

namespace SDL {

// FIXME: Need to separate this better into host and device classes
// This is only needed for host, but we template it to avoid symbol conflicts
template <typename TDev>
class EndcapGeometry {};
class EndcapGeometryHost;

template <>
class EndcapGeometry<SDL::Dev> {
class EndcapGeometryHost<Dev> {
public:
std::map<unsigned int, float> dxdy_slope_; // dx/dy slope
std::map<unsigned int, float> centroid_phis_; // centroid phi

EndcapGeometryHost() = default;
~EndcapGeometryHost() = default;

void load(std::string);
float getdxdy_slope(unsigned int detid) const;
};

template <typename TDev>
class EndcapGeometry;

template <>
class EndcapGeometry<Dev> {
private:
std::map<unsigned int, float> dxdy_slope_; // dx/dy slope
std::map<unsigned int, float> centroid_phis_; // centroid phi
Expand All @@ -32,14 +52,11 @@ namespace SDL {

unsigned int nEndCapMap;

EndcapGeometry(Dev const& devAccIn, unsigned int sizef = endcap_size);
EndcapGeometry(Dev const& devAccIn, QueueAcc& queue, std::string filename, unsigned int sizef = endcap_size);
EndcapGeometry(Dev const& devAccIn, QueueAcc& queue, SDL::EndcapGeometryHost<Dev> const& endcapGeometryIn);
~EndcapGeometry() = default;

void load(QueueAcc& queue, std::string);

void fillGeoMapArraysExplicit(QueueAcc& queue);
float getdxdy_slope(unsigned int detid);
float getdxdy_slope(unsigned int detid) const;
};
} // namespace SDL

Expand Down
Loading