-
Notifications
You must be signed in to change notification settings - Fork 53
Add cuda inhomogeneous bfield type #1017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
beomki-yeo
wants to merge
2
commits into
acts-project:main
Choose a base branch
from
beomki-yeo:inhom-field
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+969
−1
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
36 changes: 36 additions & 0 deletions
36
...rc/finding/combinatorial_kalman_filter_algorithm_inhomogeneous_field_default_detector.cpp
This file contains hidden or 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) 2024-2025 CERN for the benefit of the ACTS project | ||
* | ||
* Mozilla Public License Version 2.0 | ||
*/ | ||
|
||
// Local include(s). | ||
#include "traccc/finding/combinatorial_kalman_filter_algorithm.hpp" | ||
#include "traccc/finding/details/find_tracks.hpp" | ||
#include "traccc/utils/bfield.hpp" | ||
#include "traccc/utils/propagation.hpp" | ||
|
||
namespace { | ||
using detector_type = traccc::default_detector; | ||
using scalar_type = detector_type::host::scalar_type; | ||
using bfield_type = covfie::field<traccc::inhom_bfield_backend_t<scalar_type>>; | ||
} // namespace | ||
|
||
namespace traccc::host { | ||
combinatorial_kalman_filter_algorithm::output_type | ||
combinatorial_kalman_filter_algorithm::operator()( | ||
const detector_type::host& det, const bfield_type::view_t& field, | ||
const measurement_collection_types::const_view& measurements, | ||
const bound_track_parameters_collection_types::const_view& seeds) const { | ||
|
||
// Perform the track finding using the templated implementation. | ||
return details::find_tracks< | ||
detray::rk_stepper<bfield_type::view_t, | ||
detector_type::host::algebra_type, | ||
detray::constrained_step<scalar_type>>, | ||
detray::navigator<const detector_type::host>>( | ||
det, field, measurements, seeds, m_config, m_mr.get(), logger()); | ||
} | ||
|
||
} // namespace traccc::host |
40 changes: 40 additions & 0 deletions
40
core/src/fitting/kalman_fitting_algorithm_inhomogeneous_field_default_detector.cpp
F438
This file contains hidden or 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,40 @@ | ||
/** TRACCC library, part of the ACTS project (R&D line) | ||
* | ||
* (c) 2025 CERN for the benefit of the ACTS project | ||
* | ||
* Mozilla Public License Version 2.0 | ||
*/ | ||
|
||
// Project include(s). | ||
#include "traccc/fitting/details/fit_tracks.hpp" | ||
#include "traccc/fitting/kalman_filter/kalman_fitter.hpp" | ||
#include "traccc/fitting/kalman_fitting_algorithm.hpp" | ||
#include "traccc/utils/bfield.hpp" | ||
#include "traccc/utils/propagation.hpp" | ||
|
||
namespace { | ||
using detector_type = traccc::default_detector; | ||
using scalar_type = detector_type::host::scalar_type; | ||
using bfield_type = covfie::field<traccc::inhom_bfield_backend_t<scalar_type>>; | ||
} // namespace | ||
|
||
namespace traccc::host { | ||
|
||
kalman_fitting_algorithm::output_type kalman_fitting_algorithm::operator()( | ||
const detector_type::host& det, const bfield_type::view_t& field, | ||
const edm::track_candidate_container<default_algebra>::const_view& | ||
track_candidates) const { | ||
|
||
// Create the fitter object. | ||
kalman_fitter<detray::rk_stepper<bfield_type::view_t, | ||
detector_type::host::algebra_type, | ||
detray::constrained_step<scalar_type>>, | ||
detray::navigator<const detector_type::host>> | ||
fitter{det, field, m_config}; | ||
|
||
// Perform the track fitting using a common, templated function. | ||
return details::fit_tracks<default_algebra>(fitter, track_candidates, | ||
m_mr.get(), m_copy.get()); | ||
} | ||
|
||
} // namespace traccc::host |
This file contains hidden or 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
110 changes: 110 additions & 0 deletions
110
device/cuda/include/traccc/cuda/finding/combinatorial_kalman_filter_algorithm.hpp
This file contains hidden or 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,110 @@ | ||
/** TRACCC library, part of the ACTS project (R&D line) | ||
* | ||
* (c) 2024-2025 CERN for the benefit of the ACTS project | ||
* | ||
* Mozilla Public License Version 2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
// Project include(s). | ||
#include "traccc/cuda/utils/bfield.hpp" | ||
#include "traccc/cuda/utils/stream.hpp" | ||
#include "traccc/edm/measurement.hpp" | ||
#include "traccc/edm/track_candidate_collection.hpp" | ||
#include "traccc/edm/track_parameters.hpp" | ||
#include "traccc/finding/finding_config.hpp" | ||
#include "traccc/geometry/detector.hpp" | ||
#include "traccc/utils/algorithm.hpp" | ||
#include "traccc/utils/bfield.hpp" | ||
#include "traccc/utils/detector_type_utils.hpp" | ||
#include "traccc/utils/memory_resource.hpp" | ||
#include "traccc/utils/messaging.hpp" | ||
|
||
// VecMem include(s). | ||
#include <vecmem/utils/copy.hpp> | ||
|
||
// System include(s). | ||
#include <functional> | ||
|
||
namespace traccc::cuda { | ||
|
||
/// CKF track finding algorithm | ||
class combinatorial_kalman_filter_algorithm | ||
: public algorithm<edm::track_candidate_collection<default_algebra>::buffer( | ||
const default_detector::view&, | ||
const covfie::field<traccc::const_bfield_backend_t< | ||
default_detector::device::scalar_type>>::view_t&, | ||
const measurement_collection_types::const_view&, | ||
const bound_track_parameters_collection_types::const_view&)>, | ||
public algorithm<edm::track_candidate_collection<default_algebra>::buffer( | ||
const default_detector::view&, | ||
const covfie::field<traccc::cuda::inhom_bfield_backend_t< | ||
default_detector::device::scalar_type>>::view_t&, | ||
const measurement_collection_types::const_view&, | ||
const bound_track_parameters_collection_types::const_view&)>, | ||
public messaging { | ||
|
||
public: | ||
/// Configuration type | ||
using config_type = finding_config; | ||
/// Output type | ||
using output_type = | ||
edm::track_candidate_collection<default_algebra>::buffer; | ||
|
||
/// Constructor with the algorithm's configuration | ||
explicit combinatorial_kalman_filter_algorithm( | ||
const config_type& config, const traccc::memory_resource& mr, | ||
vecmem::copy& copy, stream& str, | ||
std::unique_ptr<const Logger> logger = getDummyLogger().clone()); | ||
|
||
/// Execute the algorithm | ||
/// | ||
/// @param det The (default) detector object | ||
/// @param field The (constant) magnetic field object | ||
/// @param measurements All measurements in an event | ||
/// @param seeds All seeds in an event to start the track finding | ||
/// with | ||
/// | ||
/// @return A container of the found track candidates | ||
/// | ||
output_type operator()( | ||
const default_detector::view& det, | ||
const covfie::field<const_bfield_backend_t< | ||
default_detector::device::scalar_type>>::view_t& field, | ||
const measurement_collection_types::const_view& measurements, | ||
const bound_track_parameters_collection_types::const_view& seeds) | ||
const override; | ||
|
||
/// Execute the algorithm | ||
/// | ||
/// @param det The (default) detector object | ||
/// @param field The inhomogeneous magnetic field object | ||
/// @param measurements All measurements in an event | ||
/// @param seeds All seeds in an event to start the track finding | ||
/// with | ||
/// | ||
/// @return A container of the found track candidates | ||
/// | ||
output_type operator()( | ||
const default_detector::view& det, | ||
const covfie::field<cuda::inhom_bfield_backend_t< | ||
default_detector::device::scalar_type>>::view_t& field, | ||
const measurement_collection_types::const_view& measurements, | ||
const bound_track_parameters_collection_types::const_view& seeds) | ||
const override; | ||
|
||
private: | ||
/// Algorithm configuration | ||
config_type m_config; | ||
/// Memory resource used by the algorithm | ||
traccc::memory_resource m_mr; | ||
/// Copy object used by the algorithm | ||
std::reference_wrapper<vecmem::copy> m_copy; | ||
/// The CUDA stream to use | ||
stream& m_stream; | ||
/// Warp size of the GPU being used | ||
unsigned int m_warp_size; | ||
}; // class combinatorial_kalman_filter_algorithm | ||
|
||
} // namespace traccc::cuda |
This file contains hidden or 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) 2025 CERN for the benefit of the ACTS project | ||
* | ||
* Mozilla Public License Version 2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
// Covfie include(s) | ||
#include <covfie/core/backend/primitive/constant.hpp> | ||
#include <covfie/core/backend/transformer/affine.hpp> | ||
#include <covfie/core/backend/transformer/linear.hpp> | ||
#include <covfie/core/backend/transformer/strided.hpp> | ||
#include <covfie/core/field.hpp> | ||
#include <covfie/core/vector.hpp> | ||
#include <covfie/cuda/backend/primitive/cuda_device_array.hpp> | ||
|
||
namespace traccc::cuda { | ||
|
||
template <typename scalar_t> | ||
using inhom_bfield_backend_t = covfie::backend::affine<covfie::backend::linear< | ||
covfie::backend::strided<covfie::vector::vector_d<std::size_t, 3>, | ||
covfie::backend::cuda_device_array< | ||
covfie::vector::vector_d<scalar_t, 3>>>>>; | ||
|
||
} // namespace traccc::cuda |
33 changes: 33 additions & 0 deletions
33
device/cuda/src/finding/combinatorial_kalman_filter_algorithm.cu
This file contains hidden or 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,33 @@ | ||
/** TRACCC library, part of the ACTS project (R&D line) | ||
* | ||
* (c) 2025 CERN for the benefit of the ACTS project | ||
* | ||
* Mozilla Public License Version 2.0 | ||
*/ | ||
|
||
// Local include(s). | ||
#include "traccc/cuda/finding/combinatorial_kalman_filter_algorithm.hpp" | ||
|
||
// System include(s). | ||
#include <stdexcept> | ||
|
||
namespace traccc::cuda { | ||
|
||
combinatorial_kalman_filter_algorithm::combinatorial_kalman_filter_algorithm( | ||
const config_type& config, const traccc::memory_resource& mr, | ||
vecmem::copy& copy, stream& str, std::unique_ptr<const Logger> logger) | ||
: messaging(std::move(logger)), | ||
m_config{config}, | ||
m_mr{mr}, | ||
m_copy{copy}, | ||
m_stream{str} { | ||
|
||
// Check the configuration. | ||
if (m_config.min_track_candidates_per_track == 0) { | ||
throw std::invalid_argument( | ||
"The minimum number of track candidates per track must be at least " | ||
"1."); | ||
} | ||
} | ||
|
||
} // namespace traccc::cuda |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stephenswat is the one to tell us this, but we should try texture memory right away, right? I assume that's a different type.