Skip to content

Commit

Permalink
Removed alpaka functions from host ES code
Browse files Browse the repository at this point in the history
  • Loading branch information
ariostas committed Jul 31, 2024
1 parent ecd8e3e commit 0bcb06c
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 207 deletions.
22 changes: 10 additions & 12 deletions RecoTracker/LSTCore/interface/LSTESData.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ namespace lst {
uint16_t nLowerModules;
unsigned int nPixels;
unsigned int nEndCapMap;
std::shared_ptr<const ModulesBuffer<TDev>> modulesBuffers;
std::shared_ptr<const EndcapGeometryBuffer<TDev>> endcapGeometryBuffers;
ModulesBuffer<TDev> modulesBuffers;
EndcapGeometryBuffer<TDev> endcapGeometryBuffers;
std::shared_ptr<const PixelMap> pixelMapping;

LSTESData(uint16_t const& nModulesIn,
uint16_t const& nLowerModulesIn,
unsigned int const& nPixelsIn,
unsigned int const& nEndCapMapIn,
std::shared_ptr<const ModulesBuffer<TDev>> const& modulesBuffersIn,
std::shared_ptr<const EndcapGeometryBuffer<TDev>> const& endcapGeometryBuffersIn,
ModulesBuffer<TDev> const& modulesBuffersIn,
EndcapGeometryBuffer<TDev> const& endcapGeometryBuffersIn,
std::shared_ptr<const PixelMap> const& pixelMappingIn)
: nModules(nModulesIn),
nLowerModules(nLowerModulesIn),
Expand All @@ -49,19 +49,17 @@ namespace cms::alpakatools {
template <typename TQueue>
static lst::LSTESData<alpaka::Dev<TQueue>> copyAsync(TQueue& queue,
lst::LSTESData<alpaka_common::DevHost> const& srcData) {
auto deviceModulesBuffers = std::make_shared<lst::ModulesBuffer<alpaka::Dev<TQueue>>>(
alpaka::getDev(queue), srcData.nModules, srcData.nPixels);
deviceModulesBuffers->copyFromSrc(queue, *srcData.modulesBuffers);
auto deviceEndcapGeometryBuffers =
std::make_shared<lst::EndcapGeometryBuffer<alpaka::Dev<TQueue>>>(alpaka::getDev(queue), srcData.nEndCapMap);
deviceEndcapGeometryBuffers->copyFromSrc(queue, *srcData.endcapGeometryBuffers);
auto deviceModulesBuffers = lst::ModulesBuffer<alpaka::Dev<TQueue>>(alpaka::getDev(queue), srcData.nModules, srcData.nPixels);
deviceModulesBuffers.copyFromSrc(queue, srcData.modulesBuffers);
auto deviceEndcapGeometryBuffers = lst::EndcapGeometryBuffer<alpaka::Dev<TQueue>>(alpaka::getDev(queue), srcData.nEndCapMap);
deviceEndcapGeometryBuffers.copyFromSrc(queue, srcData.endcapGeometryBuffers);

return lst::LSTESData<alpaka::Dev<TQueue>>(srcData.nModules,
srcData.nLowerModules,
srcData.nPixels,
srcData.nEndCapMap,
deviceModulesBuffers,
deviceEndcapGeometryBuffers,
std::move(deviceModulesBuffers),
std::move(deviceEndcapGeometryBuffers),
srcData.pixelMapping);
}
};
Expand Down
44 changes: 19 additions & 25 deletions RecoTracker/LSTCore/src/LSTESData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ namespace {
}

void loadMapsHost(lst::MapPLStoLayer& pLStoLayer,
std::shared_ptr<lst::EndcapGeometry> endcapGeometry,
std::shared_ptr<lst::TiltedGeometry> tiltedGeometry,
std::shared_ptr<lst::ModuleConnectionMap> moduleConnectionMap) {
lst::EndcapGeometry& endcapGeometry,
lst::TiltedGeometry& tiltedGeometry,
lst::ModuleConnectionMap& moduleConnectionMap) {
// Module orientation information (DrDz or phi angles)
auto endcap_geom =
get_absolute_path_after_check_file_exists(trackLooperDir() + "/data/OT800_IT615_pt0.8/endcap_orientation.bin");
Expand All @@ -51,9 +51,9 @@ namespace {
auto mappath = get_absolute_path_after_check_file_exists(
trackLooperDir() + "/data/OT800_IT615_pt0.8/module_connection_tracing_merged.bin");

endcapGeometry->load(endcap_geom);
tiltedGeometry->load(tilted_geom);
moduleConnectionMap->load(mappath);
endcapGeometry.load(endcap_geom);
tiltedGeometry.load(tilted_geom);
moduleConnectionMap.load(mappath);

auto pLSMapDir = trackLooperDir() + "/data/OT800_IT615_pt0.8/pixelmap/pLS_map";
const std::array<std::string, 4> connects{
Expand All @@ -80,34 +80,28 @@ std::unique_ptr<lst::LSTESData<alpaka_common::DevHost>> lst::loadAndFillESHost()
uint16_t nModules;
uint16_t nLowerModules;
unsigned int nPixels;
std::shared_ptr<lst::ModulesBuffer<alpaka_common::DevHost>> modulesBuffers = nullptr;
auto pLStoLayer = std::make_shared<MapPLStoLayer>();
auto endcapGeometry = std::make_shared<EndcapGeometry>();
auto tiltedGeometry = std::make_shared<TiltedGeometry>();
MapPLStoLayer pLStoLayer;
EndcapGeometry endcapGeometry;
TiltedGeometry tiltedGeometry;
auto pixelMapping = std::make_shared<PixelMap>();
auto moduleConnectionMap = std::make_shared<ModuleConnectionMap>();
::loadMapsHost(*pLStoLayer, endcapGeometry, tiltedGeometry, moduleConnectionMap);
ModuleConnectionMap moduleConnectionMap;
::loadMapsHost(pLStoLayer, endcapGeometry, tiltedGeometry, moduleConnectionMap);

auto endcapGeometryBuffers = std::make_shared<EndcapGeometryBuffer<alpaka_common::DevHost>>(
cms::alpakatools::host(), endcapGeometry->nEndCapMap);
alpaka::QueueCpuBlocking queue(cms::alpakatools::host());
alpaka::memcpy(
queue, endcapGeometryBuffers->geoMapDetId_buf, endcapGeometry->geoMapDetId_buf, endcapGeometry->nEndCapMap);
alpaka::memcpy(
queue, endcapGeometryBuffers->geoMapPhi_buf, endcapGeometry->geoMapPhi_buf, endcapGeometry->nEndCapMap);
auto endcapGeometryBuffers = EndcapGeometryBuffer<alpaka_common::DevHost>(cms::alpakatools::host(), endcapGeometry.nEndCapMap);
std::memcpy(alpaka::getPtrNative(endcapGeometryBuffers.geoMapDetId_buf), endcapGeometry.geoMapDetId_buf.data(), endcapGeometry.nEndCapMap);
std::memcpy(alpaka::getPtrNative(endcapGeometryBuffers.geoMapPhi_buf), endcapGeometry.geoMapPhi_buf.data(), endcapGeometry.nEndCapMap);

auto path =
get_absolute_path_after_check_file_exists(trackLooperDir() + "/data/OT800_IT615_pt0.8/sensor_centroids.bin");
lst::loadModulesFromFile(pLStoLayer.get(),
auto modulesBuffers = lst::loadModulesFromFile(pLStoLayer,
path.c_str(),
nModules,
nLowerModules,
nPixels,
modulesBuffers,
pixelMapping.get(),
endcapGeometry.get(),
tiltedGeometry.get(),
moduleConnectionMap.get());
endcapGeometry,
tiltedGeometry,
moduleConnectionMap);
return std::make_unique<LSTESData<alpaka_common::DevHost>>(
nModules, nLowerModules, nPixels, endcapGeometry->nEndCapMap, modulesBuffers, endcapGeometryBuffers, pixelMapping);
nModules, nLowerModules, nPixels, endcapGeometry.nEndCapMap, std::move(modulesBuffers), std::move(endcapGeometryBuffers), pixelMapping);
}
Loading

0 comments on commit 0bcb06c

Please sign in to comment.