-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ef502d
commit 82de631
Showing
16 changed files
with
2,210 additions
and
0 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
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
24 changes: 24 additions & 0 deletions
24
device/cuda/include/traccc/cuda/seeding2/kernels/kd_tree_kernel.hpp
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 @@ | ||
/** TRACCC library, part of the ACTS project (R&D line) | ||
* | ||
* (c) 2022 CERN for the benefit of the ACTS project | ||
* | ||
* Mozilla Public License Version 2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <traccc/cuda/seeding2/types/internal_sp.hpp> | ||
#include <traccc/cuda/seeding2/types/kd_tree.hpp> | ||
#include <traccc/edm/internal_spacepoint.hpp> | ||
#include <traccc/edm/spacepoint.hpp> | ||
#include <vector> | ||
|
||
namespace traccc::cuda { | ||
/** | ||
* @brief Creates a k-d tree from a given set of spacepoints. | ||
* | ||
* @return A pair containing the k-d tree nodes as well as the number of nodes. | ||
*/ | ||
std::tuple<kd_tree_owning_t, uint32_t, internal_sp_owning_t> create_kd_tree( | ||
vecmem::memory_resource&, internal_sp_owning_t&&, uint32_t); | ||
} // namespace traccc::cuda |
27 changes: 27 additions & 0 deletions
27
device/cuda/include/traccc/cuda/seeding2/kernels/seed_finding_kernel.hpp
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,27 @@ | ||
/** TRACCC library, part of the ACTS project (R&D line) | ||
* | ||
* (c) 2022 CERN for the benefit of the ACTS project | ||
* | ||
* Mozilla Public License Version 2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <traccc/cuda/seeding2/types/internal_sp.hpp> | ||
#include <traccc/cuda/seeding2/types/kd_tree.hpp> | ||
#include <traccc/edm/alt_seed.hpp> | ||
#include <traccc/edm/internal_spacepoint.hpp> | ||
#include <traccc/edm/spacepoint.hpp> | ||
#include <traccc/seeding/detail/seeding_config.hpp> | ||
|
||
namespace traccc::cuda { | ||
/** | ||
* @brief Execute the seed finding kernel itself. | ||
* | ||
* @return A pair containing the list of internal seeds as well as the number | ||
* of seeds. | ||
*/ | ||
std::pair<vecmem::unique_alloc_ptr<alt_seed[]>, uint32_t> run_seeding( | ||
seedfinder_config, seedfilter_config, vecmem::memory_resource&, | ||
internal_sp_t, kd_tree_t); | ||
} // namespace traccc::cuda |
26 changes: 26 additions & 0 deletions
26
device/cuda/include/traccc/cuda/seeding2/kernels/write_output_kernel.hpp
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,26 @@ | ||
/** TRACCC library, part of the ACTS project (R&D line) | ||
* | ||
* (c) 2022 CERN for the benefit of the ACTS project | ||
* | ||
* Mozilla Public License Version 2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <traccc/cuda/seeding2/types/internal_sp.hpp> | ||
#include <traccc/edm/alt_seed.hpp> | ||
#include <traccc/edm/internal_spacepoint.hpp> | ||
#include <traccc/edm/seed.hpp> | ||
#include <traccc/edm/spacepoint.hpp> | ||
#include <traccc/utils/memory_resource.hpp> | ||
|
||
namespace traccc::cuda { | ||
/** | ||
* @brief Kernel to write output data back into traccc's EDM. | ||
* | ||
* @return A vector buffer containing the output seeds. | ||
*/ | ||
alt_seed_collection_types::buffer write_output(const traccc::memory_resource &, | ||
uint32_t, const internal_sp_t, | ||
const alt_seed *const); | ||
} // namespace traccc::cuda |
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,35 @@ | ||
/** TRACCC library, part of the ACTS project (R&D line) | ||
* | ||
* (c) 2022 CERN for the benefit of the ACTS project | ||
* | ||
* Mozilla Public License Version 2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <traccc/edm/alt_seed.hpp> | ||
#include <traccc/edm/spacepoint.hpp> | ||
#include <traccc/seeding/detail/seeding_config.hpp> | ||
#include <traccc/utils/algorithm.hpp> | ||
#include <traccc/utils/memory_resource.hpp> | ||
#include <vecmem/memory/cuda/device_memory_resource.hpp> | ||
|
||
namespace traccc::cuda { | ||
/** | ||
* @brief Alternative seed finding algorithm, using orthogonal range search | ||
* implemented through a k-d tree. | ||
*/ | ||
class seed_finding2 : public algorithm<alt_seed_collection_types::buffer( | ||
const spacepoint_collection_types::const_view&)> { | ||
public: | ||
seed_finding2(const traccc::memory_resource& mr); | ||
|
||
output_type operator()( | ||
const spacepoint_collection_types::const_view& sps) const override; | ||
|
||
private: | ||
traccc::memory_resource m_output_mr; | ||
seedfinder_config m_finder_conf; | ||
seedfilter_config m_filter_conf; | ||
}; | ||
} // namespace traccc::cuda |
35 changes: 35 additions & 0 deletions
35
device/cuda/include/traccc/cuda/seeding2/types/internal_sp.hpp
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,35 @@ | ||
/** TRACCC library, part of the ACTS project (R&D line) | ||
* | ||
* (c) 2022 CERN for the benefit of the ACTS project | ||
* | ||
* Mozilla Public License Version 2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <array> | ||
#include <cstdint> | ||
#include <traccc/edm/internal_spacepoint.hpp> | ||
#include <traccc/edm/spacepoint.hpp> | ||
#include <traccc/utils/array_wrapper.hpp> | ||
#include <vecmem/memory/unique_ptr.hpp> | ||
|
||
namespace traccc::cuda { | ||
template <template <typename> typename F> | ||
struct sp_t { | ||
using tuple_t = std::tuple<float, float, float, float, float, unsigned int>; | ||
|
||
F<float> x; | ||
F<float> y; | ||
F<float> z; | ||
F<float> phi; | ||
F<float> radius; | ||
F<unsigned int> link; | ||
}; | ||
|
||
using internal_sp = array_wrapper<soa, sp_t>; | ||
|
||
using internal_sp_owning_t = internal_sp::owner; | ||
|
||
using internal_sp_t = internal_sp::handle; | ||
} // namespace traccc::cuda |
36 changes: 36 additions & 0 deletions
36
device/cuda/include/traccc/cuda/seeding2/types/kd_tree.hpp
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,36 @@ | ||
/** TRACCC library, part of the ACTS project (R&D line) | ||
* | ||
* (c) 2022 CERN for the benefit of the ACTS project | ||
* | ||
* Mozilla Public License Version 2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <traccc/cuda/seeding2/types/range3d.hpp> | ||
#include <traccc/utils/array_wrapper.hpp> | ||
#include <vecmem/memory/unique_ptr.hpp> | ||
|
||
namespace traccc::cuda { | ||
enum class nodetype_e { LEAF, INTERNAL, NON_EXTANT }; | ||
|
||
enum class pivot_e { Phi, R, Z }; | ||
|
||
template <template <typename> typename F> | ||
struct node_t { | ||
using tuple_t = | ||
std::tuple<nodetype_e, range3d, uint32_t, uint32_t, pivot_e, float>; | ||
|
||
F<nodetype_e> type; | ||
F<range3d> range; | ||
F<uint32_t> begin, end; | ||
F<pivot_e> dim; | ||
F<float> mid; | ||
}; | ||
|
||
using kd_tree = array_wrapper<soa, node_t>; | ||
|
||
using kd_tree_owning_t = kd_tree::owner; | ||
|
||
using kd_tree_t = kd_tree::handle; | ||
} // namespace traccc::cuda |
73 changes: 73 additions & 0 deletions
73
device/cuda/include/traccc/cuda/seeding2/types/range3d.hpp
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,73 @@ | ||
/** TRACCC library, part of the ACTS project (R&D line) | ||
* | ||
* (c) 2022 CERN for the benefit of the ACTS project | ||
* | ||
* Mozilla Public License Version 2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <array> | ||
#include <cstdint> | ||
|
||
namespace traccc::cuda { | ||
/** | ||
* @brief Range in three dimensions, defined by minima and maxima in the phi, | ||
* r, and z dimensions. | ||
*/ | ||
struct range3d { | ||
float phi_min, phi_max, r_min, r_max, z_min, z_max; | ||
|
||
__host__ __device__ __forceinline__ static range3d Infinite() { | ||
range3d r; | ||
|
||
r.phi_min = std::numeric_limits<float>::lowest(); | ||
r.phi_max = std::numeric_limits<float>::max(); | ||
r.r_min = 0.f; | ||
r.r_max = std::numeric_limits<float>::max(); | ||
r.z_min = std::numeric_limits<float>::lowest(); | ||
r.z_max = std::numeric_limits<float>::max(); | ||
|
||
return r; | ||
} | ||
|
||
__host__ __device__ __forceinline__ static range3d Degenerate() { | ||
range3d r; | ||
|
||
r.phi_min = std::numeric_limits<float>::max(); | ||
r.phi_max = std::numeric_limits<float>::lowest(); | ||
r.r_min = std::numeric_limits<float>::max(); | ||
r.r_max = 0.f; | ||
r.z_min = std::numeric_limits<float>::max(); | ||
r.z_max = std::numeric_limits<float>::lowest(); | ||
|
||
return r; | ||
} | ||
|
||
__host__ __device__ __forceinline__ static range3d Union(const range3d& a, | ||
const range3d& b) { | ||
return {std::min(a.phi_min, b.phi_min), std::max(a.phi_max, b.phi_max), | ||
std::min(a.r_min, b.r_min), std::max(a.r_max, b.r_max), | ||
std::min(a.z_min, b.z_min), std::max(a.z_max, b.z_max)}; | ||
} | ||
|
||
__host__ __device__ __forceinline__ bool intersects( | ||
const range3d& o) const { | ||
return phi_min <= o.phi_max && o.phi_min < phi_max && | ||
r_min <= o.r_max && o.r_min < r_max && z_min <= o.z_max && | ||
o.z_min < z_max; | ||
} | ||
|
||
__host__ __device__ __forceinline__ bool dominates(const range3d& o) const { | ||
return phi_min <= o.phi_min && o.phi_max <= phi_max && | ||
r_min <= o.r_min && o.r_max <= r_max && z_min <= o.z_min && | ||
o.z_max <= z_max; | ||
} | ||
|
||
__host__ __device__ __forceinline__ bool contains(float phi, float r, | ||
float z) const { | ||
return phi_min <= phi && phi <= phi_max && r_min <= r && r <= r_max && | ||
z_min <= z && z <= z_max; | ||
} | ||
}; | ||
} // namespace traccc::cuda |
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 @@ | ||
/** TRACCC library, part of the ACTS project (R&D line) | ||
* | ||
* (c) 2021 CERN for the benefit of the ACTS project | ||
* | ||
* Mozilla Public License Version 2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#if defined(__CUDACC__) && defined(__CUDA_ARCH__) | ||
// Set values of maximum resident threads per SM | ||
#if __CUDA_ARCH__ < 500 | ||
#pragma message \ | ||
"Very old CUDA architecture, setting maximum resident threads per SM to 1024." | ||
#define CUDA_MAX_RESIDENT_THREADS_PER_SM 1024u | ||
#elif __CUDA_ARCH__ <= 720 | ||
#define CUDA_MAX_RESIDENT_THREADS_PER_SM 2048u | ||
#elif __CUDA_ARCH__ <= 750 | ||
#define CUDA_MAX_RESIDENT_THREADS_PER_SM 1024u | ||
#elif __CUDA_ARCH__ <= 800 | ||
#define CUDA_MAX_RESIDENT_THREADS_PER_SM 2048u | ||
#elif __CUDA_ARCH__ <= 890 | ||
#define CUDA_MAX_RESIDENT_THREADS_PER_SM 1536u | ||
#elif __CUDA_ARCH__ <= 900 | ||
#define CUDA_MAX_RESIDENT_THREADS_PER_SM 2048u | ||
#pragma message \ | ||
"Unknown CUDA architecture, setting maximum resident threads per SM to 1024." | ||
#define CUDA_MAX_RESIDENT_THREADS_PER_SM 1024u | ||
#endif | ||
|
||
// Set values of maximum resident blocks per SM | ||
#if __CUDA_ARCH__ < 500 | ||
#pragma message \ | ||
"Very old CUDA architecture, setting maximum resident blocks per SM to 16." | ||
#define CUDA_MAX_RESIDENT_BLOCKS_PER_SM 16u | ||
#elif __CUDA_ARCH__ <= 720 | ||
#define CUDA_MAX_RESIDENT_BLOCKS_PER_SM 32u | ||
#elif __CUDA_ARCH__ <= 750 | ||
#define CUDA_MAX_RESIDENT_BLOCKS_PER_SM 16u | ||
#elif __CUDA_ARCH__ <= 800 | ||
#define CUDA_MAX_RESIDENT_BLOCKS_PER_SM 32u | ||
#elif __CUDA_ARCH__ <= 870 | ||
#define CUDA_MAX_RESIDENT_BLOCKS_PER_SM 16u | ||
#elif __CUDA_ARCH__ <= 890 | ||
#define CUDA_MAX_RESIDENT_BLOCKS_PER_SM 24u | ||
#elif __CUDA_ARCH__ <= 900 | ||
#define CUDA_MAX_RESIDENT_BLOCKS_PER_SM 32u | ||
#else | ||
#pragma message \ | ||
"Very old CUDA architecture, setting maximum resident blocks per SM to 16." | ||
#define CUDA_MAX_RESIDENT_BLOCKS_PER_SM 16u | ||
#endif | ||
|
||
// Set values of maximum threadss per block | ||
#define CUDA_MAX_THREADS_PER_BLOCK 1024u | ||
#endif |
Oops, something went wrong.