Skip to content

Commit 5e053bd

Browse files
committed
alternative implementation to silence compiler warnings
1 parent 447e5c8 commit 5e053bd

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

cpp/src/community/detail/common_methods.cuh

+12-13
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,11 @@ weight_t compute_modularity(
175175
//
176176
// Sum(Sigma_tot_c^2), over all clusters c
177177
//
178-
weight_t sum_degree_squared = thrust::transform_reduce(
179-
handle.get_thrust_policy(),
178+
auto squared_first = thrust::make_transform_iterator(
180179
cluster_weights.begin(),
181-
cluster_weights.end(),
182-
cuda::proclaim_return_type<weight_t>([] __device__(weight_t p) -> weight_t { return p * p; }),
183-
weight_t{0},
184-
thrust::plus<weight_t>());
180+
cuda::proclaim_return_type<weight_t>([] __device__(weight_t p) { return p * p; }));
181+
weight_t sum_degree_squared = thrust::reduce(
182+
handle.get_thrust_policy(), squared_first, squared_first + cluster_weights.size());
185183

186184
if constexpr (multi_gpu) {
187185
sum_degree_squared = host_scalar_allreduce(
@@ -199,13 +197,14 @@ weight_t compute_modularity(
199197
: detail::edge_minor_property_view_t<vertex_t, vertex_t const*>(next_clusters.begin(),
200198
vertex_t{0}),
201199
*edge_weight_view,
202-
[] __device__(auto, auto, auto src_cluster, auto nbr_cluster, weight_t wt) {
203-
if (src_cluster == nbr_cluster) {
204-
return wt;
205-
} else {
206-
return weight_t{0};
207-
}
208-
},
200+
cuda::proclaim_return_type<weight_t>(
201+
[] __device__(auto, auto, auto src_cluster, auto nbr_cluster, weight_t wt) {
202+
if (src_cluster == nbr_cluster) {
203+
return wt;
204+
} else {
205+
return weight_t{0};
206+
}
207+
}),
209208
weight_t{0});
210209

211210
weight_t Q = sum_internal / total_edge_weight -

0 commit comments

Comments
 (0)