Skip to content

Commit a925454

Browse files
authored
Merge pull request #1283 from krasznaa/ClangFixes-main-20260330
Clang + FP64 Fixes, main branch (2026.03.30.)
2 parents 763dcfb + 6d0d7dd commit a925454

3 files changed

Lines changed: 23 additions & 17 deletions

File tree

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ TRACCC_HOST_DEVICE inline void find_tracks(
275275
const unsigned int owner_global_thread_id =
276276
owner_local_thread_id +
277277
thread_id.getBlockDimX() * thread_id.getBlockIdX();
278-
const float chi2 = std::get<0>(*result).filtered_chi2();
278+
const traccc::scalar chi2 =
279+
std::get<0>(*result).filtered_chi2();
279280
assert(chi2 >= 0.f);
280281
unsigned long long int* mutex_ptr =
281282
&shared_payload
@@ -366,6 +367,8 @@ TRACCC_HOST_DEVICE inline void find_tracks(
366367
const unsigned int p_offset =
367368
owner_global_thread_id *
368369
cfg.max_num_branches_per_surface;
370+
// No need to initialize this next variable. It always gets
371+
// a valid value in the proceeding expressions.
369372
float new_max;
370373

371374
if (index == cfg.max_num_branches_per_surface) {
@@ -375,11 +378,13 @@ TRACCC_HOST_DEVICE inline void find_tracks(
375378
* replace it. Also keep track of what the new maximum
376379
* $\chi^2$ value will be.
377380
*/
378-
float highest = 0.f;
381+
traccc::scalar highest =
382+
static_cast<traccc::scalar>(0.f);
379383

380384
for (unsigned int i = 0;
381385
i < cfg.max_num_branches_per_surface; ++i) {
382-
float old_chi2 = tmp_links.at(p_offset + i).chi2;
386+
const traccc::scalar old_chi2 =
387+
tmp_links.at(p_offset + i).chi2;
383388

384389
if (old_chi2 > highest) {
385390
highest = old_chi2;
@@ -390,14 +395,15 @@ TRACCC_HOST_DEVICE inline void find_tracks(
390395
assert(l_pos !=
391396
std::numeric_limits<unsigned int>::max());
392397

393-
new_max = chi2;
398+
new_max = static_cast<float>(chi2);
394399

395400
for (unsigned int i = 0;
396401
i < cfg.max_num_branches_per_surface; ++i) {
397-
float old_chi2 = tmp_links.at(p_offset + i).chi2;
402+
const traccc::scalar old_chi2 =
403+
tmp_links.at(p_offset + i).chi2;
398404

399405
if (i != l_pos && old_chi2 > new_max) {
400-
new_max = old_chi2;
406+
new_max = static_cast<float>(old_chi2);
401407
}
402408

403409
assert(old_chi2 <=
@@ -407,7 +413,7 @@ TRACCC_HOST_DEVICE inline void find_tracks(
407413
assert(chi2 <= new_max);
408414
} else {
409415
l_pos = index;
410-
new_max = std::max(chi2, max);
416+
new_max = std::max(static_cast<float>(chi2), max);
411417
}
412418

413419
assert(l_pos < cfg.max_num_branches_per_surface);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ TRACCC_HOST_DEVICE inline void gather_best_tips_per_measurement(
121121
tip_index.at(offset + out_idx) = thread_id;
122122
tip_pval.at(offset + out_idx) = pval;
123123

124-
typename algebra_t::scalar new_worst =
125-
std::numeric_limits<typename algebra_t::scalar>::max();
124+
float new_worst = std::numeric_limits<float>::max();
126125

127126
for (unsigned int i = 0; i < new_size; ++i) {
128-
new_worst =
129-
std::min(new_worst, tip_pval.at(offset + i));
127+
new_worst = std::min(
128+
new_worst,
129+
static_cast<float>(tip_pval.at(offset + i)));
130130
}
131131

132132
[[maybe_unused]] bool cas_result =

tests/cuda/test_grid2.cu

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void grid_replace_test(grid2_view<host_grid2_replace> grid_view) {
4545
const auto& axis0 = grid_view._axis_p0_view;
4646
const auto& axis1 = grid_view._axis_p1_view;
4747

48-
int block_dim = 1;
48+
unsigned int block_dim = 1;
4949
dim3 thread_dim(axis0.n_bins, axis1.n_bins);
5050

5151
// run the kernel
@@ -83,7 +83,7 @@ void grid_replace_ci_test(grid2_view<host_grid2_replace_ci> grid_view) {
8383
const auto& axis0 = grid_view._axis_p0_view;
8484
const auto& axis1 = grid_view._axis_p1_view;
8585

86-
int block_dim = 1;
86+
unsigned int block_dim = 1;
8787
dim3 thread_dim(axis0.n_bins, axis1.n_bins);
8888

8989
// run the kernel
@@ -127,7 +127,7 @@ void grid_complete_test(grid2_view<host_grid2_complete> grid_view) {
127127
const auto& axis0 = grid_view._axis_p0_view;
128128
const auto& axis1 = grid_view._axis_p1_view;
129129

130-
int block_dim = 1;
130+
unsigned int block_dim = 1;
131131
dim3 thread_dim(axis0.n_bins, axis1.n_bins);
132132

133133
// run the kernel
@@ -162,7 +162,7 @@ void grid_attach_read_test(const_grid2_view<host_grid2_attach> grid_view) {
162162
const auto& axis0 = grid_view._axis_p0_view;
163163
const auto& axis1 = grid_view._axis_p1_view;
164164

165-
int block_dim = 1;
165+
unsigned int block_dim = 1;
166166
dim3 thread_dim(axis0.n_bins, axis1.n_bins);
167167

168168
// run the kernel
@@ -206,7 +206,7 @@ void grid_attach_fill_test(grid2_view<host_grid2_attach> grid_view) {
206206
const auto& axis1 = grid_view._axis_p1_view;
207207

208208
dim3 block_dim(axis0.n_bins, axis1.n_bins);
209-
int thread_dim = 100;
209+
unsigned int thread_dim = 100;
210210

211211
// run the kernel
212212
grid_attach_fill_test_kernel<<<block_dim, thread_dim>>>(grid_view);
@@ -237,7 +237,7 @@ __global__ void grid_attach_assign_test_kernel(
237237
// attach_fill_test implementation
238238
void grid_attach_assign_test(grid2_view<host_grid2_attach> grid_view) {
239239

240-
int block_dim = 1;
240+
unsigned int block_dim = 1;
241241
dim3 thread_dim(2, 2);
242242

243243
// run the kernel

0 commit comments

Comments
 (0)