-
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
Add SSSP API, test and implementation #2016
Add SSSP API, test and implementation #2016
Conversation
Codecov Report
@@ Coverage Diff @@
## branch-22.02 #2016 +/- ##
================================================
+ Coverage 70.16% 70.75% +0.59%
================================================
Files 142 142
Lines 8671 8861 +190
================================================
+ Hits 6084 6270 +186
- Misses 2587 2591 +4
Continue to review full report at Codecov.
|
Looks like there was an undetected CI failure with the new SSSP C API: |
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.
Looks good to me in general...
Some minor cosmetic issues to consider.
* @return error code | ||
*/ | ||
cugraph_error_code_t cugraph_sssp(const cugraph_resource_handle_t* handle, | ||
cugraph_graph_t* graph, |
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.
Can't graph
here be const?
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.
C api will transpose the graph if the input is opposite from what the algorithm requires. This will modify the graph.
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.
C api will transpose the graph if the input is opposite from what the algorithm requires. This will modify the graph.
Would it be better to set/return an error in that case? I'm envisioning a case where we or a user has a bug that isn't transposing data if an algo requires it, it gets silently transposed anyway, then we wonder why our benchmarks are slower than expected.
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.
Fair question. I think we've discussed this (or else I had this argument with myself... entirely possible).
From an API perspective, we have two choices:
- Do what the user is asking us to do regardless of the performance ramifications. The documentation should provide sufficient detail for the user to correct their bad choices.
- Require the user to understand the performance ramifications and make all of the right calls explicitly
The C++ layer has always opted for the latter and I believe it should. Thus far I have opted for the former in the C API. Now that @rlratzel is building the python
layer it would make sense for us to have this conversation. Perhaps the python
layer should worry about providing the intelligence and the C layer should (like the C++ layer) simply fail fast if the input is in the wrong orientation.
That would be an easy change, although I think it should not be rushed into this release.
cpp/include/cugraph_c/algorithms.h
Outdated
cugraph_graph_t* graph, | ||
size_t source, | ||
double cutoff, | ||
bool_t do_expensive_check, |
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.
In the C++ API, do_expensive_check
is the last parameter, any reason to deviate from this convention?
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.
I missed that when we did bfs :-(. The fact that we can't default parameters in the C API made me a little careless on this issue.
The current C API "convention" has been to mimic the input and have the last two parameters be the return type and the error code. I can swap do_expensive_check
and compute_predecessors
to make that more consistent. In the C++ API, compute_predecessors
is not a necessary parameter since we pass in the predecessors array and pass in a null pointer if we don't want to compute predecessors.
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.
Swapped these in latest push.
rerun tests |
* @return error code | ||
*/ | ||
cugraph_error_code_t cugraph_sssp(const cugraph_resource_handle_t* handle, | ||
cugraph_graph_t* graph, |
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.
C api will transpose the graph if the input is opposite from what the algorithm requires. This will modify the graph.
Would it be better to set/return an error in that case? I'm envisioning a case where we or a user has a bug that isn't transposing data if an algo requires it, it gets silently transposed anyway, then we wonder why our benchmarks are slower than expected.
if (!(RETURN_VALUE)) { \ | ||
(RETURN_VALUE) = !(STATEMENT); \ | ||
if ((RETURN_VALUE)) { printf("ASSERTION FAILED: %s\n", (MESSAGE)); } \ | ||
} \ |
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.
This is better than before since it won't clobber a prior failing return value, but maybe it's worthwhile to see all failing tests instead of just the first one. Would this work for that?
if (!(RETURN_VALUE)) { \ | |
(RETURN_VALUE) = !(STATEMENT); \ | |
if ((RETURN_VALUE)) { printf("ASSERTION FAILED: %s\n", (MESSAGE)); } \ | |
} \ | |
if (!(STATEMENT)) { \ | |
printf("ASSERTION FAILED: %s\n", (MESSAGE)); \ | |
(RETURN_VALUE) |= 1; \ | |
} \ |
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.
Maybe. Isn't the gtest convention to bail out of a particular test at the first failure and move on to the next test? For a larger test data set you could get thousands of errors from a particular test which is probably not desired.
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.
gtest supports either behavior, based on if you use the EXPECT_*
or ASSERT_*
assertions, where EXPECT will fail the test but continue running it to see everything (the behavior I described), and ASSERT will cause it to fail and return immediately. I wasn't thinking we'd have that many failures typically, but I don't feel strongly either way. Since this is named TEST_ASSERT
, I guess the current behavior is indeed closer to gtest's ASSERT_*
.
If you wanted to follow the gtest convention further, you could also have two different versions of the macros with the above names. Just another idea. My main concern was addressed (failures not reflected in the binary's exit code), so feel free to ignore this suggestion if you'd rather keep the current behavior.
rerun tests |
rerun tests |
@gpucibot merge |
@rlratzel needed the SSSP C API squeezed into version 22.02. Skipped the usual API PR and implementation PR to squeeze these together in the interest of time. Note that SSSP is nearly identical (semantically) to BFS which is already in the C API using a similar API.
This PR provides: