@@ -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 ;
@@ -67,7 +67,7 @@ inline void select_seeds(
6767 const triplet_counter_spM_collection_types::const_view& spM_tc_view,
6868 const triplet_counter_collection_types::const_view& tc_view,
6969 const device_triplet_collection_types::const_view& triplet_view,
70- triplet * data, edm::seed_collection::view seed_view) {
70+ device_triplet * data, edm::seed_collection::view seed_view) {
7171
7272 // Check if anything needs to be done.
7373 const triplet_counter_spM_collection_types::const_device triplet_counts_spM (
@@ -90,8 +90,9 @@ inline void select_seeds(
9090 // Current work item = middle spacepoint
9191 const triplet_counter_spM spM_counter = triplet_counts_spM.at (globalIndex);
9292 const sp_location spM_loc = spM_counter.spM ;
93+ const unsigned int spM_idx = sp_device.bin (spM_loc.bin_idx )[spM_loc.sp_idx ];
9394 const edm::spacepoint_collection::const_device::const_proxy_type spM =
94- spacepoints.at (sp_device. bin (spM_loc. bin_idx )[spM_loc. sp_idx ] );
95+ spacepoints.at (spM_idx );
9596
9697 // Number of triplets added for this spM
9798 unsigned int n_triplets_per_spM = 0 ;
@@ -103,14 +104,12 @@ inline void select_seeds(
103104 device_triplet aTriplet = triplets[i];
104105
105106 // spacepoints bottom and top for this triplet
106- const sp_location spB_loc =
107- triplet_counts.at (static_cast <unsigned int >(aTriplet.counter_link ))
108- .spB ;
109- const sp_location spT_loc = aTriplet.spT ;
107+ const unsigned int spB_idx = aTriplet.spB ;
110108 const edm::spacepoint_collection::const_device::const_proxy_type spB =
111- spacepoints.at (sp_device.bin (spB_loc.bin_idx )[spB_loc.sp_idx ]);
109+ spacepoints.at (spB_idx);
110+ const unsigned int spT_idx = aTriplet.spT ;
112111 const edm::spacepoint_collection::const_device::const_proxy_type spT =
113- spacepoints.at (sp_device. bin (spT_loc. bin_idx )[spT_loc. sp_idx ] );
112+ spacepoints.at (spT_idx );
114113
115114 // update weight of triplet
116115 seed_selecting_helper::seed_weight (filter_config, spM, spB, spT,
@@ -126,61 +125,54 @@ inline void select_seeds(
126125 // the triplet with the lowest weight is removed
127126 if (n_triplets_per_spM >= finder_config.maxSeedsPerSpM ) {
128127
129- const std::size_t min_index =
130- details::min_elem ( data, 0 , finder_config.maxSeedsPerSpM ,
131- [](const triplet lhs, const triplet rhs) {
132- return lhs.weight > rhs.weight ;
133- });
128+ const std::size_t min_index = details::min_elem (
129+ data, 0 , finder_config.maxSeedsPerSpM ,
130+ [](const device_triplet& lhs, const device_triplet& rhs) {
131+ return lhs.weight > rhs.weight ;
132+ });
134133
135134 const scalar& min_weight = data[min_index].weight ;
136135
137136 if (aTriplet.weight > min_weight) {
138- data[min_index] = {spB_loc, spM_loc,
139- spT_loc, aTriplet.curvature ,
140- aTriplet.weight , aTriplet.z_vertex };
137+ data[min_index] = aTriplet;
141138 }
142139 }
143140
144141 // if the number of good triplets is below the threshold, add
145142 // the current triplet to the array
146143 else if (n_triplets_per_spM < finder_config.maxSeedsPerSpM ) {
147- data[n_triplets_per_spM] = {spB_loc, spM_loc,
148- spT_loc, aTriplet.curvature ,
149- aTriplet.weight , aTriplet.z_vertex };
144+ data[n_triplets_per_spM] = aTriplet;
150145 n_triplets_per_spM++;
151146 }
152147 }
153148
154149 // sort the triplets per spM
155150 details::insertionSort (
156151 data, 0 , n_triplets_per_spM,
157- traccc::details::triplet_sorter{spacepoints, sp_device});
152+ [](const device_triplet& lhs, const device_triplet& rhs) {
153+ return lhs.weight > rhs.weight ;
154+ });
158155
159156 // the number of good seed per compatible middle spacepoint
160157 unsigned int n_seeds_per_spM = 0 ;
161158
162159 // iterate over the good triplets for final selection of seeds
163160 for (unsigned int i = 0 ; i < n_triplets_per_spM; ++i) {
164- const triplet& aTriplet = data[i];
165- const sp_location& spB_loc = aTriplet.sp1 ;
166- const sp_location& spT_loc = aTriplet.sp3 ;
161+ const device_triplet& aTriplet = data[i];
167162
168163 // if the number of seeds reaches the threshold, break
169164 if (n_seeds_per_spM >= finder_config.maxSeedsPerSpM + 1 ) {
170165 break ;
171166 }
172167
173168 // check if it is a good triplet
174- if (seed_selecting_helper::cut_per_middle_sp (filter_config, spacepoints,
175- sp_device , aTriplet) ||
169+ if (seed_selecting_helper::cut_per_middle_sp (
170+ filter_config, spacepoints. at (aTriplet. spB ) , aTriplet. weight ) ||
176171 n_seeds_per_spM == 0 ) {
177172
178173 n_seeds_per_spM++;
179174
180- seeds_device.push_back (
181- {sp_device.bin (spB_loc.bin_idx )[spB_loc.sp_idx ],
182- sp_device.bin (spM_loc.bin_idx )[spM_loc.sp_idx ],
183- sp_device.bin (spT_loc.bin_idx )[spT_loc.sp_idx ]});
175+ seeds_device.push_back ({aTriplet.spB , aTriplet.spM , aTriplet.spT });
184176 }
185177 }
186178}
0 commit comments