Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace o2::its::gpu
{

template <int NLayers>
class TimeFrameGPU final : public TimeFrame<NLayers>
class TimeFrameGPU : public TimeFrame<NLayers>
{
using typename TimeFrame<NLayers>::IndexTableUtilsN;
using typename TimeFrame<NLayers>::ROFOverlapTableN;
Expand All @@ -35,7 +35,7 @@ class TimeFrameGPU final : public TimeFrame<NLayers>

public:
TimeFrameGPU() = default;
~TimeFrameGPU() final = default;
~TimeFrameGPU() override = default;

/// Most relevant operations
void pushMemoryStack(const int);
Expand Down
1 change: 1 addition & 0 deletions Detectors/ITSMFT/ITS/tracking/GPU/cuda/TimeFrameGPU.cu
Original file line number Diff line number Diff line change
Expand Up @@ -694,4 +694,5 @@ void TimeFrameGPU<NLayers>::wipe()
}

template class TimeFrameGPU<7>;
template class TimeFrameGPU<11>;
} // namespace o2::its::gpu
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,5 @@ void TrackerTraitsGPU<NLayers>::setBz(float bz)
}

template class TrackerTraitsGPU<7>;
template class TrackerTraitsGPU<11>;
} // namespace o2::its
180 changes: 180 additions & 0 deletions Detectors/ITSMFT/ITS/tracking/GPU/cuda/TrackingKernels.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1258,4 +1258,184 @@ template void computeTrackSeedHandler(TrackSeed<7>* trackSeeds,
const o2::base::PropagatorF::MatCorrType matCorrType,
o2::its::ExternalAllocator* alloc);

/// Explicit instantiation of ALICE3 handlers
template void countTrackletsInROFsHandler<11>(const IndexTableUtils<11>* utils,
const ROFMaskTable<11>::View& rofMask,
const int layer,
const ROFOverlapTable<11>::View& rofOverlaps,
const ROFVertexLookupTable<11>::View& vertexLUT,
const int vertexId,
const Vertex* vertices,
const int* rofPV,
const Cluster** clusters,
std::vector<unsigned int> nClusters,
const int** ROFClusters,
const unsigned char** usedClusters,
const int** clustersIndexTables,
int** trackletsLUTs,
gsl::span<int*> trackletsLUTsHost,
const int iteration,
const float NSigmaCut,
bounded_vector<float>& phiCuts,
const float resolutionPV,
std::array<float, 11>& minRs,
std::array<float, 11>& maxRs,
bounded_vector<float>& resolutions,
std::vector<float>& radii,
bounded_vector<float>& mulScatAng,
o2::its::ExternalAllocator* alloc,
gpu::Streams& streams);

template void computeTrackletsInROFsHandler<11>(const IndexTableUtils<11>* utils,
const ROFMaskTable<11>::View& rofMask,
const int layer,
const ROFOverlapTable<11>::View& rofOverlaps,
const ROFVertexLookupTable<11>::View& vertexLUT,
const int vertexId,
const Vertex* vertices,
const int* rofPV,
const Cluster** clusters,
std::vector<unsigned int> nClusters,
const int** ROFClusters,
const unsigned char** usedClusters,
const int** clustersIndexTables,
Tracklet** tracklets,
gsl::span<Tracklet*> spanTracklets,
gsl::span<int> nTracklets,
int** trackletsLUTs,
gsl::span<int*> trackletsLUTsHost,
const int iteration,
const float NSigmaCut,
bounded_vector<float>& phiCuts,
const float resolutionPV,
std::array<float, 11>& minRs,
std::array<float, 11>& maxRs,
bounded_vector<float>& resolutions,
std::vector<float>& radii,
bounded_vector<float>& mulScatAng,
o2::its::ExternalAllocator* alloc,
gpu::Streams& streams);

template void countCellsHandler<11>(const Cluster** sortedClusters,
const Cluster** unsortedClusters,
const TrackingFrameInfo** tfInfo,
Tracklet** tracklets,
int** trackletsLUT,
const int nTracklets,
const int layer,
CellSeed* cells,
int** cellsLUTsArrayDevice,
int* cellsLUTsHost,
const float bz,
const float maxChi2ClusterAttachment,
const float cellDeltaTanLambdaSigma,
const float nSigmaCut,
const std::vector<float>& layerxX0Host,
o2::its::ExternalAllocator* alloc,
gpu::Streams& streams);

template void computeCellsHandler<11>(const Cluster** sortedClusters,
const Cluster** unsortedClusters,
const TrackingFrameInfo** tfInfo,
Tracklet** tracklets,
int** trackletsLUT,
const int nTracklets,
const int layer,
CellSeed* cells,
int** cellsLUTsArrayDevice,
int* cellsLUTsHost,
const float bz,
const float maxChi2ClusterAttachment,
const float cellDeltaTanLambdaSigma,
const float nSigmaCut,
const std::vector<float>& layerxX0Host,
gpu::Streams& streams);

template void countCellNeighboursHandler<11>(CellSeed** cellsLayersDevice,
int* neighboursLUT,
int** cellsLUTs,
gpuPair<int, int>* cellNeighbours,
int* neighboursIndexTable,
const Tracklet** tracklets,
const float maxChi2ClusterAttachment,
const float bz,
const int layerIndex,
const unsigned int nCells,
const unsigned int nCellsNext,
const int maxCellNeighbours,
o2::its::ExternalAllocator* alloc,
gpu::Stream& stream);

template void computeCellNeighboursHandler<11>(CellSeed** cellsLayersDevice,
int* neighboursLUT,
int** cellsLUTs,
gpuPair<int, int>* cellNeighbours,
int* neighboursIndexTable,
const Tracklet** tracklets,
const float maxChi2ClusterAttachment,
const float bz,
const int layerIndex,
const unsigned int nCells,
const unsigned int nCellsNext,
const int maxCellNeighbours,
gpu::Stream& stream);

template void processNeighboursHandler<11>(const int startLayer,
const int startLevel,
CellSeed** allCellSeeds,
CellSeed* currentCellSeeds,
std::array<int, 9>& nCells,
const unsigned char** usedClusters,
std::array<int*, 9>& neighbours,
gsl::span<int*> neighboursDeviceLUTs,
const TrackingFrameInfo** foundTrackingFrameInfo,
bounded_vector<TrackSeed<11>>& seedsHost,
const float bz,
const float maxChi2ClusterAttachment,
const float maxChi2NDF,
const std::vector<float>& layerxX0Host,
const o2::base::Propagator* propagator,
const o2::base::PropagatorF::MatCorrType matCorrType,
o2::its::ExternalAllocator* alloc);

template void countTrackSeedHandler(TrackSeed<11>* trackSeeds,
const TrackingFrameInfo** foundTrackingFrameInfo,
const Cluster** unsortedClusters,
int* seedLUT,
const std::vector<float>& layerRadiiHost,
const std::vector<float>& minPtsHost,
const std::vector<float>& layerxX0Host,
const unsigned int nSeeds,
const float bz,
const int startLevel,
const float maxChi2ClusterAttachment,
const float maxChi2NDF,
const int reseedIfShorter,
const bool repeatRefitOut,
const bool shiftRefToCluster,
const o2::base::Propagator* propagator,
const o2::base::PropagatorF::MatCorrType matCorrType,
o2::its::ExternalAllocator* alloc);

template void computeTrackSeedHandler(TrackSeed<11>* trackSeeds,
const TrackingFrameInfo** foundTrackingFrameInfo,
const Cluster** unsortedClusters,
o2::its::TrackITSExt* tracks,
const int* seedLUT,
const std::vector<float>& layerRadiiHost,
const std::vector<float>& minPtsHost,
const std::vector<float>& layerxX0Host,
const unsigned int nSeeds,
const unsigned int nTracks,
const float bz,
const int startLevel,
const float maxChi2ClusterAttachment,
const float maxChi2NDF,
const int reseedIfShorter,
const bool repeatRefitOut,
const bool shiftRefToCluster,
const o2::base::Propagator* propagator,
const o2::base::PropagatorF::MatCorrType matCorrType,
o2::its::ExternalAllocator* alloc);

} // namespace o2::its
1 change: 1 addition & 0 deletions Detectors/Upgrades/ALICE3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

add_subdirectory(Passive)
add_subdirectory(TRK)
add_subdirectory(GlobalReconstruction)
add_subdirectory(ECal)
add_subdirectory(FD3)
add_subdirectory(FT3)
Expand Down
13 changes: 13 additions & 0 deletions Detectors/Upgrades/ALICE3/GlobalReconstruction/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2019-2020 CERN and copyright holders of ALICE O2.
# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
# All rights not expressly granted are reserved.
#
# This software is distributed under the terms of the GNU General Public
# License v3 (GPL Version 3), copied verbatim in the file "COPYING".
#
# In applying this license CERN does not waive the privileges and immunities
# granted to it by virtue of its status as an Intergovernmental Organization
# or submit itself to any jurisdiction.

add_subdirectory(reconstruction)
add_subdirectory(workflow)
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Copyright 2019-2020 CERN and copyright holders of ALICE O2.
# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
# All rights not expressly granted are reserved.
#
# This software is distributed under the terms of the GNU General Public
# License v3 (GPL Version 3), copied verbatim in the file "COPYING".
#
# In applying this license CERN does not waive the privileges and immunities
# granted to it by virtue of its status as an Intergovernmental Organization
# or submit itself to any jurisdiction.

if(Acts_FOUND)
set(actsTarget Acts::Core)
endif()

set(alice3GlobalRecoGpuSources "")
set(alice3GlobalRecoGpuTargets "")
set(alice3GlobalRecoGpuPrivateTargets "")
if(CUDA_ENABLED)
find_package(CUDAToolkit REQUIRED)
list(APPEND alice3GlobalRecoGpuSources src/TimeFrameGPU.cxx src/GPUExternalAllocator.cxx)
list(APPEND alice3GlobalRecoGpuTargets O2::ITStrackingCUDA)
list(APPEND alice3GlobalRecoGpuPrivateTargets CUDA::cudart)
elseif(HIP_ENABLED)
list(APPEND alice3GlobalRecoGpuSources src/TimeFrameGPU.cxx src/GPUExternalAllocator.cxx)
list(APPEND alice3GlobalRecoGpuTargets O2::ITStrackingHIP)
list(APPEND alice3GlobalRecoGpuPrivateTargets hip::host)
endif()

o2_add_library(ALICE3GlobalReconstruction
TARGETVARNAME targetName
SOURCES src/TimeFrame.cxx
${alice3GlobalRecoGpuSources}
$<$<BOOL:${Acts_FOUND}>:src/TrackerACTS.cxx>
PUBLIC_LINK_LIBRARIES
O2::ITStracking
O2::GPUCommon
Microsoft.GSL::GSL
O2::CommonConstants
O2::DataFormatsITSMFT
O2::DataFormatsTRK
O2::SimulationDataFormat
O2::ITSBase
O2::ITSReconstruction
O2::ITSMFTReconstruction
O2::DataFormatsITS
O2::TRKBase
O2::TRKReconstruction
O2::TRKSimulation
nlohmann_json::nlohmann_json
${alice3GlobalRecoGpuTargets}
${actsTarget}
PRIVATE_LINK_LIBRARIES
O2::Steer
TBB::tbb
${alice3GlobalRecoGpuPrivateTargets})

if(alice3GlobalRecoGpuTargets)
target_compile_definitions(${targetName} PUBLIC TRK_HAS_GPU_TRACKING)
endif()

if(CUDA_ENABLED)
target_include_directories(${targetName} PRIVATE ${CUDAToolkit_INCLUDE_DIRS})
endif()

if(CUDA_ENABLED)
target_compile_definitions(${targetName} PUBLIC TRK_HAS_CUDA_TRACKING)
elseif(HIP_ENABLED)
target_compile_definitions(${targetName} PUBLIC TRK_HAS_HIP_TRACKING)
endif()

if(Acts_FOUND)
target_compile_definitions(${targetName} PUBLIC O2_WITH_ACTS)
endif()
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

#ifndef ALICEO2_ALICE3GLOBALRECONSTRUCTION_GPUEXTERNALALLOCATOR_H
#define ALICEO2_ALICE3GLOBALRECONSTRUCTION_GPUEXTERNALALLOCATOR_H

#include "ITStracking/ExternalAllocator.h"

#include <cstddef>
#include <cstdint>
#include <mutex>
#include <type_traits>
#include <unordered_map>
#include <vector>

namespace o2::trk
{

class GPUExternalAllocator final : public o2::its::ExternalAllocator
{
public:
GPUExternalAllocator() = default;
~GPUExternalAllocator();

void* allocate(size_t size) override;
void deallocate(char* ptr, size_t size) override;
void pushTagOnStack(uint64_t tag) override;
void popTagOffStack(uint64_t tag) override;

void releaseAll();

private:
enum class AllocationSpace { Host, Device };

struct AllocationMeta {
AllocationSpace space;
uint64_t tag;
bool stacked;
};

using MemoryType = std::underlying_type_t<o2::gpu::GPUMemoryResource::MemoryType>;

void* allocateHost(size_t size);
void* allocateDevice(size_t size);
void freeAllocation(void* ptr, AllocationSpace space);
void removeFromTagLocked(uint64_t tag, void* ptr);

std::mutex mMutex;
std::vector<uint64_t> mTagStack;
std::unordered_map<uint64_t, std::vector<void*>> mTaggedAllocations;
std::unordered_map<void*, AllocationMeta> mAllocations;
};

} // namespace o2::trk

#endif
Loading
Loading