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

Initial cuGraph C API - biased RW, C tests, script updates, cmake files, C library helpers #1799

Merged
merged 73 commits into from
Oct 7, 2021

Conversation

aschaffer
Copy link
Collaborator

@aschaffer aschaffer commented Aug 31, 2021

Initial cuGraph C API:

  • C-API for Biased RW and supporting C library helpers.
  • cmake updates to build the new object files and library using the appropriate compiler (g++ or gcc) accordingly.
  • C tests written without gtests to ensure a pure-C application build works.
  • updated CI scripts to build and run the new tests.

The Python API for the updated Biased RW will be done in a separate PR.

aschaffer and others added 20 commits November 30, 2020 15:00
Update forked branch-0.18 from release
Update branch-0.19 from release
update forked from release branch-0.19
Merge from release branch-0.19
Merge latest rapidsai:branch-0.19 into aschaffer:branch-0.19
merge latest release branch-0.20
Merge latest rapidsai/branch-0.20 into forked branch-0.20
aschaffer/21.08 <- rapidsai/21.08
@aschaffer aschaffer requested a review from a team as a code owner August 31, 2021 20:14
@codecov-commenter
Copy link

codecov-commenter commented Sep 2, 2021

Codecov Report

❗ No coverage uploaded for pull request base (branch-21.12@1313e34). Click here to learn what that means.
The diff coverage is n/a.

❗ Current head a56fed6 differs from pull request most recent head bbadef7. Consider uploading reports for the commit bbadef7 to get more accurate results
Impacted file tree graph

@@               Coverage Diff               @@
##             branch-21.12    #1799   +/-   ##
===============================================
  Coverage                ?   70.10%           
===============================================
  Files                   ?      143           
  Lines                   ?     8827           
  Branches                ?        0           
===============================================
  Hits                    ?     6188           
  Misses                  ?     2639           
  Partials                ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1313e34...bbadef7. Read the comment docs.

@@ -205,6 +205,7 @@ add_library(cugraph SHARED
src/visitors/graph_envelope.cpp
src/visitors/visitors_factory.cpp
src/visitors/bfs_visitor.cpp
src/visitors/rw_visitor.cpp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, do we plan to place bindings related files under the cugrpah/cpp directory? Or we'd better separate the core libcugraph from the bindings related files? (i.e. placing bindings related files under something like cugraph/bindings)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The visitor implementation is not restricted to bindings only. It's meant to be (and it is) used for implementation purposes, too. These are cpp files. There will be a separate branch for the C-only API.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then, what about creating a separate directory under the cpp (similar to tests)? Is this directly relevant to libcugraph users? (someone willing to directly use our C++ API). If not, I am not sure it is a good idea to include this in our core libcugraph_(sg|mg).so.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is. As you probably know Visitor is useful to enrich the functionality of an object (visitee) without having to add new methods to it, which may inflate the code and cause merge conflicts on high traffic headers, like graph*.hpp .

The visitor abstraction is being used in RW, for example, for exactly such reasons.

Also, this structuring of this code has been in place for a while. And it has been extensively discussed before-hand (at least 2 presentations and demos have been done). Constantly shuffling code around after the fact is counterproductive, confusing, and wasteful. If new code restructuring is in the works, then this is not the PR for it. This PR has different goals. We've already agreed on small, targeted PRs as opposed to all-inclusive major code restructuring ones.

There's also the question of what exactly is the criterion for code cut-off to be accepted in cugraph. If this is to be discussed, then, again, maybe this is something to discuss before-fact, not after. I am starting to get the feeling that it's increasingly hard to get code accepted in cugraph and a lot of effort is potentially wasted with code shuffling and reshuffling on what appears to be quite ad-hoc and last-moment criteria.

@aschaffer aschaffer requested a review from a team as a code owner September 8, 2021 20:48
*/
return 0;

G = cugraph_make_sg_graph(&handle,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized I named the test and test file with the word "create" instead of "make". Similar to Chuck's comment re: func and file names matching, I'd make these match too (either change the API to "create" or the file and test to "make").


return (count_passed == num_paths);
}
int test_random_walks_1()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may not be finished updating this test, but just so you don't forget: this was just meant to be a placeholder name - I'd change it to something more descriptive so the user can identify what failed from the test output.

@rlratzel
Copy link
Contributor

rerun tests

Copy link
Contributor

@rlratzel rlratzel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still reviewing but a few things jumped out (I've only looked at the tests) so I'll post what I have so far.
My biggest concern is that it looks like some tests are hardcoded to return success, which should be easy to fix so that CI will actually catch problems.

int data_type_sz[] = {4, 8, 4, 8};
}

bool_t runtime_assert(bool_t statement_truth_value, const char* error_msg)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the name "assert" here is misleading. When reading code, I expect execution to stop when a false value is passed to this function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't necessarily agree, but you're free to change that.

cugraph_free_handle(p_handle);

/* because bools and err return codes from programs have opposite meaning...*/
if (flag_failed)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is still inverted: tests need to return 0 on success, but this will return 0 if flag_failed is true, meaning it's a failure? Maybe I'm confused...

edit: oh, this flag is only used for the check above which must "fail". I would possibly rename the variable, or add something to the comment, or change the name of the test, or all of the above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's correct. This is a negative test.

}

/* negative test RW call flow*/
int test_random_walks_3()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this tests and others still using the placeholder name need to have a more descriptive name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You provided these names. You're free to change them in the next release.

31, 32, 34, 312, 3124, 3125, 31246, 31256, 324, 325, 3246, 3256, 346, 46, 56};

/* linear search of `value` inside `p_cmprsd_path[max_num_paths]`*/
bool_t is_one_of(int32_t value, int32_t* p_cmprsd_path, int max_num_paths)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think some of these abbreviations are harder to type and read than the non-abbreviated words. Can this just say "compressed" instead of "cmprsd" (assuming that's what it's abbreviating)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, question of style/taste. You're free to change them in the next release.


cugraph_free_handle(p_handle);

return 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the asserts don't fail the test and their return values aren't being captured and checked, this test will always pass, and therefore CI will not catch anything.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is just debug info. We can modify this in the next release.

vertex_t h_start[] = {0, 2};

p_handle = cugraph_create_handle();
runtime_assert(p_handle != NULL, "raft handle creation failed.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this isn't a real assert (the implementation I saw above seems to just print to stderr), the final return value of the test needs to reflect if this fails, but it's just being ignored. Same for all other runtime_assert calls that aren't setting a flag of some sort.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can modify this in the next release.

cpp/tests/c_api/create_sg_graph_test.c Outdated Show resolved Hide resolved
@BradReesWork BradReesWork added this to the 21.10 milestone Sep 29, 2021
@BradReesWork BradReesWork modified the milestones: 21.10, 21.12 Sep 30, 2021
@BradReesWork BradReesWork changed the base branch from branch-21.10 to branch-21.12 September 30, 2021 14:43
@BradReesWork
Copy link
Member

rerun tests

Copy link
Collaborator

@ChuckHastings ChuckHastings left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #1867 to remind us to address the review feedback that is being deferred.

Copy link
Contributor

@rlratzel rlratzel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving now that #1867 has been created.

@ChuckHastings
Copy link
Collaborator

rerun tests

1 similar comment
@ChuckHastings
Copy link
Collaborator

rerun tests

@BradReesWork
Copy link
Member

@gpucibot merge

@rapids-bot rapids-bot bot merged commit 50158c6 into rapidsai:branch-21.12 Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement / enhancement to an existing function non-breaking Non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants