-
Notifications
You must be signed in to change notification settings - Fork 310
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
Fix OOB error, BFS C API should validate that the source vertex is a valid vertex #4077
Changes from 1 commit
3f8ac91
0f808e3
bb6e744
7cf5237
b6e3de7
a6f6202
dc103a8
2bb7a7b
2d61637
e16b4af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2021-2023, NVIDIA CORPORATION. | ||
* Copyright (c) 2021-2024, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
|
@@ -15,11 +15,13 @@ | |
*/ | ||
#include <cugraph/detail/utility_wrappers.hpp> | ||
#include <cugraph/utilities/error.hpp> | ||
#include <cugraph/utilities/host_scalar_comm.hpp> | ||
|
||
#include <raft/random/rng.cuh> | ||
|
||
#include <rmm/exec_policy.hpp> | ||
|
||
#include <thrust/count.h> | ||
#include <thrust/distance.h> | ||
#include <thrust/functional.h> | ||
#include <thrust/iterator/zip_iterator.h> | ||
|
@@ -227,5 +229,36 @@ template bool is_equal(raft::handle_t const& handle, | |
raft::device_span<int64_t const> span1, | ||
raft::device_span<int64_t const> span2); | ||
|
||
template <typename data_t, bool multi_gpu> | ||
size_t count_values(raft::handle_t const& handle, | ||
raft::device_span<data_t const> span, | ||
data_t value) | ||
{ | ||
size_t local_count = thrust::count_if( | ||
handle.get_thrust_policy(), span.begin(), span.end(), [value] __device__(data_t d) { | ||
return d == value; | ||
}); | ||
|
||
if constexpr (multi_gpu) { | ||
local_count = cugraph::host_scalar_allreduce( | ||
handle.get_comms(), local_count, raft::comms::op_t::SUM, handle.get_stream()); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All the other functions in this file are SG functions, and this function is an MG function. This might be confusing... Should we better resolve this?
What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll look at option 2. While I like option 3, there are many cases where we don't need to create a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I think what I'll do is move the all reduce (which doesn't use thrust, so can be called in a |
||
|
||
return local_count; | ||
} | ||
|
||
template size_t count_values<int32_t, false>(raft::handle_t const& handle, | ||
raft::device_span<int32_t const> span, | ||
int32_t value); | ||
template size_t count_values<int32_t, true>(raft::handle_t const& handle, | ||
raft::device_span<int32_t const> span, | ||
int32_t value); | ||
template size_t count_values<int64_t, false>(raft::handle_t const& handle, | ||
raft::device_span<int64_t const> span, | ||
int64_t value); | ||
template size_t count_values<int64_t, true>(raft::handle_t const& handle, | ||
raft::device_span<int64_t const> span, | ||
int64_t value); | ||
|
||
} // namespace detail | ||
} // namespace cugraph |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use thrust::count (https://thrust.github.io/doc/group__counting_ga4f2955d87ada73fc89f3442a19ca1bfa.html#ga4f2955d87ada73fc89f3442a19ca1bfa) and no need to provide a predicate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.