Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging in fix with recent cugraph build failure #50

Merged
merged 2 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ add_library(cugraph
src/visitors/bfs_visitor.cpp
src/visitors/rw_visitor.cpp
src/visitors/graph_make_visitor.cpp
src/community/triangle_counts_sg.cu
src/community/triangle_counts_mg.cu
)

set_target_properties(cugraph
Expand Down
28 changes: 28 additions & 0 deletions cpp/include/cugraph/algorithms.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <cugraph-ops/graph/sampling.hpp>

#include <raft/handle.hpp>
#include <raft/span.hpp>

namespace cugraph {

Expand Down Expand Up @@ -1534,4 +1535,31 @@ uniform_nbr_sample(raft::handle_t const& handle,
std::vector<int> const& h_fan_out,
bool with_replacement = true);

/*
* @brief Compute triangle counts.
*
* Compute triangle counts for the entire set of vertices (if @p vertices is std::nullopt) or the
* given vertices (@p vertices.has_value() is true).
*
* @tparam vertex_t Type of vertex identifiers. Needs to be an integral type.
* @tparam edge_t Type of edge identifiers. Needs to be an integral type.
* @tparam weight_t Type of edge weights. Needs to be a floating point type.
* @tparam multi_gpu Flag indicating whether template instantiation should target single-GPU (false)
* @param handle RAFT handle object to encapsulate resources (e.g. CUDA stream, communicator, and
* handles to various CUDA libraries) to run graph algorithms.
* @param graph_view Graph view object.
* @param vertices Vertices to compute triangle counts. If @p vertices.has_value() is false, compute
* triangle counts for the entire set of vertices.
* @param counts Output triangle count array. The size of the array should be the local vertex
* partition range size (if @p vertices is std::nullopt) or the size of @p vertices (if @p
* vertices.has_value() is true).
* @param do_expensive_check A flag to run expensive checks for input arguments (if set to `true`).
*/
template <typename vertex_t, typename edge_t, typename weight_t, bool multi_gpu>
void triangle_counts(raft::handle_t const& handle,
graph_view_t<vertex_t, edge_t, weight_t, false, multi_gpu> const& graph_view,
std::optional<raft::device_span<vertex_t>> vertices,
raft::device_span<edge_t> counts,
bool do_expensive_check = false);

} // namespace cugraph
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ union pair_packer<pair_type, std::enable_if_t<is_packable<pair_type>()>> {
*/
template <typename Key,
typename Element,
typename Hasher = default_hash<Key>,
typename Hasher = cudf::detail::default_hash<Key>,
typename Equality = equal_to<Key>,
typename Allocator = default_allocator<thrust::pair<Key, Element>>>
class concurrent_unordered_map {
Expand Down
33 changes: 33 additions & 0 deletions cpp/src/community/triangle_counts_impl.cuh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once

#include <cugraph/algorithms.hpp>

namespace cugraph {

template <typename vertex_t, typename edge_t, typename weight_t, bool multi_gpu>
void triangle_counts(raft::handle_t const& handle,
graph_view_t<vertex_t, edge_t, weight_t, false, multi_gpu> const& graph_view,
std::optional<raft::device_span<vertex_t>> vertices,
raft::device_span<edge_t> counts,
bool do_expensive_check)
{
CUGRAPH_FAIL("unimplemented.");
return;
}

} // namespace cugraph
57 changes: 57 additions & 0 deletions cpp/src/community/triangle_counts_mg.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <community/triangle_counts_impl.cuh>

namespace cugraph {

void triangle_counts(raft::handle_t const& handle,
graph_view_t<int32_t, int32_t, float, false, true> const& graph_view,
std::optional<raft::device_span<int32_t>> vertices,
raft::device_span<int32_t> counts,
bool do_expensive_check);

void triangle_counts(raft::handle_t const& handle,
graph_view_t<int32_t, int32_t, double, false, true> const& graph_view,
std::optional<raft::device_span<int32_t>> vertices,
raft::device_span<int32_t> counts,
bool do_expensive_check);

void triangle_counts(raft::handle_t const& handle,
graph_view_t<int32_t, int64_t, float, false, true> const& graph_view,
std::optional<raft::device_span<int32_t>> vertices,
raft::device_span<int64_t> counts,
bool do_expensive_check);

void triangle_counts(raft::handle_t const& handle,
graph_view_t<int32_t, int64_t, double, false, true> const& graph_view,
std::optional<raft::device_span<int32_t>> vertices,
raft::device_span<int64_t> counts,
bool do_expensive_check);

void triangle_counts(raft::handle_t const& handle,
graph_view_t<int64_t, int64_t, float, false, true> const& graph_view,
std::optional<raft::device_span<int64_t>> vertices,
raft::device_span<int64_t> counts,
bool do_expensive_check);

void triangle_counts(raft::handle_t const& handle,
graph_view_t<int64_t, int64_t, double, false, true> const& graph_view,
std::optional<raft::device_span<int64_t>> vertices,
raft::device_span<int64_t> counts,
bool do_expensive_check);

} // namespace cugraph
57 changes: 57 additions & 0 deletions cpp/src/community/triangle_counts_sg.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <community/triangle_counts_impl.cuh>

namespace cugraph {

void triangle_counts(raft::handle_t const& handle,
graph_view_t<int32_t, int32_t, float, false, false> const& graph_view,
std::optional<raft::device_span<int32_t>> vertices,
raft::device_span<int32_t> counts,
bool do_expensive_check);

void triangle_counts(raft::handle_t const& handle,
graph_view_t<int32_t, int32_t, double, false, false> const& graph_view,
std::optional<raft::device_span<int32_t>> vertices,
raft::device_span<int32_t> counts,
bool do_expensive_check);

void triangle_counts(raft::handle_t const& handle,
graph_view_t<int32_t, int64_t, float, false, false> const& graph_view,
std::optional<raft::device_span<int32_t>> vertices,
raft::device_span<int64_t> counts,
bool do_expensive_check);

void triangle_counts(raft::handle_t const& handle,
graph_view_t<int32_t, int64_t, double, false, false> const& graph_view,
std::optional<raft::device_span<int32_t>> vertices,
raft::device_span<int64_t> counts,
bool do_expensive_check);

void triangle_counts(raft::handle_t const& handle,
graph_view_t<int64_t, int64_t, float, false, false> const& graph_view,
std::optional<raft::device_span<int64_t>> vertices,
raft::device_span<int64_t> counts,
bool do_expensive_check);

void triangle_counts(raft::handle_t const& handle,
graph_view_t<int64_t, int64_t, double, false, false> const& graph_view,
std::optional<raft::device_span<int64_t>> vertices,
raft::device_span<int64_t> counts,
bool do_expensive_check);

} // namespace cugraph
2 changes: 1 addition & 1 deletion python/cugraph/cugraph/structure/hypergraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ def _create_direct_edges(
def _str_scalar_to_category(size, val):
return cudf.core.column.build_categorical_column(
categories=cudf.core.column.as_column([val], dtype="str"),
codes=cudf.utils.utils.scalar_broadcast_to(0, size, dtype=np.int32),
codes=cudf.core.column.column.full(size, 0, dtype=np.int32),
mask=None,
size=size,
offset=0,
Expand Down