@@ -20,7 +20,7 @@ namespace traccc::device {
2020namespace details {
2121// Finding minimum element algorithm
2222template <typename Comparator>
23- TRACCC_HOST_DEVICE std::size_t min_elem (const triplet * arr,
23+ TRACCC_HOST_DEVICE std::size_t min_elem (const device_triplet * arr,
2424 const std::size_t begin_idx,
2525 const std::size_t end_idx,
2626 Comparator comp) {
@@ -38,11 +38,11 @@ TRACCC_HOST_DEVICE std::size_t min_elem(const triplet* arr,
3838
3939// Sorting algorithm for sorting seeds in the local memory
4040template <typename Comparator>
41- TRACCC_HOST_DEVICE void insertionSort (triplet * arr,
41+ TRACCC_HOST_DEVICE void insertionSort (device_triplet * arr,
4242 const unsigned int begin_idx,
4343 const unsigned int n, Comparator comp) {
4444 int j = 0 ;
45- triplet key = arr[begin_idx];
45+ device_triplet key = arr[begin_idx];
4646 for (unsigned int i = 0 ; i < n; ++i) {
4747 key = arr[begin_idx + i];
4848 j = static_cast <int >(i) - 1 ;
@@ -66,7 +66,7 @@ inline void select_seeds(
6666 const triplet_counter_spM_collection_types::const_view& spM_tc_view,
6767 const triplet_counter_collection_types::const_view& tc_view,
6868 const device_triplet_collection_types::const_view& triplet_view,
69- triplet * data, edm::seed_collection::view seed_view) {
69+ device_triplet * data, edm::seed_collection::view seed_view) {
7070
7171 // Check if anything needs to be done.
7272 const triplet_counter_spM_collection_types::const_device triplet_counts_spM (
@@ -89,8 +89,9 @@ inline void select_seeds(
8989 // Current work item = middle spacepoint
9090 const triplet_counter_spM spM_counter = triplet_counts_spM.at (globalIndex);
9191 const sp_location spM_loc = spM_counter.spM ;
92+ const unsigned int spM_idx = sp_device.bin (spM_loc.bin_idx )[spM_loc.sp_idx ];
9293 const edm::spacepoint_collection::const_device::const_proxy_type spM =
93- spacepoints.at (sp_device. bin (spM_loc. bin_idx )[spM_loc. sp_idx ] );
94+ spacepoints.at (spM_idx );
9495
9596 // Number of triplets added for this spM
9697 unsigned int n_triplets_per_spM = 0 ;
@@ -102,14 +103,12 @@ inline void select_seeds(
102103 device_triplet aTriplet = triplets[i];
103104
104105 // spacepoints bottom and top for this triplet
105- const sp_location spB_loc =
106- triplet_counts.at (static_cast <unsigned int >(aTriplet.counter_link ))
107- .spB ;
108- const sp_location spT_loc = aTriplet.spT ;
106+ const unsigned int spB_idx = aTriplet.spB ;
109107 const edm::spacepoint_collection::const_device::const_proxy_type spB =
110- spacepoints.at (sp_device.bin (spB_loc.bin_idx )[spB_loc.sp_idx ]);
108+ spacepoints.at (spB_idx);
109+ const unsigned int spT_idx = aTriplet.spT ;
111110 const edm::spacepoint_collection::const_device::const_proxy_type spT =
112- spacepoints.at (sp_device. bin (spT_loc. bin_idx )[spT_loc. sp_idx ] );
111+ spacepoints.at (spT_idx );
113112
114113 // update weight of triplet
115114 seed_selecting_helper::seed_weight (filter_config, spM, spB, spT,
@@ -125,61 +124,54 @@ inline void select_seeds(
125124 // the triplet with the lowest weight is removed
126125 if (n_triplets_per_spM >= filter_config.max_triplets_per_spM ) {
127126
128- const std::size_t min_index =
129- details::min_elem ( data, 0 , filter_config.max_triplets_per_spM ,
130- [](const triplet lhs, const triplet rhs) {
131- return lhs.weight > rhs.weight ;
132- });
127+ const std::size_t min_index = details::min_elem (
128+ data, 0 , filter_config.max_triplets_per_spM ,
129+ [](const device_triplet& lhs, const device_triplet& rhs) {
130+ return lhs.weight > rhs.weight ;
131+ });
133132
134133 const scalar& min_weight = data[min_index].weight ;
135134
136135 if (aTriplet.weight > min_weight) {
137- data[min_index] = {spB_loc, spM_loc,
138- spT_loc, aTriplet.curvature ,
139- aTriplet.weight , aTriplet.z_vertex };
136+ data[min_index] = aTriplet;
140137 }
141138 }
142139
143140 // if the number of good triplets is below the threshold, add
144141 // the current triplet to the array
145142 else if (n_triplets_per_spM < filter_config.max_triplets_per_spM ) {
146- data[n_triplets_per_spM] = {spB_loc, spM_loc,
147- spT_loc, aTriplet.curvature ,
148- aTriplet.weight , aTriplet.z_vertex };
143+ data[n_triplets_per_spM] = aTriplet;
149144 n_triplets_per_spM++;
150145 }
151146 }
152147
153148 // sort the triplets per spM
154149 details::insertionSort (
155150 data, 0 , n_triplets_per_spM,
156- traccc::details::triplet_sorter{spacepoints, sp_device});
151+ [](const device_triplet& lhs, const device_triplet& rhs) {
152+ return lhs.weight > rhs.weight ;
153+ });
157154
158155 // the number of good seed per compatible middle spacepoint
159156 unsigned int n_seeds_per_spM = 0 ;
160157
161158 // iterate over the good triplets for final selection of seeds
162159 for (unsigned int i = 0 ; i < n_triplets_per_spM; ++i) {
163- const triplet& aTriplet = data[i];
164- const sp_location& spB_loc = aTriplet.sp1 ;
165- const sp_location& spT_loc = aTriplet.sp3 ;
160+ const device_triplet& aTriplet = data[i];
166161
167162 // if the number of seeds reaches the threshold, break
168163 if (n_seeds_per_spM >= filter_config.maxSeedsPerSpM + 1 ) {
169164 break ;
170165 }
171166
172167 // check if it is a good triplet
173- if (seed_selecting_helper::cut_per_middle_sp (filter_config, spacepoints,
174- sp_device , aTriplet) ||
168+ if (seed_selecting_helper::cut_per_middle_sp (
169+ filter_config, spacepoints. at (aTriplet. spB ) , aTriplet. weight ) ||
175170 n_seeds_per_spM == 0 ) {
176171
177172 n_seeds_per_spM++;
178173
179- seeds_device.push_back (
180- {sp_device.bin (spB_loc.bin_idx )[spB_loc.sp_idx ],
181- sp_device.bin (spM_loc.bin_idx )[spM_loc.sp_idx ],
182- sp_device.bin (spT_loc.bin_idx )[spT_loc.sp_idx ]});
174+ seeds_device.push_back ({aTriplet.spB , aTriplet.spM , aTriplet.spT });
183175 }
184176 }
185177}
0 commit comments