Skip to content

Commit bca39f4

Browse files
committed
Minor fixes to the track building kernel
This commit makes some minor fixes and improvements to the track building kernel. In particular, it: 1. Fixes an error where we were comparing measurements indices to see if they were _larger_ than the total number of measurements, but they should be check also for _equality_. 2. Fail more gracefully if we cannot find any true measurements, i.e. register the failed track as a candidate for pruning. 3. Simplify the control flow of the kernel by removing an unnecessary break statement.
1 parent a54d64a commit bca39f4

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

device/common/include/traccc/finding/device/impl/build_tracks.ipp

+11-8
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ TRACCC_DEVICE inline void build_tracks(const global_index_t globalIndex,
6565
// Resize the candidates with the exact size
6666
cands_per_track.resize(n_cands);
6767

68+
bool success = true;
69+
6870
// Reversely iterate to fill the track candidates
6971
for (auto it = cands_per_track.rbegin(); it != cands_per_track.rend();
7072
it++) {
7173

72-
while (L.meas_idx > n_meas &&
74+
while (L.meas_idx >= n_meas &&
7375
L.previous.first !=
7476
std::numeric_limits<
7577
candidate_link::link_index_type::first_type>::max()) {
@@ -78,26 +80,27 @@ TRACCC_DEVICE inline void build_tracks(const global_index_t globalIndex,
7880
}
7981

8082
// Break if the measurement is still invalid
81-
if (L.meas_idx > measurements.size()) {
83+
if (L.meas_idx >= measurements.size()) {
84+
success = false;
8285
break;
8386
}
8487

85-
auto& cand = *it;
86-
cand = {measurements.at(L.meas_idx)};
88+
*it = {measurements.at(L.meas_idx)};
8789

8890
// Break the loop if the iterator is at the first candidate and fill the
8991
// seed
9092
if (it == cands_per_track.rend() - 1) {
9193
seed = seeds.at(L.previous.second);
92-
break;
94+
} else {
95+
L = links[L.previous.first][L.previous.second];
9396
}
94-
95-
L = links[L.previous.first][L.previous.second];
9697
}
9798

99+
// NOTE: We may at some point want to assert that `success` is true
100+
98101
// Criteria for valid tracks
99102
if (n_cands >= cfg.min_track_candidates_per_track &&
100-
n_cands <= cfg.max_track_candidates_per_track) {
103+
n_cands <= cfg.max_track_candidates_per_track && success) {
101104

102105
vecmem::device_atomic_ref<unsigned int> num_valid_tracks(
103106
*payload.n_valid_tracks);

0 commit comments

Comments
 (0)