Skip to content

Commit

Permalink
fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
jnke2016 committed Jan 3, 2025
1 parent 0675c73 commit 2b1ac70
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 33 deletions.
63 changes: 31 additions & 32 deletions cpp/src/community/leiden_impl.cuh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2024, NVIDIA CORPORATION.
* Copyright (c) 2022-2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -718,53 +718,52 @@ std::pair<size_t, weight_t> leiden(
rmm::device_uvector<vertex_t> unique_cluster_ids(local_num_verts, handle.get_stream());

thrust::copy(handle.get_thrust_policy(),
clustering,
clustering + local_num_verts,
unique_cluster_ids.begin());
clustering,
clustering + local_num_verts,
unique_cluster_ids.begin());

thrust::sort(handle.get_thrust_policy(), unique_cluster_ids.begin(), unique_cluster_ids.end());

unique_cluster_ids.resize(
thrust::distance(
unique_cluster_ids.begin(),
thrust::unique(handle.get_thrust_policy(), unique_cluster_ids.begin(), unique_cluster_ids.end())),
handle.get_stream());
unique_cluster_ids.resize(thrust::distance(unique_cluster_ids.begin(),
thrust::unique(handle.get_thrust_policy(),
unique_cluster_ids.begin(),
unique_cluster_ids.end())),
handle.get_stream());

if constexpr (multi_gpu) {
auto recvcounts = cugraph::host_scalar_allgather(
handle.get_comms(), unique_cluster_ids.size(), handle.get_stream());

std::vector<size_t> displacements(recvcounts.size());
std::exclusive_scan(recvcounts.begin(), recvcounts.end(), displacements.begin(), size_t{0});
rmm::device_uvector<vertex_t> allgathered_unique_cluster_ids(displacements.back() + recvcounts.back(),
handle.get_stream());
rmm::device_uvector<vertex_t> allgathered_unique_cluster_ids(
displacements.back() + recvcounts.back(), handle.get_stream());
cugraph::device_allgatherv(handle.get_comms(),
unique_cluster_ids.begin(),
allgathered_unique_cluster_ids.begin(),
recvcounts,
displacements,
handle.get_stream());

thrust::sort(
handle.get_thrust_policy(),
allgathered_unique_cluster_ids.begin(),
allgathered_unique_cluster_ids.end());
unique_cluster_ids.begin(),
allgathered_unique_cluster_ids.begin(),
recvcounts,
displacements,
handle.get_stream());

thrust::sort(handle.get_thrust_policy(),
allgathered_unique_cluster_ids.begin(),
allgathered_unique_cluster_ids.end());

allgathered_unique_cluster_ids.resize(
thrust::distance(
allgathered_unique_cluster_ids.begin(),
thrust::unique(handle.get_thrust_policy(),
allgathered_unique_cluster_ids.begin(),
allgathered_unique_cluster_ids.end())),
handle.get_stream());

detail::relabel_cluster_ids<vertex_t, multi_gpu>(handle, allgathered_unique_cluster_ids, clustering, local_num_verts);
thrust::distance(allgathered_unique_cluster_ids.begin(),
thrust::unique(handle.get_thrust_policy(),
allgathered_unique_cluster_ids.begin(),
allgathered_unique_cluster_ids.end())),
handle.get_stream());

detail::relabel_cluster_ids<vertex_t, multi_gpu>(
handle, allgathered_unique_cluster_ids, clustering, local_num_verts);

} else {
detail::relabel_cluster_ids<vertex_t, multi_gpu>(handle, unique_cluster_ids, clustering, local_num_verts);
detail::relabel_cluster_ids<vertex_t, multi_gpu>(
handle, unique_cluster_ids, clustering, local_num_verts);
}


return std::make_pair(dendrogram->num_levels(), modularity);
}

Expand Down
2 changes: 1 addition & 1 deletion python/cugraph/cugraph/dask/community/leiden.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2022-2024, NVIDIA CORPORATION.
# Copyright (c) 2022-2025, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down

0 comments on commit 2b1ac70

Please sign in to comment.