-
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
59ffb25
commit a132f0b
Showing
21 changed files
with
2,549 additions
and
5 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
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,203 @@ | ||
/** 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 | ||
|
||
#include <traccc/utils/functor.hpp> | ||
#include <type_traits> | ||
#include <utility> | ||
#include <vecmem/memory/memory_resource.hpp> | ||
#include <vecmem/memory/unique_ptr.hpp> | ||
|
||
namespace traccc::cuda { | ||
|
||
template <typename... Ts> | ||
struct pod {}; | ||
|
||
template <> | ||
struct pod<> {}; | ||
|
||
template <typename T, typename... Ts> | ||
struct pod<T, Ts...> { | ||
T v; | ||
pod<Ts...> r; | ||
}; | ||
|
||
template <std::size_t I, typename... Ts> | ||
constexpr auto& pod_get(pod<Ts...>& p) { | ||
if constexpr (I == 0) { | ||
return p.v; | ||
} else { | ||
return pod_get<I - 1>(p.r); | ||
} | ||
} | ||
|
||
template <template <typename...> typename F, | ||
template <template <typename> typename> typename T> | ||
struct array_wrapper { | ||
struct owner { | ||
owner(vecmem::memory_resource& mr, std::size_t n) : data(mr, n) {} | ||
|
||
typename details::functor::reapply< | ||
F, typename T<details::functor::identity>::tuple_t>::type::owner | ||
data; | ||
}; | ||
|
||
struct handle { | ||
using handle_t = typename details::functor::reapply< | ||
F, typename T<details::functor::identity>::tuple_t>::type::handle; | ||
|
||
handle(const owner& o) : data(o.data) {} | ||
|
||
std::size_t size() const { return data.size(); } | ||
|
||
template <std::size_t I> | ||
__host__ __device__ auto& get(std::size_t i) { | ||
return data.get<I>(i); | ||
} | ||
|
||
template <std::size_t I> | ||
__host__ __device__ auto get(std::size_t i) const { | ||
return data.get<I>(i); | ||
} | ||
|
||
template <std::size_t I> | ||
__host__ __device__ auto get_identity(std::size_t i) const { | ||
return data.get<I>(i); | ||
} | ||
|
||
template <std::size_t I> | ||
__host__ __device__ auto& get_reference(std::size_t i) { | ||
return data.get<I>(i); | ||
} | ||
|
||
template <std::size_t... Ns> | ||
constexpr __host__ __device__ T<details::functor::identity> | ||
_construct_helper_identity(std::index_sequence<Ns...>, | ||
std::size_t i) const { | ||
return T<details::functor::identity>{get_identity<Ns>(i)...}; | ||
} | ||
|
||
template <std::size_t... Ns> | ||
constexpr __host__ __device__ T<details::functor::reference> | ||
_construct_helper_reference(std::index_sequence<Ns...>, std::size_t i) { | ||
return T<details::functor::reference>{get_reference<Ns>(i)...}; | ||
} | ||
|
||
__host__ __device__ T<details::functor::identity> operator[]( | ||
std::size_t i) const { | ||
return _construct_helper_identity( | ||
std::make_index_sequence<std::tuple_size_v< | ||
typename T<details::functor::identity>::tuple_t>>(), | ||
i); | ||
} | ||
|
||
__host__ __device__ T<details::functor::reference> operator[]( | ||
std::size_t i) { | ||
return _construct_helper_reference( | ||
std::make_index_sequence<std::tuple_size_v< | ||
typename T<details::functor::identity>::tuple_t>>(), | ||
i); | ||
} | ||
|
||
handle_t data; | ||
}; | ||
}; | ||
|
||
template <std::size_t... Ns, typename... Ts> | ||
std::tuple<Ts*...> _get_ptrs( | ||
std::index_sequence<Ns...>, | ||
const std::tuple<vecmem::unique_alloc_ptr<Ts[]>...>& o) { | ||
return {std::get<Ns>(o).get()...}; | ||
} | ||
|
||
template <typename... Ts> | ||
struct soa { | ||
struct owner { | ||
owner(vecmem::memory_resource& mr, std::size_t n) | ||
: _size(n), _ptrs{vecmem::make_unique_alloc<Ts[]>(mr, n)...} {} | ||
|
||
std::size_t size() const { return _size; } | ||
|
||
const std::tuple<vecmem::unique_alloc_ptr<Ts[]>...>& pointers() const { | ||
return _ptrs; | ||
} | ||
|
||
private: | ||
std::size_t _size; | ||
std::tuple<vecmem::unique_alloc_ptr<Ts[]>...> _ptrs; | ||
}; | ||
|
||
struct handle { | ||
private: | ||
using tuple_t = std::tuple<Ts*...>; | ||
|
||
public: | ||
handle(const owner& o) | ||
: _size(o.size()), | ||
_ptrs(_get_ptrs(std::make_index_sequence<sizeof...(Ts)>(), | ||
o.pointers())) {} | ||
|
||
__host__ __device__ std::size_t size() const { return _size; } | ||
|
||
template <std::size_t I> | ||
__host__ __device__ auto& get(std::size_t i) { | ||
return std::get<I>(_ptrs)[i]; | ||
} | ||
|
||
template <std::size_t I> | ||
__host__ __device__ const auto& get(std::size_t i) const { | ||
return std::get<I>(_ptrs)[i]; | ||
} | ||
|
||
private: | ||
std::size_t _size; | ||
std::tuple<Ts*...> _ptrs; | ||
}; | ||
}; | ||
|
||
template <typename... Ts> | ||
struct aos { | ||
struct owner { | ||
owner(vecmem::memory_resource& mr, std::size_t n) | ||
: _size(n), _ptr{vecmem::make_unique_alloc<pod<Ts...>[]>(mr, n)} {} | ||
|
||
std::size_t size() const { return _size; } | ||
|
||
const vecmem::unique_alloc_ptr<pod<Ts...>[]>& pointer() const { | ||
return _ptr; | ||
} | ||
|
||
private : std::size_t _size; | ||
vecmem::unique_alloc_ptr<pod<Ts...>[]> _ptr; | ||
}; | ||
|
||
struct handle { | ||
private: | ||
using tuple_t = pod<Ts...>; | ||
|
||
public: | ||
handle(const owner& o) : _size(o.size()), _ptr(o.pointer().get()) {} | ||
|
||
__host__ __device__ std::size_t size() const { return _size; } | ||
|
||
template <std::size_t I> | ||
__host__ __device__ auto& get(std::size_t i) { | ||
return pod_get<I>(_ptr[i]); | ||
} | ||
|
||
template <std::size_t I> | ||
__host__ __device__ const auto& get(std::size_t i) const { | ||
return pod_get<I>(_ptr[i]); | ||
} | ||
|
||
private: | ||
std::size_t _size; | ||
tuple_t* _ptr; | ||
}; | ||
}; | ||
} // 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,28 @@ | ||
/** TRACCC library, part of the ACTS project (R&D line) | ||
* | ||
* (c) 2021-2022 CERN for the benefit of the ACTS project | ||
* | ||
* Mozilla Public License Version 2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
namespace traccc::details::functor { | ||
template <typename T> | ||
using identity = T; | ||
|
||
template <typename T> | ||
using reference = T&; | ||
|
||
template <typename T> | ||
using const_reference = const T&; | ||
|
||
template <template <typename...> typename F, typename T> | ||
struct reapply {}; | ||
|
||
template <template <typename...> typename F1, | ||
template <typename...> typename F2, typename... Ts> | ||
struct reapply<F1, F2<Ts...>> { | ||
using type = F1<Ts...>; | ||
}; | ||
} // namespace traccc::details::functor |
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 |
39 changes: 39 additions & 0 deletions
39
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,39 @@ | ||
/** 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 Convenience data structure for all the data we need for seeding. | ||
*/ | ||
struct seed_finding_data_t { | ||
const seedfinder_config finder_conf; | ||
const seedfilter_config filter_conf; | ||
const internal_sp_t spacepoints; | ||
const std::size_t n_spacepoints; | ||
const kd_tree_t tree; | ||
const uint32_t tree_nodes; | ||
}; | ||
|
||
/** | ||
* @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, uint32_t, kd_tree_t, uint32_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 |
Oops, something went wrong.